@@ -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 | |
@@ -80,108 +80,106 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | public function get_data() { |
| 82 | 82 | |
| 83 | - $totals = $this->get_stored_data( 'give_temp_recount_all_stats' ); |
|
| 84 | - $payment_items = $this->get_stored_data( 'give_temp_payment_items' ); |
|
| 85 | - $processed_payments = $this->get_stored_data( 'give_temp_processed_payments' ); |
|
| 86 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
| 83 | + $totals = $this->get_stored_data('give_temp_recount_all_stats'); |
|
| 84 | + $payment_items = $this->get_stored_data('give_temp_payment_items'); |
|
| 85 | + $processed_payments = $this->get_stored_data('give_temp_processed_payments'); |
|
| 86 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
| 87 | 87 | |
| 88 | - if ( false === $totals ) { |
|
| 88 | + if (false === $totals) { |
|
| 89 | 89 | $totals = array(); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - if ( false === $payment_items ) { |
|
| 92 | + if (false === $payment_items) { |
|
| 93 | 93 | $payment_items = array(); |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - if ( false === $processed_payments ) { |
|
| 96 | + if (false === $processed_payments) { |
|
| 97 | 97 | $processed_payments = array(); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - $all_forms = $this->get_stored_data( 'give_temp_form_ids' ); |
|
| 100 | + $all_forms = $this->get_stored_data('give_temp_form_ids'); |
|
| 101 | 101 | |
| 102 | - $payments = $this->get_stored_data( 'give_temp_all_payments_data' ); |
|
| 102 | + $payments = $this->get_stored_data('give_temp_all_payments_data'); |
|
| 103 | 103 | |
| 104 | - if ( empty( $payments ) ) { |
|
| 105 | - $args = apply_filters( 'give_recount_form_stats_args', array( |
|
| 104 | + if (empty($payments)) { |
|
| 105 | + $args = apply_filters('give_recount_form_stats_args', array( |
|
| 106 | 106 | 'give_forms' => $all_forms, |
| 107 | 107 | 'number' => $this->per_step, |
| 108 | 108 | 'status' => $accepted_statuses, |
| 109 | 109 | 'paged' => $this->step, |
| 110 | 110 | 'output' => 'give_payments', |
| 111 | - ) ); |
|
| 111 | + )); |
|
| 112 | 112 | |
| 113 | - $payments_query = new Give_Payments_Query( $args ); |
|
| 113 | + $payments_query = new Give_Payments_Query($args); |
|
| 114 | 114 | $payments = $payments_query->get_payments(); |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - if ( ! empty( $payments ) ) { |
|
| 117 | + if ( ! empty($payments)) { |
|
| 118 | 118 | |
| 119 | 119 | //Loop through payments |
| 120 | - foreach ( $payments as $payment ) { |
|
| 120 | + foreach ($payments as $payment) { |
|
| 121 | 121 | |
| 122 | - $payment_id = ( ! empty( $payment['ID'] ) ? absint( $payment['ID'] ) : ( ! empty( $payment->ID ) ? absint( $payment->ID ) : false ) ); |
|
| 123 | - $payment = new Give_Payment( $payment_id ); |
|
| 122 | + $payment_id = ( ! empty($payment['ID']) ? absint($payment['ID']) : ( ! empty($payment->ID) ? absint($payment->ID) : false)); |
|
| 123 | + $payment = new Give_Payment($payment_id); |
|
| 124 | 124 | |
| 125 | 125 | // Prevent payments that have all ready been retrieved from a previous sales log from counting again. |
| 126 | - if ( in_array( $payment->ID, $processed_payments ) ) { |
|
| 126 | + if (in_array($payment->ID, $processed_payments)) { |
|
| 127 | 127 | continue; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | // Verify accepted status. |
| 131 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
| 131 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
| 132 | 132 | $processed_payments[] = $payment->ID; |
| 133 | 133 | continue; |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - $payment_item = $payment_items[ $payment->ID ]; |
|
| 136 | + $payment_item = $payment_items[$payment->ID]; |
|
| 137 | 137 | |
| 138 | - $form_id = isset( $payment_item['id'] ) ? $payment_item['id'] : ''; |
|
| 138 | + $form_id = isset($payment_item['id']) ? $payment_item['id'] : ''; |
|
| 139 | 139 | |
| 140 | 140 | // Must have a form ID. |
| 141 | - if ( empty( $form_id ) ) { |
|
| 141 | + if (empty($form_id)) { |
|
| 142 | 142 | continue; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | // Form ID must be within $all_forms array to be validated. |
| 146 | - if ( ! in_array( $form_id, $all_forms ) ) { |
|
| 146 | + if ( ! in_array($form_id, $all_forms)) { |
|
| 147 | 147 | continue; |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | // Set Sales count |
| 151 | - $totals[ $form_id ]['sales'] = isset( $totals[ $form_id ]['sales'] ) ? |
|
| 152 | - ++ $totals[ $form_id ]['sales'] : |
|
| 153 | - 1; |
|
| 151 | + $totals[$form_id]['sales'] = isset($totals[$form_id]['sales']) ? |
|
| 152 | + ++$totals[$form_id]['sales'] : 1; |
|
| 154 | 153 | |
| 155 | 154 | // Set Total Earnings |
| 156 | - $totals[ $form_id ]['earnings'] = isset( $totals[ $form_id ]['earnings'] ) ? |
|
| 157 | - ( $totals[ $form_id ]['earnings'] + $payment_item['price'] ) : |
|
| 158 | - $payment_item['price']; |
|
| 155 | + $totals[$form_id]['earnings'] = isset($totals[$form_id]['earnings']) ? |
|
| 156 | + ($totals[$form_id]['earnings'] + $payment_item['price']) : $payment_item['price']; |
|
| 159 | 157 | |
| 160 | 158 | $processed_payments[] = $payment->ID; |
| 161 | 159 | } |
| 162 | 160 | |
| 163 | 161 | // Get the list of form ids which does not contain any payment record. |
| 164 | - $remaining_form_ids = array_diff( $all_forms, array_keys( $totals ) ); |
|
| 165 | - foreach ( $remaining_form_ids as $form_id ) { |
|
| 162 | + $remaining_form_ids = array_diff($all_forms, array_keys($totals)); |
|
| 163 | + foreach ($remaining_form_ids as $form_id) { |
|
| 166 | 164 | //If array key doesn't exist, create it |
| 167 | - if ( ! array_key_exists( $form_id, $totals ) ) { |
|
| 168 | - $totals[ $form_id ] = array( |
|
| 165 | + if ( ! array_key_exists($form_id, $totals)) { |
|
| 166 | + $totals[$form_id] = array( |
|
| 169 | 167 | 'sales' => (int) 0, |
| 170 | 168 | 'earnings' => (float) 0, |
| 171 | 169 | ); |
| 172 | 170 | } |
| 173 | 171 | } |
| 174 | 172 | |
| 175 | - $this->store_data( 'give_temp_processed_payments', $processed_payments ); |
|
| 176 | - $this->store_data( 'give_temp_recount_all_stats', $totals ); |
|
| 173 | + $this->store_data('give_temp_processed_payments', $processed_payments); |
|
| 174 | + $this->store_data('give_temp_recount_all_stats', $totals); |
|
| 177 | 175 | |
| 178 | 176 | return true; |
| 179 | 177 | } |
| 180 | 178 | |
| 181 | 179 | |
| 182 | - foreach ( $totals as $key => $stats ) { |
|
| 183 | - give_update_meta( $key, '_give_form_sales', $stats['sales'] ); |
|
| 184 | - give_update_meta( $key, '_give_form_earnings', give_sanitize_amount_for_db( $stats['earnings'] ) ); |
|
| 180 | + foreach ($totals as $key => $stats) { |
|
| 181 | + give_update_meta($key, '_give_form_sales', $stats['sales']); |
|
| 182 | + give_update_meta($key, '_give_form_earnings', give_sanitize_amount_for_db($stats['earnings'])); |
|
| 185 | 183 | } |
| 186 | 184 | |
| 187 | 185 | return false; |
@@ -196,20 +194,20 @@ discard block |
||
| 196 | 194 | */ |
| 197 | 195 | public function get_percentage_complete() { |
| 198 | 196 | |
| 199 | - $total = $this->get_stored_data( 'give_recount_all_total' ); |
|
| 197 | + $total = $this->get_stored_data('give_recount_all_total'); |
|
| 200 | 198 | |
| 201 | - if ( false === $total ) { |
|
| 199 | + if (false === $total) { |
|
| 202 | 200 | $this->pre_fetch(); |
| 203 | - $total = $this->get_stored_data( 'give_recount_all_total' ); |
|
| 201 | + $total = $this->get_stored_data('give_recount_all_total'); |
|
| 204 | 202 | } |
| 205 | 203 | |
| 206 | 204 | $percentage = 100; |
| 207 | 205 | |
| 208 | - if ( $total > 0 ) { |
|
| 209 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
| 206 | + if ($total > 0) { |
|
| 207 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
| 210 | 208 | } |
| 211 | 209 | |
| 212 | - if ( $percentage > 100 ) { |
|
| 210 | + if ($percentage > 100) { |
|
| 213 | 211 | $percentage = 100; |
| 214 | 212 | } |
| 215 | 213 | |
@@ -223,8 +221,8 @@ discard block |
||
| 223 | 221 | * |
| 224 | 222 | * @param array $request The Form Data passed into the batch processing |
| 225 | 223 | */ |
| 226 | - public function set_properties( $request ) { |
|
| 227 | - $this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false; |
|
| 224 | + public function set_properties($request) { |
|
| 225 | + $this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false; |
|
| 228 | 226 | } |
| 229 | 227 | |
| 230 | 228 | /** |
@@ -235,25 +233,25 @@ discard block |
||
| 235 | 233 | */ |
| 236 | 234 | public function process_step() { |
| 237 | 235 | |
| 238 | - if ( ! $this->can_export() ) { |
|
| 239 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 236 | + if ( ! $this->can_export()) { |
|
| 237 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 240 | 238 | } |
| 241 | 239 | |
| 242 | 240 | $had_data = $this->get_data(); |
| 243 | 241 | |
| 244 | - if ( $had_data ) { |
|
| 242 | + if ($had_data) { |
|
| 245 | 243 | $this->done = false; |
| 246 | 244 | |
| 247 | 245 | return true; |
| 248 | 246 | } else { |
| 249 | - $this->delete_data( 'give_recount_total_' . $this->form_id ); |
|
| 250 | - $this->delete_data( 'give_recount_all_total' ); |
|
| 251 | - $this->delete_data( 'give_temp_recount_all_stats' ); |
|
| 252 | - $this->delete_data( 'give_temp_payment_items' ); |
|
| 253 | - $this->delete_data( 'give_temp_form_ids' ); |
|
| 254 | - $this->delete_data( 'give_temp_processed_payments' ); |
|
| 247 | + $this->delete_data('give_recount_total_'.$this->form_id); |
|
| 248 | + $this->delete_data('give_recount_all_total'); |
|
| 249 | + $this->delete_data('give_temp_recount_all_stats'); |
|
| 250 | + $this->delete_data('give_temp_payment_items'); |
|
| 251 | + $this->delete_data('give_temp_form_ids'); |
|
| 252 | + $this->delete_data('give_temp_processed_payments'); |
|
| 255 | 253 | $this->done = true; |
| 256 | - $this->message = esc_html__( 'Donation form income amounts and donation counts stats successfully recounted.', 'give' ); |
|
| 254 | + $this->message = esc_html__('Donation form income amounts and donation counts stats successfully recounted.', 'give'); |
|
| 257 | 255 | |
| 258 | 256 | return false; |
| 259 | 257 | } |
@@ -263,10 +261,10 @@ discard block |
||
| 263 | 261 | * Set headers. |
| 264 | 262 | */ |
| 265 | 263 | public function headers() { |
| 266 | - ignore_user_abort( true ); |
|
| 264 | + ignore_user_abort(true); |
|
| 267 | 265 | |
| 268 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 269 | - set_time_limit( 0 ); |
|
| 266 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
| 267 | + set_time_limit(0); |
|
| 270 | 268 | } |
| 271 | 269 | } |
| 272 | 270 | |
@@ -293,70 +291,70 @@ discard block |
||
| 293 | 291 | */ |
| 294 | 292 | public function pre_fetch() { |
| 295 | 293 | |
| 296 | - if ( 1 == $this->step ) { |
|
| 297 | - $this->delete_data( 'give_temp_recount_all_total' ); |
|
| 298 | - $this->delete_data( 'give_temp_recount_all_stats' ); |
|
| 299 | - $this->delete_data( 'give_temp_payment_items' ); |
|
| 300 | - $this->delete_data( 'give_temp_processed_payments' ); |
|
| 301 | - $this->delete_data( 'give_temp_all_payments_data' ); |
|
| 294 | + if (1 == $this->step) { |
|
| 295 | + $this->delete_data('give_temp_recount_all_total'); |
|
| 296 | + $this->delete_data('give_temp_recount_all_stats'); |
|
| 297 | + $this->delete_data('give_temp_payment_items'); |
|
| 298 | + $this->delete_data('give_temp_processed_payments'); |
|
| 299 | + $this->delete_data('give_temp_all_payments_data'); |
|
| 302 | 300 | } |
| 303 | 301 | |
| 304 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
| 305 | - $total = $this->get_stored_data( 'give_temp_recount_all_total' ); |
|
| 302 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
| 303 | + $total = $this->get_stored_data('give_temp_recount_all_total'); |
|
| 306 | 304 | |
| 307 | - if ( false === $total ) { |
|
| 305 | + if (false === $total) { |
|
| 308 | 306 | |
| 309 | - $payment_items = $this->get_stored_data( 'give_temp_payment_items' ); |
|
| 307 | + $payment_items = $this->get_stored_data('give_temp_payment_items'); |
|
| 310 | 308 | |
| 311 | - if ( false === $payment_items ) { |
|
| 309 | + if (false === $payment_items) { |
|
| 312 | 310 | $payment_items = array(); |
| 313 | - $this->store_data( 'give_temp_payment_items', $payment_items ); |
|
| 311 | + $this->store_data('give_temp_payment_items', $payment_items); |
|
| 314 | 312 | } |
| 315 | 313 | |
| 316 | 314 | $args = array( |
| 317 | 315 | 'post_status' => 'publish', |
| 318 | 316 | 'post_type' => 'give_forms', |
| 319 | - 'posts_per_page' => - 1, |
|
| 317 | + 'posts_per_page' => -1, |
|
| 320 | 318 | 'fields' => 'ids', |
| 321 | 319 | ); |
| 322 | 320 | |
| 323 | - $all_forms = get_posts( $args ); |
|
| 321 | + $all_forms = get_posts($args); |
|
| 324 | 322 | |
| 325 | - $this->store_data( 'give_temp_form_ids', $all_forms ); |
|
| 323 | + $this->store_data('give_temp_form_ids', $all_forms); |
|
| 326 | 324 | |
| 327 | - $args = apply_filters( 'give_recount_form_stats_total_args', array( |
|
| 325 | + $args = apply_filters('give_recount_form_stats_total_args', array( |
|
| 328 | 326 | 'give_forms' => $all_forms, |
| 329 | 327 | 'number' => $this->per_step, |
| 330 | 328 | 'status' => $accepted_statuses, |
| 331 | 329 | 'page' => $this->step, |
| 332 | 330 | 'output' => 'payments', |
| 333 | - ) ); |
|
| 331 | + )); |
|
| 334 | 332 | |
| 335 | - $payments_query = new Give_Payments_Query( $args ); |
|
| 333 | + $payments_query = new Give_Payments_Query($args); |
|
| 336 | 334 | $payments = $payments_query->get_payments(); |
| 337 | 335 | |
| 338 | - $total = wp_count_posts( 'give_payment' )->publish; |
|
| 336 | + $total = wp_count_posts('give_payment')->publish; |
|
| 339 | 337 | |
| 340 | - $this->store_data( 'give_temp_all_payments_data', $payments ); |
|
| 338 | + $this->store_data('give_temp_all_payments_data', $payments); |
|
| 341 | 339 | |
| 342 | - if ( $payments ) { |
|
| 340 | + if ($payments) { |
|
| 343 | 341 | |
| 344 | - foreach ( $payments as $payment ) { |
|
| 342 | + foreach ($payments as $payment) { |
|
| 345 | 343 | |
| 346 | 344 | $form_id = $payment->form_id; |
| 347 | 345 | |
| 348 | 346 | //If for some reason somehow the form_ID isn't set check payment meta |
| 349 | - if ( empty( $payment->form_id ) ) { |
|
| 347 | + if (empty($payment->form_id)) { |
|
| 350 | 348 | $payment_meta = $payment->get_meta(); |
| 351 | - $form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0; |
|
| 349 | + $form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0; |
|
| 352 | 350 | } |
| 353 | 351 | |
| 354 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
| 352 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
| 355 | 353 | continue; |
| 356 | 354 | } |
| 357 | 355 | |
| 358 | - if ( ! array_key_exists( $payment->ID, $payment_items ) ) { |
|
| 359 | - $payment_items[ $payment->ID ] = array( |
|
| 356 | + if ( ! array_key_exists($payment->ID, $payment_items)) { |
|
| 357 | + $payment_items[$payment->ID] = array( |
|
| 360 | 358 | 'id' => $form_id, |
| 361 | 359 | 'payment_id' => $payment->ID, |
| 362 | 360 | 'price' => $payment->total, |
@@ -364,8 +362,8 @@ discard block |
||
| 364 | 362 | } |
| 365 | 363 | } |
| 366 | 364 | } |
| 367 | - $this->store_data( 'give_temp_payment_items', $payment_items ); |
|
| 368 | - $this->store_data( 'give_recount_all_total', $total ); |
|
| 365 | + $this->store_data('give_temp_payment_items', $payment_items); |
|
| 366 | + $this->store_data('give_recount_all_total', $total); |
|
| 369 | 367 | } |
| 370 | 368 | |
| 371 | 369 | } |
@@ -379,17 +377,17 @@ discard block |
||
| 379 | 377 | * |
| 380 | 378 | * @return mixed Returns the data from the database |
| 381 | 379 | */ |
| 382 | - private function get_stored_data( $key ) { |
|
| 380 | + private function get_stored_data($key) { |
|
| 383 | 381 | global $wpdb; |
| 384 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
| 385 | - if ( empty( $value ) ) { |
|
| 382 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
| 383 | + if (empty($value)) { |
|
| 386 | 384 | return false; |
| 387 | 385 | } |
| 388 | 386 | |
| 389 | - $maybe_json = json_decode( $value ); |
|
| 387 | + $maybe_json = json_decode($value); |
|
| 390 | 388 | |
| 391 | - if ( ! is_null( $maybe_json ) ) { |
|
| 392 | - $value = json_decode( $value, true ); |
|
| 389 | + if ( ! is_null($maybe_json)) { |
|
| 390 | + $value = json_decode($value, true); |
|
| 393 | 391 | } |
| 394 | 392 | |
| 395 | 393 | return $value; |
@@ -405,10 +403,10 @@ discard block |
||
| 405 | 403 | * |
| 406 | 404 | * @return void |
| 407 | 405 | */ |
| 408 | - private function store_data( $key, $value ) { |
|
| 406 | + private function store_data($key, $value) { |
|
| 409 | 407 | global $wpdb; |
| 410 | 408 | |
| 411 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
| 409 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
| 412 | 410 | |
| 413 | 411 | $data = array( |
| 414 | 412 | 'option_name' => $key, |
@@ -422,7 +420,7 @@ discard block |
||
| 422 | 420 | '%s', |
| 423 | 421 | ); |
| 424 | 422 | |
| 425 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
| 423 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
| 426 | 424 | } |
| 427 | 425 | |
| 428 | 426 | /** |
@@ -434,9 +432,9 @@ discard block |
||
| 434 | 432 | * |
| 435 | 433 | * @return void |
| 436 | 434 | */ |
| 437 | - private function delete_data( $key ) { |
|
| 435 | + private function delete_data($key) { |
|
| 438 | 436 | global $wpdb; |
| 439 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
| 437 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
| 440 | 438 | } |
| 441 | 439 | |
| 442 | 440 | } |
@@ -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 | |
@@ -53,40 +53,40 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | public function get_data() { |
| 55 | 55 | |
| 56 | - $donor = new Give_Donor( $this->customer_id ); |
|
| 57 | - $payments = $this->get_stored_data( 'give_recount_donor_payments_' . $donor->id ); |
|
| 56 | + $donor = new Give_Donor($this->customer_id); |
|
| 57 | + $payments = $this->get_stored_data('give_recount_donor_payments_'.$donor->id); |
|
| 58 | 58 | |
| 59 | - $offset = ( $this->step - 1 ) * $this->per_step; |
|
| 60 | - $step_items = array_slice( $payments, $offset, $this->per_step ); |
|
| 59 | + $offset = ($this->step - 1) * $this->per_step; |
|
| 60 | + $step_items = array_slice($payments, $offset, $this->per_step); |
|
| 61 | 61 | |
| 62 | - if ( count( $step_items ) > 0 ) { |
|
| 63 | - $pending_total = (float) $this->get_stored_data( 'give_stats_donor_pending_total' . $donor->id ); |
|
| 62 | + if (count($step_items) > 0) { |
|
| 63 | + $pending_total = (float) $this->get_stored_data('give_stats_donor_pending_total'.$donor->id); |
|
| 64 | 64 | $step_total = 0; |
| 65 | 65 | |
| 66 | - $found_payment_ids = $this->get_stored_data( 'give_stats_found_payments_' . $donor->id ); |
|
| 66 | + $found_payment_ids = $this->get_stored_data('give_stats_found_payments_'.$donor->id); |
|
| 67 | 67 | |
| 68 | - foreach ( $step_items as $payment ) { |
|
| 69 | - $payment = get_post( $payment->ID ); |
|
| 68 | + foreach ($step_items as $payment) { |
|
| 69 | + $payment = get_post($payment->ID); |
|
| 70 | 70 | |
| 71 | - if ( is_null( $payment ) || is_wp_error( $payment ) || 'give_payment' !== $payment->post_type ) { |
|
| 71 | + if (is_null($payment) || is_wp_error($payment) || 'give_payment' !== $payment->post_type) { |
|
| 72 | 72 | |
| 73 | - $missing_payments = $this->get_stored_data( 'give_stats_missing_payments' . $donor->id ); |
|
| 73 | + $missing_payments = $this->get_stored_data('give_stats_missing_payments'.$donor->id); |
|
| 74 | 74 | $missing_payments[] = $payment->ID; |
| 75 | - $this->store_data( 'give_stats_missing_payments' . $donor->id, $missing_payments ); |
|
| 75 | + $this->store_data('give_stats_missing_payments'.$donor->id, $missing_payments); |
|
| 76 | 76 | |
| 77 | 77 | continue; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | $should_process_payment = 'publish' == $payment->post_status ? true : false; |
| 81 | - $should_process_payment = apply_filters( 'give_donor_recount_should_process_donation', $should_process_payment, $payment ); |
|
| 81 | + $should_process_payment = apply_filters('give_donor_recount_should_process_donation', $should_process_payment, $payment); |
|
| 82 | 82 | |
| 83 | - if ( true === $should_process_payment ) { |
|
| 83 | + if (true === $should_process_payment) { |
|
| 84 | 84 | |
| 85 | 85 | $found_payment_ids[] = $payment->ID; |
| 86 | 86 | |
| 87 | - if ( apply_filters( 'give_donor_recount_should_increase_value', true, $payment ) ) { |
|
| 88 | - $payment_amount = give_donation_amount( $payment->ID ); |
|
| 89 | - $step_total += $payment_amount; |
|
| 87 | + if (apply_filters('give_donor_recount_should_increase_value', true, $payment)) { |
|
| 88 | + $payment_amount = give_donation_amount($payment->ID); |
|
| 89 | + $step_total += $payment_amount; |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | } |
@@ -94,8 +94,8 @@ discard block |
||
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | $updated_total = $pending_total + $step_total; |
| 97 | - $this->store_data( 'give_stats_donor_pending_total' . $donor->id, $updated_total ); |
|
| 98 | - $this->store_data( 'give_stats_found_payments_' . $donor->id, $found_payment_ids ); |
|
| 97 | + $this->store_data('give_stats_donor_pending_total'.$donor->id, $updated_total); |
|
| 98 | + $this->store_data('give_stats_found_payments_'.$donor->id, $found_payment_ids); |
|
| 99 | 99 | |
| 100 | 100 | return true; |
| 101 | 101 | } |
@@ -112,16 +112,16 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | public function get_percentage_complete() { |
| 114 | 114 | |
| 115 | - $payments = $this->get_stored_data( 'give_recount_donor_payments_' . $this->customer_id ); |
|
| 116 | - $total = count( $payments ); |
|
| 115 | + $payments = $this->get_stored_data('give_recount_donor_payments_'.$this->customer_id); |
|
| 116 | + $total = count($payments); |
|
| 117 | 117 | |
| 118 | 118 | $percentage = 100; |
| 119 | 119 | |
| 120 | - if ( $total > 0 ) { |
|
| 121 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
| 120 | + if ($total > 0) { |
|
| 121 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - if ( $percentage > 100 ) { |
|
| 124 | + if ($percentage > 100) { |
|
| 125 | 125 | $percentage = 100; |
| 126 | 126 | } |
| 127 | 127 | |
@@ -135,8 +135,8 @@ discard block |
||
| 135 | 135 | * |
| 136 | 136 | * @param array $request The Form Data passed into the batch processing |
| 137 | 137 | */ |
| 138 | - public function set_properties( $request ) { |
|
| 139 | - $this->customer_id = isset( $request['customer_id'] ) ? sanitize_text_field( $request['customer_id'] ) : false; |
|
| 138 | + public function set_properties($request) { |
|
| 139 | + $this->customer_id = isset($request['customer_id']) ? sanitize_text_field($request['customer_id']) : false; |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | /** |
@@ -147,63 +147,63 @@ discard block |
||
| 147 | 147 | */ |
| 148 | 148 | public function process_step() { |
| 149 | 149 | |
| 150 | - if ( ! $this->can_export() ) { |
|
| 151 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 150 | + if ( ! $this->can_export()) { |
|
| 151 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | $had_data = $this->get_data(); |
| 155 | 155 | |
| 156 | - if ( $had_data ) { |
|
| 156 | + if ($had_data) { |
|
| 157 | 157 | $this->done = false; |
| 158 | 158 | |
| 159 | 159 | return true; |
| 160 | 160 | } else { |
| 161 | - $donor = new Give_Donor( $this->customer_id ); |
|
| 162 | - $payment_ids = get_option( 'give_stats_found_payments_' . $donor->id, array() ); |
|
| 163 | - $this->delete_data( 'give_stats_found_payments_' . $donor->id ); |
|
| 161 | + $donor = new Give_Donor($this->customer_id); |
|
| 162 | + $payment_ids = get_option('give_stats_found_payments_'.$donor->id, array()); |
|
| 163 | + $this->delete_data('give_stats_found_payments_'.$donor->id); |
|
| 164 | 164 | |
| 165 | - $removed_payments = array_unique( get_option( 'give_stats_missing_payments' . $donor->id, array() ) ); |
|
| 165 | + $removed_payments = array_unique(get_option('give_stats_missing_payments'.$donor->id, array())); |
|
| 166 | 166 | |
| 167 | 167 | // Find non-existing payments (deleted) and total up the donation count |
| 168 | 168 | $purchase_count = 0; |
| 169 | - foreach ( $payment_ids as $key => $payment_id ) { |
|
| 170 | - if ( in_array( $payment_id, $removed_payments ) ) { |
|
| 171 | - unset( $payment_ids[ $key ] ); |
|
| 169 | + foreach ($payment_ids as $key => $payment_id) { |
|
| 170 | + if (in_array($payment_id, $removed_payments)) { |
|
| 171 | + unset($payment_ids[$key]); |
|
| 172 | 172 | continue; |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - $payment = get_post( $payment_id ); |
|
| 176 | - if ( apply_filters( 'give_donor_recount_should_increase_count', true, $payment ) ) { |
|
| 177 | - $purchase_count ++; |
|
| 175 | + $payment = get_post($payment_id); |
|
| 176 | + if (apply_filters('give_donor_recount_should_increase_count', true, $payment)) { |
|
| 177 | + $purchase_count++; |
|
| 178 | 178 | } |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - $this->delete_data( 'give_stats_missing_payments' . $donor->id ); |
|
| 181 | + $this->delete_data('give_stats_missing_payments'.$donor->id); |
|
| 182 | 182 | |
| 183 | - $pending_total = $this->get_stored_data( 'give_stats_donor_pending_total' . $donor->id ); |
|
| 184 | - $this->delete_data( 'give_stats_donor_pending_total' . $donor->id ); |
|
| 185 | - $this->delete_data( 'give_recount_donor_stats_' . $donor->id ); |
|
| 186 | - $this->delete_data( 'give_recount_donor_payments_' . $this->customer_id ); |
|
| 183 | + $pending_total = $this->get_stored_data('give_stats_donor_pending_total'.$donor->id); |
|
| 184 | + $this->delete_data('give_stats_donor_pending_total'.$donor->id); |
|
| 185 | + $this->delete_data('give_recount_donor_stats_'.$donor->id); |
|
| 186 | + $this->delete_data('give_recount_donor_payments_'.$this->customer_id); |
|
| 187 | 187 | |
| 188 | - $payment_ids = implode( ',', $payment_ids ); |
|
| 189 | - $donor->update( array( |
|
| 188 | + $payment_ids = implode(',', $payment_ids); |
|
| 189 | + $donor->update(array( |
|
| 190 | 190 | '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 have been successfully recounted.', 'give' ); |
|
| 196 | + $this->message = esc_html__('Donor stats have been 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_donors_donation_statuses', give_get_payment_status_keys() ); |
|
| 233 | + if ($this->step === 1) { |
|
| 234 | + $allowed_payment_status = apply_filters('give_recount_donors_donation_statuses', give_get_payment_status_keys()); |
|
| 235 | 235 | |
| 236 | 236 | // Before we start, let's zero out the customer's data |
| 237 | - $donor = new Give_Donor( $this->customer_id ); |
|
| 238 | - $donor->update( array( 'purchase_value' => give_format_amount( 0, array( 'sanitize' => false ) ), 'purchase_count' => 0 ) ); |
|
| 237 | + $donor = new Give_Donor($this->customer_id); |
|
| 238 | + $donor->update(array('purchase_value' => give_format_amount(0, array('sanitize' => false)), 'purchase_count' => 0)); |
|
| 239 | 239 | |
| 240 | - $attached_payment_ids = explode( ',', $donor->payment_ids ); |
|
| 240 | + $attached_payment_ids = explode(',', $donor->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_payment_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_payment_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_donor_payments_' . $donor->id, $payments ); |
|
| 266 | + $this->store_data('give_recount_donor_payments_'.$donor->id, $payments); |
|
| 267 | 267 | } |
| 268 | 268 | } |
| 269 | 269 | |
@@ -276,17 +276,17 @@ 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 | - if ( empty( $value ) ) { |
|
| 283 | + if (empty($value)) { |
|
| 284 | 284 | return false; |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | - $maybe_json = json_decode( $value ); |
|
| 288 | - if ( ! is_null( $maybe_json ) ) { |
|
| 289 | - $value = json_decode( $value, true ); |
|
| 287 | + $maybe_json = json_decode($value); |
|
| 288 | + if ( ! is_null($maybe_json)) { |
|
| 289 | + $value = json_decode($value, true); |
|
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | return $value; |
@@ -302,10 +302,10 @@ discard block |
||
| 302 | 302 | * |
| 303 | 303 | * @return void |
| 304 | 304 | */ |
| 305 | - private function store_data( $key, $value ) { |
|
| 305 | + private function store_data($key, $value) { |
|
| 306 | 306 | global $wpdb; |
| 307 | 307 | |
| 308 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
| 308 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
| 309 | 309 | |
| 310 | 310 | $data = array( |
| 311 | 311 | 'option_name' => $key, |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | '%s', |
| 320 | 320 | ); |
| 321 | 321 | |
| 322 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
| 322 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | /** |
@@ -331,9 +331,9 @@ discard block |
||
| 331 | 331 | * |
| 332 | 332 | * @return void |
| 333 | 333 | */ |
| 334 | - private function delete_data( $key ) { |
|
| 334 | + private function delete_data($key) { |
|
| 335 | 335 | global $wpdb; |
| 336 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
| 336 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | } |
@@ -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 | |
@@ -53,19 +53,19 @@ discard block |
||
| 53 | 53 | * @return array|bool $data The data for the CSV file |
| 54 | 54 | */ |
| 55 | 55 | public function get_data() { |
| 56 | - $items = $this->get_stored_data( 'give_temp_delete_test_ids' ); |
|
| 56 | + $items = $this->get_stored_data('give_temp_delete_test_ids'); |
|
| 57 | 57 | |
| 58 | - if ( ! is_array( $items ) ) { |
|
| 58 | + if ( ! is_array($items)) { |
|
| 59 | 59 | return false; |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - $offset = ( $this->step - 1 ) * $this->per_step; |
|
| 63 | - $step_items = array_slice( $items, $offset, $this->per_step ); |
|
| 62 | + $offset = ($this->step - 1) * $this->per_step; |
|
| 63 | + $step_items = array_slice($items, $offset, $this->per_step); |
|
| 64 | 64 | |
| 65 | - if ( $step_items ) { |
|
| 66 | - foreach ( $step_items as $item ) { |
|
| 65 | + if ($step_items) { |
|
| 66 | + foreach ($step_items as $item) { |
|
| 67 | 67 | // Delete the main payment. |
| 68 | - give_delete_donation( absint( $item['id'] ) ); |
|
| 68 | + give_delete_donation(absint($item['id'])); |
|
| 69 | 69 | } |
| 70 | 70 | return true; |
| 71 | 71 | } |
@@ -81,16 +81,16 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | public function get_percentage_complete() { |
| 83 | 83 | |
| 84 | - $items = $this->get_stored_data( 'give_temp_delete_test_ids', false ); |
|
| 85 | - $total = count( $items ); |
|
| 84 | + $items = $this->get_stored_data('give_temp_delete_test_ids', false); |
|
| 85 | + $total = count($items); |
|
| 86 | 86 | |
| 87 | 87 | $percentage = 100; |
| 88 | 88 | |
| 89 | - if ( $total > 0 ) { |
|
| 90 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
| 89 | + if ($total > 0) { |
|
| 90 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - if ( $percentage > 100 ) { |
|
| 93 | + if ($percentage > 100) { |
|
| 94 | 94 | $percentage = 100; |
| 95 | 95 | } |
| 96 | 96 | |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | * |
| 105 | 105 | * @param array $request The Form Data passed into the batch processing |
| 106 | 106 | */ |
| 107 | - public function set_properties( $request ) { |
|
| 107 | + public function set_properties($request) { |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
@@ -115,29 +115,29 @@ discard block |
||
| 115 | 115 | */ |
| 116 | 116 | public function process_step() { |
| 117 | 117 | |
| 118 | - if ( ! $this->can_export() ) { |
|
| 119 | - wp_die( __( 'You do not have permission to delete test transactions.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 118 | + if ( ! $this->can_export()) { |
|
| 119 | + wp_die(__('You do not have permission to delete test transactions.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | $had_data = $this->get_data(); |
| 123 | 123 | |
| 124 | - if ( $had_data ) { |
|
| 124 | + if ($had_data) { |
|
| 125 | 125 | $this->done = false; |
| 126 | 126 | |
| 127 | 127 | return true; |
| 128 | 128 | } else { |
| 129 | - update_option( 'give_earnings_total', give_get_total_earnings( true ) ); |
|
| 130 | - Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) ); |
|
| 129 | + update_option('give_earnings_total', give_get_total_earnings(true)); |
|
| 130 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
| 131 | 131 | |
| 132 | - $this->delete_data( 'give_temp_delete_test_ids' ); |
|
| 132 | + $this->delete_data('give_temp_delete_test_ids'); |
|
| 133 | 133 | |
| 134 | 134 | // Reset the sequential order numbers |
| 135 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
| 136 | - delete_option( 'give_last_payment_number' ); |
|
| 135 | + if (give_get_option('enable_sequential')) { |
|
| 136 | + delete_option('give_last_payment_number'); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | $this->done = true; |
| 140 | - $this->message = __( 'Test transactions successfully deleted.', 'give' ); |
|
| 140 | + $this->message = __('Test transactions successfully deleted.', 'give'); |
|
| 141 | 141 | |
| 142 | 142 | return false; |
| 143 | 143 | } |
@@ -147,10 +147,10 @@ discard block |
||
| 147 | 147 | * Headers |
| 148 | 148 | */ |
| 149 | 149 | public function headers() { |
| 150 | - ignore_user_abort( true ); |
|
| 150 | + ignore_user_abort(true); |
|
| 151 | 151 | |
| 152 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 153 | - set_time_limit( 0 ); |
|
| 152 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
| 153 | + set_time_limit(0); |
|
| 154 | 154 | } |
| 155 | 155 | } |
| 156 | 156 | |
@@ -174,27 +174,27 @@ discard block |
||
| 174 | 174 | */ |
| 175 | 175 | public function pre_fetch() { |
| 176 | 176 | |
| 177 | - if ( $this->step == 1 ) { |
|
| 178 | - $this->delete_data( 'give_temp_delete_test_ids' ); |
|
| 177 | + if ($this->step == 1) { |
|
| 178 | + $this->delete_data('give_temp_delete_test_ids'); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - $items = get_option( 'give_temp_delete_test_ids', false ); |
|
| 181 | + $items = get_option('give_temp_delete_test_ids', false); |
|
| 182 | 182 | |
| 183 | - if ( false === $items ) { |
|
| 183 | + if (false === $items) { |
|
| 184 | 184 | $items = array(); |
| 185 | 185 | |
| 186 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
| 186 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
| 187 | 187 | 'post_status' => 'any', |
| 188 | - 'number' => - 1, |
|
| 188 | + 'number' => -1, |
|
| 189 | 189 | 'meta_key' => '_give_payment_mode', |
| 190 | 190 | 'meta_value' => 'test' |
| 191 | - ) ); |
|
| 191 | + )); |
|
| 192 | 192 | |
| 193 | - $posts = new Give_Payments_Query( $args ); |
|
| 193 | + $posts = new Give_Payments_Query($args); |
|
| 194 | 194 | $payments = $posts->get_payments(); |
| 195 | 195 | |
| 196 | 196 | /* @var Give_Payment $payment */ |
| 197 | - foreach ( $payments as $payment ) { |
|
| 197 | + foreach ($payments as $payment) { |
|
| 198 | 198 | $items[] = array( |
| 199 | 199 | 'id' => (int) $payment->ID, |
| 200 | 200 | 'type' => 'give_payment', |
@@ -203,9 +203,9 @@ discard block |
||
| 203 | 203 | |
| 204 | 204 | // Allow filtering of items to remove with an unassociative array for each item. |
| 205 | 205 | // The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method. |
| 206 | - $items = apply_filters( 'give_delete_test_items', $items ); |
|
| 206 | + $items = apply_filters('give_delete_test_items', $items); |
|
| 207 | 207 | |
| 208 | - $this->store_data( 'give_temp_delete_test_ids', $items ); |
|
| 208 | + $this->store_data('give_temp_delete_test_ids', $items); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | } |
@@ -219,17 +219,17 @@ discard block |
||
| 219 | 219 | * |
| 220 | 220 | * @return mixed Returns the data from the database |
| 221 | 221 | */ |
| 222 | - private function get_stored_data( $key ) { |
|
| 222 | + private function get_stored_data($key) { |
|
| 223 | 223 | global $wpdb; |
| 224 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
| 224 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
| 225 | 225 | |
| 226 | - if ( empty( $value ) ) { |
|
| 226 | + if (empty($value)) { |
|
| 227 | 227 | return false; |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | - $maybe_json = json_decode( $value ); |
|
| 231 | - if ( ! is_null( $maybe_json ) ) { |
|
| 232 | - $value = json_decode( $value, true ); |
|
| 230 | + $maybe_json = json_decode($value); |
|
| 231 | + if ( ! is_null($maybe_json)) { |
|
| 232 | + $value = json_decode($value, true); |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | return $value; |
@@ -245,10 +245,10 @@ discard block |
||
| 245 | 245 | * |
| 246 | 246 | * @return void |
| 247 | 247 | */ |
| 248 | - private function store_data( $key, $value ) { |
|
| 248 | + private function store_data($key, $value) { |
|
| 249 | 249 | global $wpdb; |
| 250 | 250 | |
| 251 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
| 251 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
| 252 | 252 | |
| 253 | 253 | $data = array( |
| 254 | 254 | 'option_name' => $key, |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | '%s', |
| 263 | 263 | ); |
| 264 | 264 | |
| 265 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
| 265 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | /** |
@@ -274,9 +274,9 @@ discard block |
||
| 274 | 274 | * |
| 275 | 275 | * @return void |
| 276 | 276 | */ |
| 277 | - private function delete_data( $key ) { |
|
| 277 | + private function delete_data($key) { |
|
| 278 | 278 | global $wpdb; |
| 279 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
| 279 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | } |
@@ -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 | |
@@ -57,32 +57,32 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | $args = array( |
| 59 | 59 | 'number' => $this->per_step, |
| 60 | - 'offset' => $this->per_step * ( $this->step - 1 ), |
|
| 60 | + 'offset' => $this->per_step * ($this->step - 1), |
|
| 61 | 61 | 'orderby' => 'id', |
| 62 | 62 | 'order' => 'DESC', |
| 63 | 63 | ); |
| 64 | 64 | |
| 65 | - $donors = Give()->donors->get_donors( $args ); |
|
| 65 | + $donors = Give()->donors->get_donors($args); |
|
| 66 | 66 | |
| 67 | - if ( $donors ) { |
|
| 67 | + if ($donors) { |
|
| 68 | 68 | |
| 69 | - $allowed_payment_status = apply_filters( 'give_recount_donors_donation_statuses', give_get_payment_status_keys() ); |
|
| 69 | + $allowed_payment_status = apply_filters('give_recount_donors_donation_statuses', give_get_payment_status_keys()); |
|
| 70 | 70 | |
| 71 | - foreach ( $donors as $donor ) { |
|
| 71 | + foreach ($donors as $donor) { |
|
| 72 | 72 | |
| 73 | - $attached_payment_ids = explode( ',', $donor->payment_ids ); |
|
| 73 | + $attached_payment_ids = explode(',', $donor->payment_ids); |
|
| 74 | 74 | |
| 75 | 75 | $attached_args = array( |
| 76 | 76 | 'post__in' => $attached_payment_ids, |
| 77 | - 'number' => - 1, |
|
| 77 | + 'number' => -1, |
|
| 78 | 78 | 'status' => $allowed_payment_status, |
| 79 | 79 | ); |
| 80 | 80 | |
| 81 | - $attached_payments = (array) give_get_payments( $attached_args ); |
|
| 81 | + $attached_payments = (array) give_get_payments($attached_args); |
|
| 82 | 82 | |
| 83 | 83 | $unattached_args = array( |
| 84 | 84 | 'post__not_in' => $attached_payment_ids, |
| 85 | - 'number' => - 1, |
|
| 85 | + 'number' => -1, |
|
| 86 | 86 | 'status' => $allowed_payment_status, |
| 87 | 87 | 'meta_query' => array( |
| 88 | 88 | array( |
@@ -93,29 +93,29 @@ discard block |
||
| 93 | 93 | ), |
| 94 | 94 | ); |
| 95 | 95 | |
| 96 | - $unattached_payments = give_get_payments( $unattached_args ); |
|
| 96 | + $unattached_payments = give_get_payments($unattached_args); |
|
| 97 | 97 | |
| 98 | - $payments = array_merge( $attached_payments, $unattached_payments ); |
|
| 98 | + $payments = array_merge($attached_payments, $unattached_payments); |
|
| 99 | 99 | |
| 100 | 100 | $purchase_value = 0.00; |
| 101 | 101 | $purchase_count = 0; |
| 102 | 102 | $payment_ids = array(); |
| 103 | 103 | |
| 104 | - if ( $payments ) { |
|
| 104 | + if ($payments) { |
|
| 105 | 105 | |
| 106 | - foreach ( $payments as $payment ) { |
|
| 106 | + foreach ($payments as $payment) { |
|
| 107 | 107 | |
| 108 | 108 | $should_process_payment = 'publish' == $payment->post_status ? true : false; |
| 109 | - $should_process_payment = apply_filters( 'give_donor_recount_should_process_donation', $should_process_payment, $payment ); |
|
| 109 | + $should_process_payment = apply_filters('give_donor_recount_should_process_donation', $should_process_payment, $payment); |
|
| 110 | 110 | |
| 111 | - if ( true === $should_process_payment ) { |
|
| 111 | + if (true === $should_process_payment) { |
|
| 112 | 112 | |
| 113 | - if ( apply_filters( 'give_donor_recount_should_increase_value', true, $payment ) ) { |
|
| 114 | - $purchase_value += give_donation_amount( $payment->ID ); |
|
| 113 | + if (apply_filters('give_donor_recount_should_increase_value', true, $payment)) { |
|
| 114 | + $purchase_value += give_donation_amount($payment->ID); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - if ( apply_filters( 'give_donor_recount_should_increase_count', true, $payment ) ) { |
|
| 118 | - $purchase_count ++; |
|
| 117 | + if (apply_filters('give_donor_recount_should_increase_count', true, $payment)) { |
|
| 118 | + $purchase_count++; |
|
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | 121 | |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | } |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - $payment_ids = implode( ',', $payment_ids ); |
|
| 126 | + $payment_ids = implode(',', $payment_ids); |
|
| 127 | 127 | |
| 128 | 128 | $donor_update_data = array( |
| 129 | 129 | 'purchase_count' => $purchase_count, |
@@ -131,8 +131,8 @@ discard block |
||
| 131 | 131 | 'payment_ids' => $payment_ids, |
| 132 | 132 | ); |
| 133 | 133 | |
| 134 | - $donor_instance = new Give_Donor( $donor->id ); |
|
| 135 | - $donor_instance->update( $donor_update_data ); |
|
| 134 | + $donor_instance = new Give_Donor($donor->id); |
|
| 135 | + $donor_instance->update($donor_update_data); |
|
| 136 | 136 | |
| 137 | 137 | }// End foreach(). |
| 138 | 138 | |
@@ -152,21 +152,21 @@ discard block |
||
| 152 | 152 | public function get_percentage_complete() { |
| 153 | 153 | |
| 154 | 154 | $args = array( |
| 155 | - 'number' => - 1, |
|
| 155 | + 'number' => -1, |
|
| 156 | 156 | 'orderby' => 'id', |
| 157 | 157 | 'order' => 'DESC', |
| 158 | 158 | ); |
| 159 | 159 | |
| 160 | - $donors = Give()->donors->get_donors( $args ); |
|
| 161 | - $total = count( $donors ); |
|
| 160 | + $donors = Give()->donors->get_donors($args); |
|
| 161 | + $total = count($donors); |
|
| 162 | 162 | |
| 163 | 163 | $percentage = 100; |
| 164 | 164 | |
| 165 | - if ( $total > 0 ) { |
|
| 166 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
| 165 | + if ($total > 0) { |
|
| 166 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - if ( $percentage > 100 ) { |
|
| 169 | + if ($percentage > 100) { |
|
| 170 | 170 | $percentage = 100; |
| 171 | 171 | } |
| 172 | 172 | |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | * |
| 181 | 181 | * @param array $request The Form Data passed into the batch processing |
| 182 | 182 | */ |
| 183 | - public function set_properties( $request ) { |
|
| 183 | + public function set_properties($request) { |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | /** |
@@ -191,21 +191,21 @@ discard block |
||
| 191 | 191 | */ |
| 192 | 192 | public function process_step() { |
| 193 | 193 | |
| 194 | - if ( ! $this->can_export() ) { |
|
| 195 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
| 194 | + if ( ! $this->can_export()) { |
|
| 195 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array( |
|
| 196 | 196 | 'response' => 403, |
| 197 | - ) ); |
|
| 197 | + )); |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | $had_data = $this->get_data(); |
| 201 | 201 | |
| 202 | - if ( $had_data ) { |
|
| 202 | + if ($had_data) { |
|
| 203 | 203 | $this->done = false; |
| 204 | 204 | |
| 205 | 205 | return true; |
| 206 | 206 | } else { |
| 207 | 207 | $this->done = true; |
| 208 | - $this->message = esc_html__( 'Donor stats have been successfully recounted.', 'give' ); |
|
| 208 | + $this->message = esc_html__('Donor stats have been successfully recounted.', 'give'); |
|
| 209 | 209 | |
| 210 | 210 | return false; |
| 211 | 211 | } |
@@ -215,10 +215,10 @@ discard block |
||
| 215 | 215 | * Headers |
| 216 | 216 | */ |
| 217 | 217 | public function headers() { |
| 218 | - ignore_user_abort( true ); |
|
| 218 | + ignore_user_abort(true); |
|
| 219 | 219 | |
| 220 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 221 | - set_time_limit( 0 ); |
|
| 220 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
| 221 | + set_time_limit(0); |
|
| 222 | 222 | } |
| 223 | 223 | } |
| 224 | 224 | |
@@ -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 | |
@@ -53,49 +53,49 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | public function get_data() { |
| 55 | 55 | |
| 56 | - if ( $this->step == 1 ) { |
|
| 57 | - $this->delete_data( 'give_temp_recount_earnings' ); |
|
| 56 | + if ($this->step == 1) { |
|
| 57 | + $this->delete_data('give_temp_recount_earnings'); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - $total = get_option( 'give_temp_recount_earnings', false ); |
|
| 60 | + $total = get_option('give_temp_recount_earnings', false); |
|
| 61 | 61 | |
| 62 | - if ( false === $total ) { |
|
| 62 | + if (false === $total) { |
|
| 63 | 63 | $total = (float) 0; |
| 64 | - $this->store_data( 'give_temp_recount_earnings', $total ); |
|
| 64 | + $this->store_data('give_temp_recount_earnings', $total); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
| 67 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
| 68 | 68 | |
| 69 | - $args = apply_filters( 'give_recount_earnings_args', array( |
|
| 69 | + $args = apply_filters('give_recount_earnings_args', array( |
|
| 70 | 70 | 'number' => $this->per_step, |
| 71 | 71 | 'page' => $this->step, |
| 72 | 72 | 'status' => $accepted_statuses, |
| 73 | 73 | 'fields' => 'ids' |
| 74 | - ) ); |
|
| 74 | + )); |
|
| 75 | 75 | |
| 76 | - $payments = give_get_payments( $args ); |
|
| 76 | + $payments = give_get_payments($args); |
|
| 77 | 77 | |
| 78 | - if ( ! empty( $payments ) ) { |
|
| 78 | + if ( ! empty($payments)) { |
|
| 79 | 79 | |
| 80 | - foreach ( $payments as $payment ) { |
|
| 80 | + foreach ($payments as $payment) { |
|
| 81 | 81 | |
| 82 | - $total += give_donation_amount( $payment ); |
|
| 82 | + $total += give_donation_amount($payment); |
|
| 83 | 83 | |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - if ( $total < 0 ) { |
|
| 86 | + if ($total < 0) { |
|
| 87 | 87 | $totals = 0; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - $total = round( $total, give_get_price_decimals() ); |
|
| 90 | + $total = round($total, give_get_price_decimals()); |
|
| 91 | 91 | |
| 92 | - $this->store_data( 'give_temp_recount_earnings', $total ); |
|
| 92 | + $this->store_data('give_temp_recount_earnings', $total); |
|
| 93 | 93 | |
| 94 | 94 | return true; |
| 95 | 95 | |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - update_option( 'give_earnings_total', $total ); |
|
| 98 | + update_option('give_earnings_total', $total); |
|
| 99 | 99 | |
| 100 | 100 | return false; |
| 101 | 101 | |
@@ -109,25 +109,25 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | public function get_percentage_complete() { |
| 111 | 111 | |
| 112 | - $total = $this->get_stored_data( 'give_recount_earnings_total' ); |
|
| 112 | + $total = $this->get_stored_data('give_recount_earnings_total'); |
|
| 113 | 113 | |
| 114 | - if ( false === $total ) { |
|
| 115 | - $args = apply_filters( 'give_recount_earnings_total_args', array() ); |
|
| 114 | + if (false === $total) { |
|
| 115 | + $args = apply_filters('give_recount_earnings_total_args', array()); |
|
| 116 | 116 | |
| 117 | - $counts = give_count_payments( $args ); |
|
| 118 | - $total = absint( $counts->publish ); |
|
| 119 | - $total = apply_filters( 'give_recount_store_earnings_total', $total ); |
|
| 117 | + $counts = give_count_payments($args); |
|
| 118 | + $total = absint($counts->publish); |
|
| 119 | + $total = apply_filters('give_recount_store_earnings_total', $total); |
|
| 120 | 120 | |
| 121 | - $this->store_data( 'give_recount_earnings_total', $total ); |
|
| 121 | + $this->store_data('give_recount_earnings_total', $total); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | $percentage = 100; |
| 125 | 125 | |
| 126 | - if ( $total > 0 ) { |
|
| 127 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
| 126 | + if ($total > 0) { |
|
| 127 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - if ( $percentage > 100 ) { |
|
| 130 | + if ($percentage > 100) { |
|
| 131 | 131 | $percentage = 100; |
| 132 | 132 | } |
| 133 | 133 | |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | * |
| 142 | 142 | * @param array $request The Form Data passed into the batch processing |
| 143 | 143 | */ |
| 144 | - public function set_properties( $request ) { |
|
| 144 | + public function set_properties($request) { |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | /** |
@@ -152,21 +152,21 @@ discard block |
||
| 152 | 152 | */ |
| 153 | 153 | public function process_step() { |
| 154 | 154 | |
| 155 | - if ( ! $this->can_export() ) { |
|
| 156 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 155 | + if ( ! $this->can_export()) { |
|
| 156 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | $had_data = $this->get_data(); |
| 160 | 160 | |
| 161 | - if ( $had_data ) { |
|
| 161 | + if ($had_data) { |
|
| 162 | 162 | $this->done = false; |
| 163 | 163 | |
| 164 | 164 | return true; |
| 165 | 165 | } else { |
| 166 | - $this->delete_data( 'give_recount_earnings_total' ); |
|
| 167 | - $this->delete_data( 'give_temp_recount_earnings' ); |
|
| 166 | + $this->delete_data('give_recount_earnings_total'); |
|
| 167 | + $this->delete_data('give_temp_recount_earnings'); |
|
| 168 | 168 | $this->done = true; |
| 169 | - $this->message = esc_html__( 'Income stats have been successfully recounted.', 'give' ); |
|
| 169 | + $this->message = esc_html__('Income stats have been successfully recounted.', 'give'); |
|
| 170 | 170 | |
| 171 | 171 | return false; |
| 172 | 172 | } |
@@ -176,10 +176,10 @@ discard block |
||
| 176 | 176 | * Headers. |
| 177 | 177 | */ |
| 178 | 178 | public function headers() { |
| 179 | - ignore_user_abort( true ); |
|
| 179 | + ignore_user_abort(true); |
|
| 180 | 180 | |
| 181 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 182 | - set_time_limit( 0 ); |
|
| 181 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
| 182 | + set_time_limit(0); |
|
| 183 | 183 | } |
| 184 | 184 | } |
| 185 | 185 | |
@@ -207,17 +207,17 @@ discard block |
||
| 207 | 207 | * |
| 208 | 208 | * @return mixed Returns the data from the database |
| 209 | 209 | */ |
| 210 | - private function get_stored_data( $key ) { |
|
| 210 | + private function get_stored_data($key) { |
|
| 211 | 211 | global $wpdb; |
| 212 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
| 212 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
| 213 | 213 | |
| 214 | - if ( empty( $value ) ) { |
|
| 214 | + if (empty($value)) { |
|
| 215 | 215 | return false; |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - $maybe_json = json_decode( $value ); |
|
| 219 | - if ( ! is_null( $maybe_json ) ) { |
|
| 220 | - $value = json_decode( $value, true ); |
|
| 218 | + $maybe_json = json_decode($value); |
|
| 219 | + if ( ! is_null($maybe_json)) { |
|
| 220 | + $value = json_decode($value, true); |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | return $value; |
@@ -233,10 +233,10 @@ discard block |
||
| 233 | 233 | * |
| 234 | 234 | * @return void |
| 235 | 235 | */ |
| 236 | - private function store_data( $key, $value ) { |
|
| 236 | + private function store_data($key, $value) { |
|
| 237 | 237 | global $wpdb; |
| 238 | 238 | |
| 239 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
| 239 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
| 240 | 240 | |
| 241 | 241 | $data = array( |
| 242 | 242 | 'option_name' => $key, |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | '%s', |
| 251 | 251 | ); |
| 252 | 252 | |
| 253 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
| 253 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | /** |
@@ -262,9 +262,9 @@ discard block |
||
| 262 | 262 | * |
| 263 | 263 | * @return void |
| 264 | 264 | */ |
| 265 | - private function delete_data( $key ) { |
|
| 265 | + private function delete_data($key) { |
|
| 266 | 266 | global $wpdb; |
| 267 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
| 267 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | } |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | // Exit if accessed directly. |
| 15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 15 | +if ( ! defined('ABSPATH')) { |
|
| 16 | 16 | exit; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -25,59 +25,59 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | function give_do_automatic_upgrades() { |
| 27 | 27 | $did_upgrade = false; |
| 28 | - $give_version = preg_replace( '/[^0-9.].*/', '', get_option( 'give_version' ) ); |
|
| 28 | + $give_version = preg_replace('/[^0-9.].*/', '', get_option('give_version')); |
|
| 29 | 29 | |
| 30 | - if ( ! $give_version ) { |
|
| 30 | + if ( ! $give_version) { |
|
| 31 | 31 | // 1.0 is the first version to use this option so we must add it. |
| 32 | 32 | $give_version = '1.0'; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - switch ( true ) { |
|
| 35 | + switch (true) { |
|
| 36 | 36 | |
| 37 | - case version_compare( $give_version, '1.6', '<' ) : |
|
| 37 | + case version_compare($give_version, '1.6', '<') : |
|
| 38 | 38 | give_v16_upgrades(); |
| 39 | 39 | $did_upgrade = true; |
| 40 | 40 | |
| 41 | - case version_compare( $give_version, '1.7', '<' ) : |
|
| 41 | + case version_compare($give_version, '1.7', '<') : |
|
| 42 | 42 | give_v17_upgrades(); |
| 43 | 43 | $did_upgrade = true; |
| 44 | 44 | |
| 45 | - case version_compare( $give_version, '1.8', '<' ) : |
|
| 45 | + case version_compare($give_version, '1.8', '<') : |
|
| 46 | 46 | give_v18_upgrades(); |
| 47 | 47 | $did_upgrade = true; |
| 48 | 48 | |
| 49 | - case version_compare( $give_version, '1.8.7', '<' ) : |
|
| 49 | + case version_compare($give_version, '1.8.7', '<') : |
|
| 50 | 50 | give_v187_upgrades(); |
| 51 | 51 | $did_upgrade = true; |
| 52 | 52 | |
| 53 | - case version_compare( $give_version, '1.8.8', '<' ) : |
|
| 53 | + case version_compare($give_version, '1.8.8', '<') : |
|
| 54 | 54 | give_v188_upgrades(); |
| 55 | 55 | $did_upgrade = true; |
| 56 | 56 | |
| 57 | - case version_compare( $give_version, '1.8.9', '<' ) : |
|
| 57 | + case version_compare($give_version, '1.8.9', '<') : |
|
| 58 | 58 | give_v189_upgrades(); |
| 59 | 59 | $did_upgrade = true; |
| 60 | 60 | |
| 61 | - case version_compare( $give_version, '1.8.12', '<' ) : |
|
| 61 | + case version_compare($give_version, '1.8.12', '<') : |
|
| 62 | 62 | give_v1812_upgrades(); |
| 63 | 63 | $did_upgrade = true; |
| 64 | 64 | |
| 65 | - case version_compare( $give_version, '1.8.13', '<' ) : |
|
| 65 | + case version_compare($give_version, '1.8.13', '<') : |
|
| 66 | 66 | give_v1813_upgrades(); |
| 67 | 67 | $did_upgrade = true; |
| 68 | 68 | |
| 69 | - case version_compare( $give_version, '1.8.17', '<' ) : |
|
| 69 | + case version_compare($give_version, '1.8.17', '<') : |
|
| 70 | 70 | give_v1817_upgrades(); |
| 71 | 71 | $did_upgrade = true; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - if ( $did_upgrade ) { |
|
| 75 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
| 74 | + if ($did_upgrade) { |
|
| 75 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | -add_action( 'admin_init', 'give_do_automatic_upgrades' ); |
|
| 80 | -add_action( 'give_upgrades', 'give_do_automatic_upgrades' ); |
|
| 79 | +add_action('admin_init', 'give_do_automatic_upgrades'); |
|
| 80 | +add_action('give_upgrades', 'give_do_automatic_upgrades'); |
|
| 81 | 81 | |
| 82 | 82 | /** |
| 83 | 83 | * Display Upgrade Notices |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | * |
| 90 | 90 | * @return void |
| 91 | 91 | */ |
| 92 | -function give_show_upgrade_notices( $give_updates ) { |
|
| 92 | +function give_show_upgrade_notices($give_updates) { |
|
| 93 | 93 | // v1.3.2 Upgrades |
| 94 | 94 | $give_updates->register( |
| 95 | 95 | array( |
@@ -155,21 +155,21 @@ discard block |
||
| 155 | 155 | ); |
| 156 | 156 | |
| 157 | 157 | // v1.8.17 Upgrades for donations. |
| 158 | - $give_updates->register( array( |
|
| 158 | + $give_updates->register(array( |
|
| 159 | 159 | 'id' => 'v1817_update_donation_iranian_currency_code', |
| 160 | 160 | 'version' => '1.8.17', |
| 161 | 161 | 'callback' => 'give_v1817_update_donation_iranian_currency_code', |
| 162 | - ) ); |
|
| 162 | + )); |
|
| 163 | 163 | |
| 164 | 164 | // v1.8.17 Upgrades for cleanup of user roles. |
| 165 | - $give_updates->register( array( |
|
| 165 | + $give_updates->register(array( |
|
| 166 | 166 | 'id' => 'v1817_cleanup_user_roles', |
| 167 | 167 | 'version' => '1.8.17', |
| 168 | 168 | 'callback' => 'give_v1817_cleanup_user_roles', |
| 169 | - ) ); |
|
| 169 | + )); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | -add_action( 'give_register_updates', 'give_show_upgrade_notices' ); |
|
| 172 | +add_action('give_register_updates', 'give_show_upgrade_notices'); |
|
| 173 | 173 | |
| 174 | 174 | /** |
| 175 | 175 | * Triggers all upgrade functions |
@@ -181,29 +181,29 @@ discard block |
||
| 181 | 181 | */ |
| 182 | 182 | function give_trigger_upgrades() { |
| 183 | 183 | |
| 184 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
| 185 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
| 184 | + if ( ! current_user_can('manage_give_settings')) { |
|
| 185 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
| 186 | 186 | 'response' => 403, |
| 187 | - ) ); |
|
| 187 | + )); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - $give_version = get_option( 'give_version' ); |
|
| 190 | + $give_version = get_option('give_version'); |
|
| 191 | 191 | |
| 192 | - if ( ! $give_version ) { |
|
| 192 | + if ( ! $give_version) { |
|
| 193 | 193 | // 1.0 is the first version to use this option so we must add it. |
| 194 | 194 | $give_version = '1.0'; |
| 195 | - add_option( 'give_version', $give_version ); |
|
| 195 | + add_option('give_version', $give_version); |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - update_option( 'give_version', GIVE_VERSION ); |
|
| 199 | - delete_option( 'give_doing_upgrade' ); |
|
| 198 | + update_option('give_version', GIVE_VERSION); |
|
| 199 | + delete_option('give_doing_upgrade'); |
|
| 200 | 200 | |
| 201 | - if ( DOING_AJAX ) { |
|
| 202 | - die( 'complete' ); |
|
| 201 | + if (DOING_AJAX) { |
|
| 202 | + die('complete'); |
|
| 203 | 203 | } // End if(). |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | -add_action( 'wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades' ); |
|
| 206 | +add_action('wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades'); |
|
| 207 | 207 | |
| 208 | 208 | |
| 209 | 209 | /** |
@@ -219,24 +219,24 @@ discard block |
||
| 219 | 219 | /* @var Give_Updates $give_updates */ |
| 220 | 220 | $give_updates = Give_Updates::get_instance(); |
| 221 | 221 | |
| 222 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
| 223 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
| 222 | + if ( ! current_user_can('manage_give_settings')) { |
|
| 223 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
| 224 | 224 | 'response' => 403, |
| 225 | - ) ); |
|
| 225 | + )); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - ignore_user_abort( true ); |
|
| 228 | + ignore_user_abort(true); |
|
| 229 | 229 | |
| 230 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 231 | - @set_time_limit( 0 ); |
|
| 230 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
| 231 | + @set_time_limit(0); |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | // UPDATE DB METAKEYS. |
| 235 | 235 | $sql = "UPDATE $wpdb->postmeta SET meta_key = '_give_payment_customer_id' WHERE meta_key = '_give_payment_donor_id'"; |
| 236 | - $query = $wpdb->query( $sql ); |
|
| 236 | + $query = $wpdb->query($sql); |
|
| 237 | 237 | |
| 238 | 238 | $give_updates->percentage = 100; |
| 239 | - give_set_upgrade_complete( 'upgrade_give_payment_customer_id' ); |
|
| 239 | + give_set_upgrade_complete('upgrade_give_payment_customer_id'); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | |
@@ -260,24 +260,24 @@ discard block |
||
| 260 | 260 | $where .= "AND ( p.post_status = 'abandoned' )"; |
| 261 | 261 | $where .= "AND ( m.meta_key = '_give_payment_gateway' AND m.meta_value = 'offline' )"; |
| 262 | 262 | |
| 263 | - $sql = $select . $join . $where; |
|
| 264 | - $found_payments = $wpdb->get_col( $sql ); |
|
| 263 | + $sql = $select.$join.$where; |
|
| 264 | + $found_payments = $wpdb->get_col($sql); |
|
| 265 | 265 | |
| 266 | - foreach ( $found_payments as $payment ) { |
|
| 266 | + foreach ($found_payments as $payment) { |
|
| 267 | 267 | |
| 268 | 268 | // Only change ones marked abandoned since our release last week because the admin may have marked some abandoned themselves. |
| 269 | - $modified_time = get_post_modified_time( 'U', false, $payment ); |
|
| 269 | + $modified_time = get_post_modified_time('U', false, $payment); |
|
| 270 | 270 | |
| 271 | 271 | // 1450124863 = 12/10/2015 20:42:25. |
| 272 | - if ( $modified_time >= 1450124863 ) { |
|
| 272 | + if ($modified_time >= 1450124863) { |
|
| 273 | 273 | |
| 274 | - give_update_payment_status( $payment, 'pending' ); |
|
| 274 | + give_update_payment_status($payment, 'pending'); |
|
| 275 | 275 | |
| 276 | 276 | } |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | $give_updates->percentage = 100; |
| 280 | - give_set_upgrade_complete( 'upgrade_give_offline_status' ); |
|
| 280 | + give_set_upgrade_complete('upgrade_give_offline_status'); |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | |
@@ -290,17 +290,17 @@ discard block |
||
| 290 | 290 | */ |
| 291 | 291 | function give_v152_cleanup_users() { |
| 292 | 292 | |
| 293 | - $give_version = get_option( 'give_version' ); |
|
| 293 | + $give_version = get_option('give_version'); |
|
| 294 | 294 | |
| 295 | - if ( ! $give_version ) { |
|
| 295 | + if ( ! $give_version) { |
|
| 296 | 296 | // 1.0 is the first version to use this option so we must add it. |
| 297 | 297 | $give_version = '1.0'; |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | - $give_version = preg_replace( '/[^0-9.].*/', '', $give_version ); |
|
| 300 | + $give_version = preg_replace('/[^0-9.].*/', '', $give_version); |
|
| 301 | 301 | |
| 302 | 302 | // v1.5.2 Upgrades |
| 303 | - if ( version_compare( $give_version, '1.5.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_user_caps_cleanup' ) ) { |
|
| 303 | + if (version_compare($give_version, '1.5.2', '<') || ! give_has_upgrade_completed('upgrade_give_user_caps_cleanup')) { |
|
| 304 | 304 | |
| 305 | 305 | // Delete all caps with "ss". |
| 306 | 306 | // Also delete all unused "campaign" roles. |
@@ -347,9 +347,9 @@ discard block |
||
| 347 | 347 | ); |
| 348 | 348 | |
| 349 | 349 | global $wp_roles; |
| 350 | - foreach ( $delete_caps as $cap ) { |
|
| 351 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
| 352 | - $wp_roles->remove_cap( $role, $cap ); |
|
| 350 | + foreach ($delete_caps as $cap) { |
|
| 351 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
| 352 | + $wp_roles->remove_cap($role, $cap); |
|
| 353 | 353 | } |
| 354 | 354 | } |
| 355 | 355 | |
@@ -359,15 +359,15 @@ discard block |
||
| 359 | 359 | $roles->add_caps(); |
| 360 | 360 | |
| 361 | 361 | // The Update Ran. |
| 362 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
| 363 | - give_set_upgrade_complete( 'upgrade_give_user_caps_cleanup' ); |
|
| 364 | - delete_option( 'give_doing_upgrade' ); |
|
| 362 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
| 363 | + give_set_upgrade_complete('upgrade_give_user_caps_cleanup'); |
|
| 364 | + delete_option('give_doing_upgrade'); |
|
| 365 | 365 | |
| 366 | 366 | }// End if(). |
| 367 | 367 | |
| 368 | 368 | } |
| 369 | 369 | |
| 370 | -add_action( 'admin_init', 'give_v152_cleanup_users' ); |
|
| 370 | +add_action('admin_init', 'give_v152_cleanup_users'); |
|
| 371 | 371 | |
| 372 | 372 | /** |
| 373 | 373 | * 1.6 Upgrade routine to create the customer meta table. |
@@ -410,53 +410,53 @@ discard block |
||
| 410 | 410 | |
| 411 | 411 | // Get addons license key. |
| 412 | 412 | $addons = array(); |
| 413 | - foreach ( $give_options as $key => $value ) { |
|
| 414 | - if ( false !== strpos( $key, '_license_key' ) ) { |
|
| 415 | - $addons[ $key ] = $value; |
|
| 413 | + foreach ($give_options as $key => $value) { |
|
| 414 | + if (false !== strpos($key, '_license_key')) { |
|
| 415 | + $addons[$key] = $value; |
|
| 416 | 416 | } |
| 417 | 417 | } |
| 418 | 418 | |
| 419 | 419 | // Bailout: We do not have any addon license data to upgrade. |
| 420 | - if ( empty( $addons ) ) { |
|
| 420 | + if (empty($addons)) { |
|
| 421 | 421 | return false; |
| 422 | 422 | } |
| 423 | 423 | |
| 424 | - foreach ( $addons as $key => $addon_license ) { |
|
| 424 | + foreach ($addons as $key => $addon_license) { |
|
| 425 | 425 | |
| 426 | 426 | // Get addon shortname. |
| 427 | - $shortname = str_replace( '_license_key', '', $key ); |
|
| 427 | + $shortname = str_replace('_license_key', '', $key); |
|
| 428 | 428 | |
| 429 | 429 | // Addon license option name. |
| 430 | - $addon_license_option_name = $shortname . '_license_active'; |
|
| 430 | + $addon_license_option_name = $shortname.'_license_active'; |
|
| 431 | 431 | |
| 432 | 432 | // bailout if license is empty. |
| 433 | - if ( empty( $addon_license ) ) { |
|
| 434 | - delete_option( $addon_license_option_name ); |
|
| 433 | + if (empty($addon_license)) { |
|
| 434 | + delete_option($addon_license_option_name); |
|
| 435 | 435 | continue; |
| 436 | 436 | } |
| 437 | 437 | |
| 438 | 438 | // Get addon name. |
| 439 | 439 | $addon_name = array(); |
| 440 | - $addon_name_parts = explode( '_', str_replace( 'give_', '', $shortname ) ); |
|
| 441 | - foreach ( $addon_name_parts as $name_part ) { |
|
| 440 | + $addon_name_parts = explode('_', str_replace('give_', '', $shortname)); |
|
| 441 | + foreach ($addon_name_parts as $name_part) { |
|
| 442 | 442 | |
| 443 | 443 | // Fix addon name |
| 444 | - switch ( $name_part ) { |
|
| 444 | + switch ($name_part) { |
|
| 445 | 445 | case 'authorizenet' : |
| 446 | 446 | $name_part = 'authorize.net'; |
| 447 | 447 | break; |
| 448 | 448 | } |
| 449 | 449 | |
| 450 | - $addon_name[] = ucfirst( $name_part ); |
|
| 450 | + $addon_name[] = ucfirst($name_part); |
|
| 451 | 451 | } |
| 452 | 452 | |
| 453 | - $addon_name = implode( ' ', $addon_name ); |
|
| 453 | + $addon_name = implode(' ', $addon_name); |
|
| 454 | 454 | |
| 455 | 455 | // Data to send to the API. |
| 456 | 456 | $api_params = array( |
| 457 | 457 | 'edd_action' => 'activate_license', // never change from "edd_" to "give_"! |
| 458 | 458 | 'license' => $addon_license, |
| 459 | - 'item_name' => urlencode( $addon_name ), |
|
| 459 | + 'item_name' => urlencode($addon_name), |
|
| 460 | 460 | 'url' => home_url(), |
| 461 | 461 | ); |
| 462 | 462 | |
@@ -471,17 +471,17 @@ discard block |
||
| 471 | 471 | ); |
| 472 | 472 | |
| 473 | 473 | // Make sure there are no errors. |
| 474 | - if ( is_wp_error( $response ) ) { |
|
| 475 | - delete_option( $addon_license_option_name ); |
|
| 474 | + if (is_wp_error($response)) { |
|
| 475 | + delete_option($addon_license_option_name); |
|
| 476 | 476 | continue; |
| 477 | 477 | } |
| 478 | 478 | |
| 479 | 479 | // Tell WordPress to look for updates. |
| 480 | - set_site_transient( 'update_plugins', null ); |
|
| 480 | + set_site_transient('update_plugins', null); |
|
| 481 | 481 | |
| 482 | 482 | // Decode license data. |
| 483 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
| 484 | - update_option( $addon_license_option_name, $license_data ); |
|
| 483 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
| 484 | + update_option($addon_license_option_name, $license_data); |
|
| 485 | 485 | }// End foreach(). |
| 486 | 486 | } |
| 487 | 487 | |
@@ -511,9 +511,9 @@ discard block |
||
| 511 | 511 | ); |
| 512 | 512 | |
| 513 | 513 | global $wp_roles; |
| 514 | - foreach ( $delete_caps as $cap ) { |
|
| 515 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
| 516 | - $wp_roles->remove_cap( $role, $cap ); |
|
| 514 | + foreach ($delete_caps as $cap) { |
|
| 515 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
| 516 | + $wp_roles->remove_cap($role, $cap); |
|
| 517 | 517 | } |
| 518 | 518 | } |
| 519 | 519 | |
@@ -547,7 +547,7 @@ discard block |
||
| 547 | 547 | function give_v18_upgrades_core_setting() { |
| 548 | 548 | // Core settings which changes from checkbox to radio. |
| 549 | 549 | $core_setting_names = array_merge( |
| 550 | - array_keys( give_v18_renamed_core_settings() ), |
|
| 550 | + array_keys(give_v18_renamed_core_settings()), |
|
| 551 | 551 | array( |
| 552 | 552 | 'uninstall_on_delete', |
| 553 | 553 | 'scripts_footer', |
@@ -559,48 +559,48 @@ discard block |
||
| 559 | 559 | ); |
| 560 | 560 | |
| 561 | 561 | // Bailout: If not any setting define. |
| 562 | - if ( $give_settings = get_option( 'give_settings' ) ) { |
|
| 562 | + if ($give_settings = get_option('give_settings')) { |
|
| 563 | 563 | |
| 564 | 564 | $setting_changed = false; |
| 565 | 565 | |
| 566 | 566 | // Loop: check each setting field. |
| 567 | - foreach ( $core_setting_names as $setting_name ) { |
|
| 567 | + foreach ($core_setting_names as $setting_name) { |
|
| 568 | 568 | // New setting name. |
| 569 | - $new_setting_name = preg_replace( '/^(enable_|disable_)/', '', $setting_name ); |
|
| 569 | + $new_setting_name = preg_replace('/^(enable_|disable_)/', '', $setting_name); |
|
| 570 | 570 | |
| 571 | 571 | // Continue: If setting already set. |
| 572 | 572 | if ( |
| 573 | - array_key_exists( $new_setting_name, $give_settings ) |
|
| 574 | - && in_array( $give_settings[ $new_setting_name ], array( 'enabled', 'disabled' ) ) |
|
| 573 | + array_key_exists($new_setting_name, $give_settings) |
|
| 574 | + && in_array($give_settings[$new_setting_name], array('enabled', 'disabled')) |
|
| 575 | 575 | ) { |
| 576 | 576 | continue; |
| 577 | 577 | } |
| 578 | 578 | |
| 579 | 579 | // Set checkbox value to radio value. |
| 580 | - $give_settings[ $setting_name ] = ( ! empty( $give_settings[ $setting_name ] ) && 'on' === $give_settings[ $setting_name ] ? 'enabled' : 'disabled' ); |
|
| 580 | + $give_settings[$setting_name] = ( ! empty($give_settings[$setting_name]) && 'on' === $give_settings[$setting_name] ? 'enabled' : 'disabled'); |
|
| 581 | 581 | |
| 582 | 582 | // @see https://github.com/WordImpress/Give/issues/1063. |
| 583 | - if ( false !== strpos( $setting_name, 'disable_' ) ) { |
|
| 583 | + if (false !== strpos($setting_name, 'disable_')) { |
|
| 584 | 584 | |
| 585 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'disabled' : 'enabled' ); |
|
| 586 | - } elseif ( false !== strpos( $setting_name, 'enable_' ) ) { |
|
| 585 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'disabled' : 'enabled'); |
|
| 586 | + } elseif (false !== strpos($setting_name, 'enable_')) { |
|
| 587 | 587 | |
| 588 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'enabled' : 'disabled' ); |
|
| 588 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'enabled' : 'disabled'); |
|
| 589 | 589 | } |
| 590 | 590 | |
| 591 | 591 | // Tell bot to update core setting to db. |
| 592 | - if ( ! $setting_changed ) { |
|
| 592 | + if ( ! $setting_changed) { |
|
| 593 | 593 | $setting_changed = true; |
| 594 | 594 | } |
| 595 | 595 | } |
| 596 | 596 | |
| 597 | 597 | // Update setting only if they changed. |
| 598 | - if ( $setting_changed ) { |
|
| 599 | - update_option( 'give_settings', $give_settings ); |
|
| 598 | + if ($setting_changed) { |
|
| 599 | + update_option('give_settings', $give_settings); |
|
| 600 | 600 | } |
| 601 | 601 | }// End if(). |
| 602 | 602 | |
| 603 | - give_set_upgrade_complete( 'v18_upgrades_core_setting' ); |
|
| 603 | + give_set_upgrade_complete('v18_upgrades_core_setting'); |
|
| 604 | 604 | } |
| 605 | 605 | |
| 606 | 606 | /** |
@@ -614,7 +614,7 @@ discard block |
||
| 614 | 614 | $give_updates = Give_Updates::get_instance(); |
| 615 | 615 | |
| 616 | 616 | // form query |
| 617 | - $forms = new WP_Query( array( |
|
| 617 | + $forms = new WP_Query(array( |
|
| 618 | 618 | 'paged' => $give_updates->step, |
| 619 | 619 | 'status' => 'any', |
| 620 | 620 | 'order' => 'ASC', |
@@ -623,41 +623,41 @@ discard block |
||
| 623 | 623 | ) |
| 624 | 624 | ); |
| 625 | 625 | |
| 626 | - if ( $forms->have_posts() ) { |
|
| 627 | - $give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 20 ) ); |
|
| 626 | + if ($forms->have_posts()) { |
|
| 627 | + $give_updates->set_percentage($forms->found_posts, ($give_updates->step * 20)); |
|
| 628 | 628 | |
| 629 | - while ( $forms->have_posts() ) { |
|
| 629 | + while ($forms->have_posts()) { |
|
| 630 | 630 | $forms->the_post(); |
| 631 | 631 | |
| 632 | 632 | // Form content. |
| 633 | 633 | // Note in version 1.8 display content setting split into display content and content placement setting. |
| 634 | 634 | // You can delete _give_content_option in future. |
| 635 | - $show_content = give_get_meta( get_the_ID(), '_give_content_option', true ); |
|
| 636 | - if ( $show_content && ! give_get_meta( get_the_ID(), '_give_display_content', true ) ) { |
|
| 637 | - $field_value = ( 'none' !== $show_content ? 'enabled' : 'disabled' ); |
|
| 638 | - give_update_meta( get_the_ID(), '_give_display_content', $field_value ); |
|
| 635 | + $show_content = give_get_meta(get_the_ID(), '_give_content_option', true); |
|
| 636 | + if ($show_content && ! give_get_meta(get_the_ID(), '_give_display_content', true)) { |
|
| 637 | + $field_value = ('none' !== $show_content ? 'enabled' : 'disabled'); |
|
| 638 | + give_update_meta(get_the_ID(), '_give_display_content', $field_value); |
|
| 639 | 639 | |
| 640 | - $field_value = ( 'none' !== $show_content ? $show_content : 'give_pre_form' ); |
|
| 641 | - give_update_meta( get_the_ID(), '_give_content_placement', $field_value ); |
|
| 640 | + $field_value = ('none' !== $show_content ? $show_content : 'give_pre_form'); |
|
| 641 | + give_update_meta(get_the_ID(), '_give_content_placement', $field_value); |
|
| 642 | 642 | } |
| 643 | 643 | |
| 644 | 644 | // "Disable" Guest Donation. Checkbox. |
| 645 | 645 | // See: https://github.com/WordImpress/Give/issues/1470. |
| 646 | - $guest_donation = give_get_meta( get_the_ID(), '_give_logged_in_only', true ); |
|
| 647 | - $guest_donation_newval = ( in_array( $guest_donation, array( 'yes', 'on' ) ) ? 'disabled' : 'enabled' ); |
|
| 648 | - give_update_meta( get_the_ID(), '_give_logged_in_only', $guest_donation_newval ); |
|
| 646 | + $guest_donation = give_get_meta(get_the_ID(), '_give_logged_in_only', true); |
|
| 647 | + $guest_donation_newval = (in_array($guest_donation, array('yes', 'on')) ? 'disabled' : 'enabled'); |
|
| 648 | + give_update_meta(get_the_ID(), '_give_logged_in_only', $guest_donation_newval); |
|
| 649 | 649 | |
| 650 | 650 | // Offline Donations. |
| 651 | 651 | // See: https://github.com/WordImpress/Give/issues/1579. |
| 652 | - $offline_donation = give_get_meta( get_the_ID(), '_give_customize_offline_donations', true ); |
|
| 653 | - if ( 'no' === $offline_donation ) { |
|
| 652 | + $offline_donation = give_get_meta(get_the_ID(), '_give_customize_offline_donations', true); |
|
| 653 | + if ('no' === $offline_donation) { |
|
| 654 | 654 | $offline_donation_newval = 'global'; |
| 655 | - } elseif ( 'yes' === $offline_donation ) { |
|
| 655 | + } elseif ('yes' === $offline_donation) { |
|
| 656 | 656 | $offline_donation_newval = 'enabled'; |
| 657 | 657 | } else { |
| 658 | 658 | $offline_donation_newval = 'disabled'; |
| 659 | 659 | } |
| 660 | - give_update_meta( get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval ); |
|
| 660 | + give_update_meta(get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval); |
|
| 661 | 661 | |
| 662 | 662 | // Convert yes/no setting field to enabled/disabled. |
| 663 | 663 | $form_radio_settings = array( |
@@ -677,15 +677,15 @@ discard block |
||
| 677 | 677 | '_give_offline_donation_enable_billing_fields_single', |
| 678 | 678 | ); |
| 679 | 679 | |
| 680 | - foreach ( $form_radio_settings as $meta_key ) { |
|
| 680 | + foreach ($form_radio_settings as $meta_key) { |
|
| 681 | 681 | // Get value. |
| 682 | - $field_value = give_get_meta( get_the_ID(), $meta_key, true ); |
|
| 682 | + $field_value = give_get_meta(get_the_ID(), $meta_key, true); |
|
| 683 | 683 | |
| 684 | 684 | // Convert meta value only if it is in yes/no/none. |
| 685 | - if ( in_array( $field_value, array( 'yes', 'on', 'no', 'none' ) ) ) { |
|
| 685 | + if (in_array($field_value, array('yes', 'on', 'no', 'none'))) { |
|
| 686 | 686 | |
| 687 | - $field_value = ( in_array( $field_value, array( 'yes', 'on' ) ) ? 'enabled' : 'disabled' ); |
|
| 688 | - give_update_meta( get_the_ID(), $meta_key, $field_value ); |
|
| 687 | + $field_value = (in_array($field_value, array('yes', 'on')) ? 'enabled' : 'disabled'); |
|
| 688 | + give_update_meta(get_the_ID(), $meta_key, $field_value); |
|
| 689 | 689 | } |
| 690 | 690 | } |
| 691 | 691 | }// End while(). |
@@ -694,7 +694,7 @@ discard block |
||
| 694 | 694 | |
| 695 | 695 | } else { |
| 696 | 696 | // No more forms found, finish up. |
| 697 | - give_set_upgrade_complete( 'v18_upgrades_form_metadata' ); |
|
| 697 | + give_set_upgrade_complete('v18_upgrades_form_metadata'); |
|
| 698 | 698 | } |
| 699 | 699 | } |
| 700 | 700 | |
@@ -761,7 +761,7 @@ discard block |
||
| 761 | 761 | '%_transient_give_stats_%', |
| 762 | 762 | 'give_cache%', |
| 763 | 763 | '%_transient_give_add_ons_feed%', |
| 764 | - '%_transient__give_ajax_works' . |
|
| 764 | + '%_transient__give_ajax_works'. |
|
| 765 | 765 | '%_transient_give_total_api_keys%', |
| 766 | 766 | '%_transient_give_i18n_give_promo_hide%', |
| 767 | 767 | '%_transient_give_contributors%', |
@@ -788,24 +788,24 @@ discard block |
||
| 788 | 788 | ARRAY_A |
| 789 | 789 | ); |
| 790 | 790 | |
| 791 | - if ( ! empty( $user_apikey_options ) ) { |
|
| 792 | - foreach ( $user_apikey_options as $user ) { |
|
| 793 | - $cached_options[] = '_transient_' . md5( 'give_api_user_' . $user['meta_key'] ); |
|
| 794 | - $cached_options[] = '_transient_' . md5( 'give_api_user_public_key' . $user['user_id'] ); |
|
| 795 | - $cached_options[] = '_transient_' . md5( 'give_api_user_secret_key' . $user['user_id'] ); |
|
| 791 | + if ( ! empty($user_apikey_options)) { |
|
| 792 | + foreach ($user_apikey_options as $user) { |
|
| 793 | + $cached_options[] = '_transient_'.md5('give_api_user_'.$user['meta_key']); |
|
| 794 | + $cached_options[] = '_transient_'.md5('give_api_user_public_key'.$user['user_id']); |
|
| 795 | + $cached_options[] = '_transient_'.md5('give_api_user_secret_key'.$user['user_id']); |
|
| 796 | 796 | } |
| 797 | 797 | } |
| 798 | 798 | |
| 799 | - if ( ! empty( $cached_options ) ) { |
|
| 800 | - foreach ( $cached_options as $option ) { |
|
| 801 | - switch ( true ) { |
|
| 802 | - case ( false !== strpos( $option, 'transient' ) ): |
|
| 803 | - $option = str_replace( '_transient_', '', $option ); |
|
| 804 | - delete_transient( $option ); |
|
| 799 | + if ( ! empty($cached_options)) { |
|
| 800 | + foreach ($cached_options as $option) { |
|
| 801 | + switch (true) { |
|
| 802 | + case (false !== strpos($option, 'transient')): |
|
| 803 | + $option = str_replace('_transient_', '', $option); |
|
| 804 | + delete_transient($option); |
|
| 805 | 805 | break; |
| 806 | 806 | |
| 807 | 807 | default: |
| 808 | - delete_option( $option ); |
|
| 808 | + delete_option($option); |
|
| 809 | 809 | } |
| 810 | 810 | } |
| 811 | 811 | } |
@@ -823,7 +823,7 @@ discard block |
||
| 823 | 823 | global $wp_roles; |
| 824 | 824 | |
| 825 | 825 | // Get the role object. |
| 826 | - $give_worker = get_role( 'give_worker' ); |
|
| 826 | + $give_worker = get_role('give_worker'); |
|
| 827 | 827 | |
| 828 | 828 | // A list of capabilities to add for give workers. |
| 829 | 829 | $caps_to_add = array( |
@@ -831,9 +831,9 @@ discard block |
||
| 831 | 831 | 'edit_pages', |
| 832 | 832 | ); |
| 833 | 833 | |
| 834 | - foreach ( $caps_to_add as $cap ) { |
|
| 834 | + foreach ($caps_to_add as $cap) { |
|
| 835 | 835 | // Add the capability. |
| 836 | - $give_worker->add_cap( $cap ); |
|
| 836 | + $give_worker->add_cap($cap); |
|
| 837 | 837 | } |
| 838 | 838 | |
| 839 | 839 | } |
@@ -850,7 +850,7 @@ discard block |
||
| 850 | 850 | $give_updates = Give_Updates::get_instance(); |
| 851 | 851 | |
| 852 | 852 | // form query. |
| 853 | - $donation_forms = new WP_Query( array( |
|
| 853 | + $donation_forms = new WP_Query(array( |
|
| 854 | 854 | 'paged' => $give_updates->step, |
| 855 | 855 | 'status' => 'any', |
| 856 | 856 | 'order' => 'ASC', |
@@ -859,10 +859,10 @@ discard block |
||
| 859 | 859 | ) |
| 860 | 860 | ); |
| 861 | 861 | |
| 862 | - if ( $donation_forms->have_posts() ) { |
|
| 863 | - $give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) ); |
|
| 862 | + if ($donation_forms->have_posts()) { |
|
| 863 | + $give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20)); |
|
| 864 | 864 | |
| 865 | - while ( $donation_forms->have_posts() ) { |
|
| 865 | + while ($donation_forms->have_posts()) { |
|
| 866 | 866 | $donation_forms->the_post(); |
| 867 | 867 | $form_id = get_the_ID(); |
| 868 | 868 | |
@@ -870,41 +870,41 @@ discard block |
||
| 870 | 870 | update_post_meta( |
| 871 | 871 | $form_id, |
| 872 | 872 | '_give_set_price', |
| 873 | - give_sanitize_amount( get_post_meta( $form_id, '_give_set_price', true ) ) |
|
| 873 | + give_sanitize_amount(get_post_meta($form_id, '_give_set_price', true)) |
|
| 874 | 874 | ); |
| 875 | 875 | |
| 876 | 876 | // Remove formatting from _give_custom_amount_minimum. |
| 877 | 877 | update_post_meta( |
| 878 | 878 | $form_id, |
| 879 | 879 | '_give_custom_amount_minimum', |
| 880 | - give_sanitize_amount( get_post_meta( $form_id, '_give_custom_amount_minimum', true ) ) |
|
| 880 | + give_sanitize_amount(get_post_meta($form_id, '_give_custom_amount_minimum', true)) |
|
| 881 | 881 | ); |
| 882 | 882 | |
| 883 | 883 | // Bailout. |
| 884 | - if ( 'set' === get_post_meta( $form_id, '_give_price_option', true ) ) { |
|
| 884 | + if ('set' === get_post_meta($form_id, '_give_price_option', true)) { |
|
| 885 | 885 | continue; |
| 886 | 886 | } |
| 887 | 887 | |
| 888 | - $donation_levels = get_post_meta( $form_id, '_give_donation_levels', true ); |
|
| 888 | + $donation_levels = get_post_meta($form_id, '_give_donation_levels', true); |
|
| 889 | 889 | |
| 890 | - if ( ! empty( $donation_levels ) ) { |
|
| 890 | + if ( ! empty($donation_levels)) { |
|
| 891 | 891 | |
| 892 | - foreach ( $donation_levels as $index => $donation_level ) { |
|
| 893 | - if ( isset( $donation_level['_give_amount'] ) ) { |
|
| 894 | - $donation_levels[ $index ]['_give_amount'] = give_sanitize_amount( $donation_level['_give_amount'] ); |
|
| 892 | + foreach ($donation_levels as $index => $donation_level) { |
|
| 893 | + if (isset($donation_level['_give_amount'])) { |
|
| 894 | + $donation_levels[$index]['_give_amount'] = give_sanitize_amount($donation_level['_give_amount']); |
|
| 895 | 895 | } |
| 896 | 896 | } |
| 897 | 897 | |
| 898 | - update_post_meta( $form_id, '_give_donation_levels', $donation_levels ); |
|
| 898 | + update_post_meta($form_id, '_give_donation_levels', $donation_levels); |
|
| 899 | 899 | |
| 900 | - $donation_levels_amounts = wp_list_pluck( $donation_levels, '_give_amount' ); |
|
| 900 | + $donation_levels_amounts = wp_list_pluck($donation_levels, '_give_amount'); |
|
| 901 | 901 | |
| 902 | - $min_amount = min( $donation_levels_amounts ); |
|
| 903 | - $max_amount = max( $donation_levels_amounts ); |
|
| 902 | + $min_amount = min($donation_levels_amounts); |
|
| 903 | + $max_amount = max($donation_levels_amounts); |
|
| 904 | 904 | |
| 905 | 905 | // Set Minimum and Maximum amount for Multi Level Donation Forms |
| 906 | - give_update_meta( $form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount( $min_amount ) : 0 ); |
|
| 907 | - give_update_meta( $form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount( $max_amount ) : 0 ); |
|
| 906 | + give_update_meta($form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount($min_amount) : 0); |
|
| 907 | + give_update_meta($form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount($max_amount) : 0); |
|
| 908 | 908 | } |
| 909 | 909 | |
| 910 | 910 | } |
@@ -913,7 +913,7 @@ discard block |
||
| 913 | 913 | wp_reset_postdata(); |
| 914 | 914 | } else { |
| 915 | 915 | // The Update Ran. |
| 916 | - give_set_upgrade_complete( 'v189_upgrades_levels_post_meta' ); |
|
| 916 | + give_set_upgrade_complete('v189_upgrades_levels_post_meta'); |
|
| 917 | 917 | } |
| 918 | 918 | |
| 919 | 919 | } |
@@ -969,22 +969,22 @@ discard block |
||
| 969 | 969 | $give_settings = give_get_settings(); |
| 970 | 970 | $give_setting_updated = false; |
| 971 | 971 | |
| 972 | - if ( $give_settings['thousands_separator'] === $give_settings['decimal_separator'] ) { |
|
| 972 | + if ($give_settings['thousands_separator'] === $give_settings['decimal_separator']) { |
|
| 973 | 973 | $give_settings['number_decimals'] = 0; |
| 974 | 974 | $give_settings['decimal_separator'] = ''; |
| 975 | 975 | $give_setting_updated = true; |
| 976 | 976 | |
| 977 | - } elseif ( empty( $give_settings['decimal_separator'] ) ) { |
|
| 977 | + } elseif (empty($give_settings['decimal_separator'])) { |
|
| 978 | 978 | $give_settings['number_decimals'] = 0; |
| 979 | 979 | $give_setting_updated = true; |
| 980 | 980 | |
| 981 | - } elseif ( 6 < absint( $give_settings['number_decimals'] ) ) { |
|
| 981 | + } elseif (6 < absint($give_settings['number_decimals'])) { |
|
| 982 | 982 | $give_settings['number_decimals'] = 5; |
| 983 | 983 | $give_setting_updated = true; |
| 984 | 984 | } |
| 985 | 985 | |
| 986 | - if ( $give_setting_updated ) { |
|
| 987 | - update_option( 'give_settings', $give_settings ); |
|
| 986 | + if ($give_setting_updated) { |
|
| 987 | + update_option('give_settings', $give_settings); |
|
| 988 | 988 | } |
| 989 | 989 | } |
| 990 | 990 | |
@@ -1003,70 +1003,70 @@ discard block |
||
| 1003 | 1003 | $give_updates = Give_Updates::get_instance(); |
| 1004 | 1004 | |
| 1005 | 1005 | // form query. |
| 1006 | - $donation_forms = new WP_Query( array( |
|
| 1006 | + $donation_forms = new WP_Query(array( |
|
| 1007 | 1007 | 'paged' => $give_updates->step, |
| 1008 | 1008 | 'status' => 'any', |
| 1009 | 1009 | 'order' => 'ASC', |
| 1010 | - 'post_type' => array( 'give_forms', 'give_payment' ), |
|
| 1010 | + 'post_type' => array('give_forms', 'give_payment'), |
|
| 1011 | 1011 | 'posts_per_page' => 20, |
| 1012 | 1012 | ) |
| 1013 | 1013 | ); |
| 1014 | 1014 | |
| 1015 | - if ( $donation_forms->have_posts() ) { |
|
| 1016 | - $give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) ); |
|
| 1015 | + if ($donation_forms->have_posts()) { |
|
| 1016 | + $give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20)); |
|
| 1017 | 1017 | |
| 1018 | - while ( $donation_forms->have_posts() ) { |
|
| 1018 | + while ($donation_forms->have_posts()) { |
|
| 1019 | 1019 | $donation_forms->the_post(); |
| 1020 | 1020 | global $post; |
| 1021 | 1021 | |
| 1022 | - $meta = get_post_meta( $post->ID ); |
|
| 1022 | + $meta = get_post_meta($post->ID); |
|
| 1023 | 1023 | |
| 1024 | - switch ( $post->post_type ) { |
|
| 1024 | + switch ($post->post_type) { |
|
| 1025 | 1025 | case 'give_forms': |
| 1026 | 1026 | // _give_set_price. |
| 1027 | - if ( ! empty( $meta['_give_set_price'][0] ) ) { |
|
| 1028 | - update_post_meta( $post->ID, '_give_set_price', give_sanitize_amount_for_db( $meta['_give_set_price'][0] ) ); |
|
| 1027 | + if ( ! empty($meta['_give_set_price'][0])) { |
|
| 1028 | + update_post_meta($post->ID, '_give_set_price', give_sanitize_amount_for_db($meta['_give_set_price'][0])); |
|
| 1029 | 1029 | } |
| 1030 | 1030 | |
| 1031 | 1031 | // _give_custom_amount_minimum. |
| 1032 | - if ( ! empty( $meta['_give_custom_amount_minimum'][0] ) ) { |
|
| 1033 | - update_post_meta( $post->ID, '_give_custom_amount_minimum', give_sanitize_amount_for_db( $meta['_give_custom_amount_minimum'][0] ) ); |
|
| 1032 | + if ( ! empty($meta['_give_custom_amount_minimum'][0])) { |
|
| 1033 | + update_post_meta($post->ID, '_give_custom_amount_minimum', give_sanitize_amount_for_db($meta['_give_custom_amount_minimum'][0])); |
|
| 1034 | 1034 | } |
| 1035 | 1035 | |
| 1036 | 1036 | // _give_levels_minimum_amount. |
| 1037 | - if ( ! empty( $meta['_give_levels_minimum_amount'][0] ) ) { |
|
| 1038 | - update_post_meta( $post->ID, '_give_levels_minimum_amount', give_sanitize_amount_for_db( $meta['_give_levels_minimum_amount'][0] ) ); |
|
| 1037 | + if ( ! empty($meta['_give_levels_minimum_amount'][0])) { |
|
| 1038 | + update_post_meta($post->ID, '_give_levels_minimum_amount', give_sanitize_amount_for_db($meta['_give_levels_minimum_amount'][0])); |
|
| 1039 | 1039 | } |
| 1040 | 1040 | |
| 1041 | 1041 | // _give_levels_maximum_amount. |
| 1042 | - if ( ! empty( $meta['_give_levels_maximum_amount'][0] ) ) { |
|
| 1043 | - update_post_meta( $post->ID, '_give_levels_maximum_amount', give_sanitize_amount_for_db( $meta['_give_levels_maximum_amount'][0] ) ); |
|
| 1042 | + if ( ! empty($meta['_give_levels_maximum_amount'][0])) { |
|
| 1043 | + update_post_meta($post->ID, '_give_levels_maximum_amount', give_sanitize_amount_for_db($meta['_give_levels_maximum_amount'][0])); |
|
| 1044 | 1044 | } |
| 1045 | 1045 | |
| 1046 | 1046 | // _give_set_goal. |
| 1047 | - if ( ! empty( $meta['_give_set_goal'][0] ) ) { |
|
| 1048 | - update_post_meta( $post->ID, '_give_set_goal', give_sanitize_amount_for_db( $meta['_give_set_goal'][0] ) ); |
|
| 1047 | + if ( ! empty($meta['_give_set_goal'][0])) { |
|
| 1048 | + update_post_meta($post->ID, '_give_set_goal', give_sanitize_amount_for_db($meta['_give_set_goal'][0])); |
|
| 1049 | 1049 | } |
| 1050 | 1050 | |
| 1051 | 1051 | // _give_form_earnings. |
| 1052 | - if ( ! empty( $meta['_give_form_earnings'][0] ) ) { |
|
| 1053 | - update_post_meta( $post->ID, '_give_form_earnings', give_sanitize_amount_for_db( $meta['_give_form_earnings'][0] ) ); |
|
| 1052 | + if ( ! empty($meta['_give_form_earnings'][0])) { |
|
| 1053 | + update_post_meta($post->ID, '_give_form_earnings', give_sanitize_amount_for_db($meta['_give_form_earnings'][0])); |
|
| 1054 | 1054 | } |
| 1055 | 1055 | |
| 1056 | 1056 | // _give_custom_amount_minimum. |
| 1057 | - if ( ! empty( $meta['_give_donation_levels'][0] ) ) { |
|
| 1058 | - $donation_levels = unserialize( $meta['_give_donation_levels'][0] ); |
|
| 1057 | + if ( ! empty($meta['_give_donation_levels'][0])) { |
|
| 1058 | + $donation_levels = unserialize($meta['_give_donation_levels'][0]); |
|
| 1059 | 1059 | |
| 1060 | - foreach ( $donation_levels as $index => $level ) { |
|
| 1061 | - if ( empty( $level['_give_amount'] ) ) { |
|
| 1060 | + foreach ($donation_levels as $index => $level) { |
|
| 1061 | + if (empty($level['_give_amount'])) { |
|
| 1062 | 1062 | continue; |
| 1063 | 1063 | } |
| 1064 | 1064 | |
| 1065 | - $donation_levels[ $index ]['_give_amount'] = give_sanitize_amount_for_db( $level['_give_amount'] ); |
|
| 1065 | + $donation_levels[$index]['_give_amount'] = give_sanitize_amount_for_db($level['_give_amount']); |
|
| 1066 | 1066 | } |
| 1067 | 1067 | |
| 1068 | 1068 | $meta['_give_donation_levels'] = $donation_levels; |
| 1069 | - update_post_meta( $post->ID, '_give_donation_levels', $meta['_give_donation_levels'] ); |
|
| 1069 | + update_post_meta($post->ID, '_give_donation_levels', $meta['_give_donation_levels']); |
|
| 1070 | 1070 | } |
| 1071 | 1071 | |
| 1072 | 1072 | |
@@ -1074,8 +1074,8 @@ discard block |
||
| 1074 | 1074 | |
| 1075 | 1075 | case 'give_payment': |
| 1076 | 1076 | // _give_payment_total. |
| 1077 | - if ( ! empty( $meta['_give_payment_total'][0] ) ) { |
|
| 1078 | - update_post_meta( $post->ID, '_give_payment_total', give_sanitize_amount_for_db( $meta['_give_payment_total'][0] ) ); |
|
| 1077 | + if ( ! empty($meta['_give_payment_total'][0])) { |
|
| 1078 | + update_post_meta($post->ID, '_give_payment_total', give_sanitize_amount_for_db($meta['_give_payment_total'][0])); |
|
| 1079 | 1079 | } |
| 1080 | 1080 | |
| 1081 | 1081 | break; |
@@ -1086,7 +1086,7 @@ discard block |
||
| 1086 | 1086 | wp_reset_postdata(); |
| 1087 | 1087 | } else { |
| 1088 | 1088 | // The Update Ran. |
| 1089 | - give_set_upgrade_complete( 'v1812_update_amount_values' ); |
|
| 1089 | + give_set_upgrade_complete('v1812_update_amount_values'); |
|
| 1090 | 1090 | } |
| 1091 | 1091 | } |
| 1092 | 1092 | |
@@ -1106,22 +1106,22 @@ discard block |
||
| 1106 | 1106 | $offset = 1 === $give_updates->step ? 0 : $give_updates->step * 20; |
| 1107 | 1107 | |
| 1108 | 1108 | // form query. |
| 1109 | - $donors = Give()->donors->get_donors( array( |
|
| 1109 | + $donors = Give()->donors->get_donors(array( |
|
| 1110 | 1110 | 'number' => 20, |
| 1111 | 1111 | 'offset' => $offset, |
| 1112 | 1112 | ) |
| 1113 | 1113 | ); |
| 1114 | 1114 | |
| 1115 | - if ( ! empty( $donors ) ) { |
|
| 1116 | - $give_updates->set_percentage( Give()->donors->count(), ( $give_updates->step * 20 ) ); |
|
| 1115 | + if ( ! empty($donors)) { |
|
| 1116 | + $give_updates->set_percentage(Give()->donors->count(), ($give_updates->step * 20)); |
|
| 1117 | 1117 | |
| 1118 | 1118 | /* @var Object $donor */ |
| 1119 | - foreach ( $donors as $donor ) { |
|
| 1120 | - Give()->donors->update( $donor->id, array( 'purchase_value' => give_sanitize_amount_for_db( $donor->purchase_value ) ) ); |
|
| 1119 | + foreach ($donors as $donor) { |
|
| 1120 | + Give()->donors->update($donor->id, array('purchase_value' => give_sanitize_amount_for_db($donor->purchase_value))); |
|
| 1121 | 1121 | } |
| 1122 | 1122 | } else { |
| 1123 | 1123 | // The Update Ran. |
| 1124 | - give_set_upgrade_complete( 'v1812_update_donor_purchase_values' ); |
|
| 1124 | + give_set_upgrade_complete('v1812_update_donor_purchase_values'); |
|
| 1125 | 1125 | } |
| 1126 | 1126 | } |
| 1127 | 1127 | |
@@ -1136,25 +1136,25 @@ discard block |
||
| 1136 | 1136 | $offset = 1 === $give_updates->step ? 0 : $give_updates->step * 20; |
| 1137 | 1137 | |
| 1138 | 1138 | // Fetch all the existing donors. |
| 1139 | - $donors = Give()->donors->get_donors( array( |
|
| 1139 | + $donors = Give()->donors->get_donors(array( |
|
| 1140 | 1140 | 'number' => 20, |
| 1141 | 1141 | 'offset' => $offset, |
| 1142 | 1142 | ) |
| 1143 | 1143 | ); |
| 1144 | 1144 | |
| 1145 | - if ( ! empty( $donors ) ) { |
|
| 1146 | - $give_updates->set_percentage( Give()->donors->count(), ( $give_updates->step * 20 ) ); |
|
| 1145 | + if ( ! empty($donors)) { |
|
| 1146 | + $give_updates->set_percentage(Give()->donors->count(), ($give_updates->step * 20)); |
|
| 1147 | 1147 | |
| 1148 | 1148 | /* @var Object $donor */ |
| 1149 | - foreach ( $donors as $donor ) { |
|
| 1149 | + foreach ($donors as $donor) { |
|
| 1150 | 1150 | $user_id = $donor->user_id; |
| 1151 | 1151 | |
| 1152 | 1152 | // Proceed, if donor is attached with user. |
| 1153 | - if ( $user_id ) { |
|
| 1154 | - $user = get_userdata( $user_id ); |
|
| 1153 | + if ($user_id) { |
|
| 1154 | + $user = get_userdata($user_id); |
|
| 1155 | 1155 | |
| 1156 | 1156 | // Update user role, if user has subscriber role. |
| 1157 | - if ( is_array( $user->roles ) && in_array( 'subscriber', $user->roles ) ) { |
|
| 1157 | + if (is_array($user->roles) && in_array('subscriber', $user->roles)) { |
|
| 1158 | 1158 | wp_update_user( |
| 1159 | 1159 | array( |
| 1160 | 1160 | 'ID' => $user_id, |
@@ -1166,7 +1166,7 @@ discard block |
||
| 1166 | 1166 | } |
| 1167 | 1167 | } else { |
| 1168 | 1168 | // The Update Ran. |
| 1169 | - give_set_upgrade_complete( 'v1813_update_donor_user_roles' ); |
|
| 1169 | + give_set_upgrade_complete('v1813_update_donor_user_roles'); |
|
| 1170 | 1170 | } |
| 1171 | 1171 | } |
| 1172 | 1172 | |
@@ -1180,33 +1180,33 @@ discard block |
||
| 1180 | 1180 | $give_updates = Give_Updates::get_instance(); |
| 1181 | 1181 | |
| 1182 | 1182 | // form query. |
| 1183 | - $payments = new WP_Query( array( |
|
| 1183 | + $payments = new WP_Query(array( |
|
| 1184 | 1184 | 'paged' => $give_updates->step, |
| 1185 | 1185 | 'status' => 'any', |
| 1186 | 1186 | 'order' => 'ASC', |
| 1187 | - 'post_type' => array( 'give_payment' ), |
|
| 1187 | + 'post_type' => array('give_payment'), |
|
| 1188 | 1188 | 'posts_per_page' => 20, |
| 1189 | 1189 | ) |
| 1190 | 1190 | ); |
| 1191 | 1191 | |
| 1192 | - if ( $payments->have_posts() ) { |
|
| 1193 | - $give_updates->set_percentage( $payments->found_posts, ( $give_updates->step * 20 ) ); |
|
| 1192 | + if ($payments->have_posts()) { |
|
| 1193 | + $give_updates->set_percentage($payments->found_posts, ($give_updates->step * 20)); |
|
| 1194 | 1194 | |
| 1195 | - while( $payments->have_posts() ) { |
|
| 1195 | + while ($payments->have_posts()) { |
|
| 1196 | 1196 | $payments->the_post(); |
| 1197 | 1197 | |
| 1198 | - $payment_meta = give_get_payment_meta( get_the_ID() ); |
|
| 1198 | + $payment_meta = give_get_payment_meta(get_the_ID()); |
|
| 1199 | 1199 | |
| 1200 | - if ( 'RIAL' === $payment_meta['currency'] ) { |
|
| 1200 | + if ('RIAL' === $payment_meta['currency']) { |
|
| 1201 | 1201 | $payment_meta['currency'] = 'IRR'; |
| 1202 | - give_update_meta( get_the_ID(), '_give_payment_meta', $payment_meta ); |
|
| 1202 | + give_update_meta(get_the_ID(), '_give_payment_meta', $payment_meta); |
|
| 1203 | 1203 | } |
| 1204 | 1204 | |
| 1205 | 1205 | } |
| 1206 | 1206 | |
| 1207 | - }else{ |
|
| 1207 | + } else { |
|
| 1208 | 1208 | // The Update Ran. |
| 1209 | - give_set_upgrade_complete( 'v1817_update_donation_iranian_currency_code' ); |
|
| 1209 | + give_set_upgrade_complete('v1817_update_donation_iranian_currency_code'); |
|
| 1210 | 1210 | } |
| 1211 | 1211 | } |
| 1212 | 1212 | |
@@ -1217,7 +1217,7 @@ discard block |
||
| 1217 | 1217 | */ |
| 1218 | 1218 | function give_v1813_upgrades() { |
| 1219 | 1219 | // Update admin setting. |
| 1220 | - give_update_option( 'donor_default_user_role', 'give_donor' ); |
|
| 1220 | + give_update_option('donor_default_user_role', 'give_donor'); |
|
| 1221 | 1221 | |
| 1222 | 1222 | // Update Give roles. |
| 1223 | 1223 | $roles = new Give_Roles(); |
@@ -1234,9 +1234,9 @@ discard block |
||
| 1234 | 1234 | function give_v1817_upgrades() { |
| 1235 | 1235 | $give_settings = give_get_settings(); |
| 1236 | 1236 | |
| 1237 | - if ( 'RIAL' === $give_settings['currency'] ) { |
|
| 1237 | + if ('RIAL' === $give_settings['currency']) { |
|
| 1238 | 1238 | $give_settings['currency'] = 'IRR'; |
| 1239 | - update_option( 'give_settings', $give_settings ); |
|
| 1239 | + update_option('give_settings', $give_settings); |
|
| 1240 | 1240 | } |
| 1241 | 1241 | } |
| 1242 | 1242 | |
@@ -1249,7 +1249,7 @@ discard block |
||
| 1249 | 1249 | |
| 1250 | 1250 | global $wp_roles; |
| 1251 | 1251 | |
| 1252 | - if( ! ( $wp_roles instanceof WP_Roles ) ) { |
|
| 1252 | + if ( ! ($wp_roles instanceof WP_Roles)) { |
|
| 1253 | 1253 | return; |
| 1254 | 1254 | } |
| 1255 | 1255 | |
@@ -1273,15 +1273,15 @@ discard block |
||
| 1273 | 1273 | ), |
| 1274 | 1274 | ); |
| 1275 | 1275 | |
| 1276 | - foreach ( $add_caps as $role => $caps ) { |
|
| 1277 | - foreach( $caps as $cap ) { |
|
| 1278 | - $wp_roles->add_cap( $role, $cap ); |
|
| 1276 | + foreach ($add_caps as $role => $caps) { |
|
| 1277 | + foreach ($caps as $cap) { |
|
| 1278 | + $wp_roles->add_cap($role, $cap); |
|
| 1279 | 1279 | } |
| 1280 | 1280 | } |
| 1281 | 1281 | |
| 1282 | - foreach ( $remove_caps as $role => $caps ) { |
|
| 1283 | - foreach( $caps as $cap ) { |
|
| 1284 | - $wp_roles->remove_cap( $role, $cap ); |
|
| 1282 | + foreach ($remove_caps as $role => $caps) { |
|
| 1283 | + foreach ($caps as $cap) { |
|
| 1284 | + $wp_roles->remove_cap($role, $cap); |
|
| 1285 | 1285 | } |
| 1286 | 1286 | } |
| 1287 | 1287 | |
@@ -1306,6 +1306,6 @@ discard block |
||
| 1306 | 1306 | $roles->add_roles(); |
| 1307 | 1307 | $roles->add_caps(); |
| 1308 | 1308 | |
| 1309 | - give_set_upgrade_complete( 'v1817_cleanup_user_roles' ); |
|
| 1309 | + give_set_upgrade_complete('v1817_cleanup_user_roles'); |
|
| 1310 | 1310 | |
| 1311 | 1311 | } |
| 1312 | 1312 | \ No newline at end of file |
@@ -1204,7 +1204,7 @@ |
||
| 1204 | 1204 | |
| 1205 | 1205 | } |
| 1206 | 1206 | |
| 1207 | - }else{ |
|
| 1207 | + } else{ |
|
| 1208 | 1208 | // The Update Ran. |
| 1209 | 1209 | give_set_upgrade_complete( 'v1817_update_donation_iranian_currency_code' ); |
| 1210 | 1210 | } |
@@ -109,8 +109,8 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | // Show error message if Akismet not configured and Admin try to save 'enabled' option. |
| 111 | 111 | if ( isset( $_POST['akismet_spam_protection'] ) |
| 112 | - && give_is_setting_enabled( $_POST['akismet_spam_protection'] ) |
|
| 113 | - && ! give_check_akismet_key() |
|
| 112 | + && give_is_setting_enabled( $_POST['akismet_spam_protection'] ) |
|
| 113 | + && ! give_check_akismet_key() |
|
| 114 | 114 | ) { |
| 115 | 115 | self::add_error( 'give-akismet-protection', __( 'Please properly configure Akismet to enable SPAM protection.', 'give' ) ); |
| 116 | 116 | |
@@ -792,9 +792,9 @@ discard block |
||
| 792 | 792 | <td class="give-docs-link" colspan="2"> |
| 793 | 793 | <?php |
| 794 | 794 | echo '<p class="give-docs-link"><a href="' . esc_url( $value['url'] ) |
| 795 | - . '" target="_blank">' |
|
| 796 | - . sprintf( esc_html__( 'Need Help? See docs on "%s"', 'give' ), $value['title'] ) |
|
| 797 | - . '<span class="dashicons dashicons-editor-help"></span></a></p>'; |
|
| 795 | + . '" target="_blank">' |
|
| 796 | + . sprintf( esc_html__( 'Need Help? See docs on "%s"', 'give' ), $value['title'] ) |
|
| 797 | + . '<span class="dashicons dashicons-editor-help"></span></a></p>'; |
|
| 798 | 798 | ?> |
| 799 | 799 | </td> |
| 800 | 800 | </tr><?php |
@@ -9,11 +9,11 @@ discard block |
||
| 9 | 9 | * @since 1.8 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 12 | +if ( ! defined('ABSPATH')) { |
|
| 13 | 13 | exit; |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | -if ( ! class_exists( 'Give_Admin_Settings' ) ) : |
|
| 16 | +if ( ! class_exists('Give_Admin_Settings')) : |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Give_Admin_Settings Class. |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @param array $settings Array of settings class object. |
| 74 | 74 | */ |
| 75 | - self::$settings = apply_filters( self::$setting_filter_prefix . '_get_settings_pages', array() ); |
|
| 75 | + self::$settings = apply_filters(self::$setting_filter_prefix.'_get_settings_pages', array()); |
|
| 76 | 76 | |
| 77 | 77 | return self::$settings; |
| 78 | 78 | } |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * @return bool |
| 87 | 87 | */ |
| 88 | 88 | public static function verify_nonce() { |
| 89 | - if ( empty( $_REQUEST['_give-save-settings'] ) || ! wp_verify_nonce( $_REQUEST['_give-save-settings'], 'give-save-settings' ) ) { |
|
| 89 | + if (empty($_REQUEST['_give-save-settings']) || ! wp_verify_nonce($_REQUEST['_give-save-settings'], 'give-save-settings')) { |
|
| 90 | 90 | return false; |
| 91 | 91 | } |
| 92 | 92 | |
@@ -102,17 +102,17 @@ discard block |
||
| 102 | 102 | public static function save() { |
| 103 | 103 | $current_tab = give_get_current_setting_tab(); |
| 104 | 104 | |
| 105 | - if ( ! self::verify_nonce() ) { |
|
| 106 | - echo '<div class="notice error"><p>' . __( 'Action failed. Please refresh the page and retry.', 'give' ) . '</p></div>'; |
|
| 105 | + if ( ! self::verify_nonce()) { |
|
| 106 | + echo '<div class="notice error"><p>'.__('Action failed. Please refresh the page and retry.', 'give').'</p></div>'; |
|
| 107 | 107 | die(); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | // Show error message if Akismet not configured and Admin try to save 'enabled' option. |
| 111 | - if ( isset( $_POST['akismet_spam_protection'] ) |
|
| 112 | - && give_is_setting_enabled( $_POST['akismet_spam_protection'] ) |
|
| 111 | + if (isset($_POST['akismet_spam_protection']) |
|
| 112 | + && give_is_setting_enabled($_POST['akismet_spam_protection']) |
|
| 113 | 113 | && ! give_check_akismet_key() |
| 114 | 114 | ) { |
| 115 | - self::add_error( 'give-akismet-protection', __( 'Please properly configure Akismet to enable SPAM protection.', 'give' ) ); |
|
| 115 | + self::add_error('give-akismet-protection', __('Please properly configure Akismet to enable SPAM protection.', 'give')); |
|
| 116 | 116 | |
| 117 | 117 | return; |
| 118 | 118 | } |
@@ -126,9 +126,9 @@ discard block |
||
| 126 | 126 | * |
| 127 | 127 | * @since 1.8 |
| 128 | 128 | */ |
| 129 | - do_action( self::$setting_filter_prefix . '_save_' . $current_tab ); |
|
| 129 | + do_action(self::$setting_filter_prefix.'_save_'.$current_tab); |
|
| 130 | 130 | |
| 131 | - self::add_message( 'give-setting-updated', __( 'Your settings have been saved.', 'give' ) ); |
|
| 131 | + self::add_message('give-setting-updated', __('Your settings have been saved.', 'give')); |
|
| 132 | 132 | |
| 133 | 133 | /** |
| 134 | 134 | * Trigger Action. |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | * |
| 140 | 140 | * @since 1.8 |
| 141 | 141 | */ |
| 142 | - do_action( self::$setting_filter_prefix . '_saved' ); |
|
| 142 | + do_action(self::$setting_filter_prefix.'_saved'); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | /** |
@@ -152,8 +152,8 @@ discard block |
||
| 152 | 152 | * |
| 153 | 153 | * @return void |
| 154 | 154 | */ |
| 155 | - public static function add_message( $code, $message ) { |
|
| 156 | - self::$messages[ $code ] = $message; |
|
| 155 | + public static function add_message($code, $message) { |
|
| 156 | + self::$messages[$code] = $message; |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -166,8 +166,8 @@ discard block |
||
| 166 | 166 | * |
| 167 | 167 | * @return void |
| 168 | 168 | */ |
| 169 | - public static function add_error( $code, $message ) { |
|
| 170 | - self::$errors[ $code ] = $message; |
|
| 169 | + public static function add_error($code, $message) { |
|
| 170 | + self::$errors[$code] = $message; |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | /** |
@@ -180,18 +180,18 @@ discard block |
||
| 180 | 180 | $notice_html = ''; |
| 181 | 181 | $classes = 'give-notice settings-error notice is-dismissible'; |
| 182 | 182 | |
| 183 | - self::$errors = apply_filters( self::$setting_filter_prefix . '_error_notices', self::$errors ); |
|
| 184 | - self::$messages = apply_filters( self::$setting_filter_prefix . '_update_notices', self::$messages ); |
|
| 183 | + self::$errors = apply_filters(self::$setting_filter_prefix.'_error_notices', self::$errors); |
|
| 184 | + self::$messages = apply_filters(self::$setting_filter_prefix.'_update_notices', self::$messages); |
|
| 185 | 185 | |
| 186 | - if ( 0 < count( self::$errors ) ) { |
|
| 187 | - foreach ( self::$errors as $code => $message ) { |
|
| 188 | - $notice_html .= '<div id="setting-error-' . $code . '" class="' . $classes . ' error"><p><strong>' . $message . '</strong></p></div>'; |
|
| 186 | + if (0 < count(self::$errors)) { |
|
| 187 | + foreach (self::$errors as $code => $message) { |
|
| 188 | + $notice_html .= '<div id="setting-error-'.$code.'" class="'.$classes.' error"><p><strong>'.$message.'</strong></p></div>'; |
|
| 189 | 189 | } |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - if ( 0 < count( self::$messages ) ) { |
|
| 193 | - foreach ( self::$messages as $code => $message ) { |
|
| 194 | - $notice_html .= '<div id="setting-error-' . $code . '" class="' . $classes . ' updated"><p><strong>' . $message . '</strong></p></div>'; |
|
| 192 | + if (0 < count(self::$messages)) { |
|
| 193 | + foreach (self::$messages as $code => $message) { |
|
| 194 | + $notice_html .= '<div id="setting-error-'.$code.'" class="'.$classes.' updated"><p><strong>'.$message.'</strong></p></div>'; |
|
| 195 | 195 | } |
| 196 | 196 | } |
| 197 | 197 | |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | self::$setting_filter_prefix = give_get_current_setting_page(); |
| 212 | 212 | |
| 213 | 213 | // Bailout: Exit if setting page is not defined. |
| 214 | - if ( empty( self::$setting_filter_prefix ) ) { |
|
| 214 | + if (empty(self::$setting_filter_prefix)) { |
|
| 215 | 215 | return false; |
| 216 | 216 | } |
| 217 | 217 | |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | * |
| 225 | 225 | * @since 1.8 |
| 226 | 226 | */ |
| 227 | - do_action( self::$setting_filter_prefix . '_start' ); |
|
| 227 | + do_action(self::$setting_filter_prefix.'_start'); |
|
| 228 | 228 | |
| 229 | 229 | $current_tab = give_get_current_setting_tab(); |
| 230 | 230 | |
@@ -234,9 +234,9 @@ discard block |
||
| 234 | 234 | /* @var object $current_setting_obj */ |
| 235 | 235 | $current_setting_obj = new StdClass; |
| 236 | 236 | |
| 237 | - foreach ( $all_setting as $setting ) { |
|
| 237 | + foreach ($all_setting as $setting) { |
|
| 238 | 238 | if ( |
| 239 | - method_exists( $setting, 'get_id' ) && |
|
| 239 | + method_exists($setting, 'get_id') && |
|
| 240 | 240 | $current_tab === $setting->get_id() |
| 241 | 241 | ) { |
| 242 | 242 | $current_setting_obj = $setting; |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | // Save settings if data has been posted. |
| 248 | - if ( ! empty( $_POST ) ) { |
|
| 248 | + if ( ! empty($_POST)) { |
|
| 249 | 249 | self::save(); |
| 250 | 250 | } |
| 251 | 251 | |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | * |
| 259 | 259 | * @since 1.8 |
| 260 | 260 | */ |
| 261 | - $tabs = apply_filters( self::$setting_filter_prefix . '_tabs_array', array() ); |
|
| 261 | + $tabs = apply_filters(self::$setting_filter_prefix.'_tabs_array', array()); |
|
| 262 | 262 | |
| 263 | 263 | include 'views/html-admin-settings.php'; |
| 264 | 264 | |
@@ -276,25 +276,25 @@ discard block |
||
| 276 | 276 | * |
| 277 | 277 | * @return string|bool |
| 278 | 278 | */ |
| 279 | - public static function get_option( $option_name = '', $field_id = '', $default = false ) { |
|
| 279 | + public static function get_option($option_name = '', $field_id = '', $default = false) { |
|
| 280 | 280 | // Bailout. |
| 281 | - if ( empty( $option_name ) && empty( $field_id ) ) { |
|
| 281 | + if (empty($option_name) && empty($field_id)) { |
|
| 282 | 282 | return false; |
| 283 | 283 | } |
| 284 | 284 | |
| 285 | - if ( ! empty( $field_id ) && ! empty( $option_name ) ) { |
|
| 285 | + if ( ! empty($field_id) && ! empty($option_name)) { |
|
| 286 | 286 | // Get field value if any. |
| 287 | - $option_value = get_option( $option_name ); |
|
| 287 | + $option_value = get_option($option_name); |
|
| 288 | 288 | |
| 289 | - $option_value = ( is_array( $option_value ) && array_key_exists( $field_id, $option_value ) ) |
|
| 290 | - ? $option_value[ $field_id ] |
|
| 289 | + $option_value = (is_array($option_value) && array_key_exists($field_id, $option_value)) |
|
| 290 | + ? $option_value[$field_id] |
|
| 291 | 291 | : $default; |
| 292 | 292 | } else { |
| 293 | 293 | // If option name is empty but not field name then this means, setting is direct store to option table under there field name. |
| 294 | 294 | $option_name = ! $option_name ? $field_id : $option_name; |
| 295 | 295 | |
| 296 | 296 | // Get option value if any. |
| 297 | - $option_value = get_option( $option_name, $default ); |
|
| 297 | + $option_value = get_option($option_name, $default); |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | return $option_value; |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | * |
| 313 | 313 | * @return void |
| 314 | 314 | */ |
| 315 | - public static function output_fields( $options, $option_name = '' ) { |
|
| 315 | + public static function output_fields($options, $option_name = '') { |
|
| 316 | 316 | $current_tab = give_get_current_setting_tab(); |
| 317 | 317 | |
| 318 | 318 | // Field Default values. |
@@ -325,52 +325,52 @@ discard block |
||
| 325 | 325 | 'table_html' => true, |
| 326 | 326 | ); |
| 327 | 327 | |
| 328 | - foreach ( $options as $value ) { |
|
| 329 | - if ( ! isset( $value['type'] ) ) { |
|
| 328 | + foreach ($options as $value) { |
|
| 329 | + if ( ! isset($value['type'])) { |
|
| 330 | 330 | continue; |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | // Set title. |
| 334 | - $defaults['title'] = isset( $value['name'] ) ? $value['name'] : ''; |
|
| 334 | + $defaults['title'] = isset($value['name']) ? $value['name'] : ''; |
|
| 335 | 335 | |
| 336 | 336 | // Set default setting. |
| 337 | - $value = wp_parse_args( $value, $defaults ); |
|
| 337 | + $value = wp_parse_args($value, $defaults); |
|
| 338 | 338 | |
| 339 | 339 | // Colorpicker field. |
| 340 | - $value['class'] = ( 'colorpicker' === $value['type'] ? trim( $value['class'] ) . ' give-colorpicker' : $value['class'] ); |
|
| 341 | - $value['type'] = ( 'colorpicker' === $value['type'] ? 'text' : $value['type'] ); |
|
| 340 | + $value['class'] = ('colorpicker' === $value['type'] ? trim($value['class']).' give-colorpicker' : $value['class']); |
|
| 341 | + $value['type'] = ('colorpicker' === $value['type'] ? 'text' : $value['type']); |
|
| 342 | 342 | |
| 343 | 343 | |
| 344 | 344 | // Custom attribute handling. |
| 345 | 345 | $custom_attributes = array(); |
| 346 | 346 | |
| 347 | - if ( ! empty( $value['attributes'] ) && is_array( $value['attributes'] ) ) { |
|
| 348 | - foreach ( $value['attributes'] as $attribute => $attribute_value ) { |
|
| 349 | - $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"'; |
|
| 347 | + if ( ! empty($value['attributes']) && is_array($value['attributes'])) { |
|
| 348 | + foreach ($value['attributes'] as $attribute => $attribute_value) { |
|
| 349 | + $custom_attributes[] = esc_attr($attribute).'="'.esc_attr($attribute_value).'"'; |
|
| 350 | 350 | } |
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | // Description handling. |
| 354 | - $description = self::get_field_description( $value ); |
|
| 354 | + $description = self::get_field_description($value); |
|
| 355 | 355 | |
| 356 | 356 | // Switch based on type. |
| 357 | - switch ( $value['type'] ) { |
|
| 357 | + switch ($value['type']) { |
|
| 358 | 358 | |
| 359 | 359 | // Section Titles |
| 360 | 360 | case 'title': |
| 361 | - if ( ! empty( $value['title'] ) ) { |
|
| 362 | - echo '<div class="give-setting-tab-header give-setting-tab-header-' . $current_tab . '"><h2>' . self::get_field_title( $value ) . '</h2><hr></div>'; |
|
| 361 | + if ( ! empty($value['title'])) { |
|
| 362 | + echo '<div class="give-setting-tab-header give-setting-tab-header-'.$current_tab.'"><h2>'.self::get_field_title($value).'</h2><hr></div>'; |
|
| 363 | 363 | } |
| 364 | 364 | |
| 365 | - if ( ! empty( $value['desc'] ) ) { |
|
| 366 | - echo wpautop( wptexturize( wp_kses_post( $value['desc'] ) ) ); |
|
| 365 | + if ( ! empty($value['desc'])) { |
|
| 366 | + echo wpautop(wptexturize(wp_kses_post($value['desc']))); |
|
| 367 | 367 | } |
| 368 | 368 | |
| 369 | - if ( $value['table_html'] ) { |
|
| 370 | - echo '<table class="form-table give-setting-tab-body give-setting-tab-body-' . $current_tab . '">' . "\n\n"; |
|
| 369 | + if ($value['table_html']) { |
|
| 370 | + echo '<table class="form-table give-setting-tab-body give-setting-tab-body-'.$current_tab.'">'."\n\n"; |
|
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - if ( ! empty( $value['id'] ) ) { |
|
| 373 | + if ( ! empty($value['id'])) { |
|
| 374 | 374 | |
| 375 | 375 | /** |
| 376 | 376 | * Trigger Action. |
@@ -379,14 +379,14 @@ discard block |
||
| 379 | 379 | * |
| 380 | 380 | * @since 1.8 |
| 381 | 381 | */ |
| 382 | - do_action( 'give_settings_' . sanitize_title( $value['id'] ) ); |
|
| 382 | + do_action('give_settings_'.sanitize_title($value['id'])); |
|
| 383 | 383 | } |
| 384 | 384 | |
| 385 | 385 | break; |
| 386 | 386 | |
| 387 | 387 | // Section Ends. |
| 388 | 388 | case 'sectionend': |
| 389 | - if ( ! empty( $value['id'] ) ) { |
|
| 389 | + if ( ! empty($value['id'])) { |
|
| 390 | 390 | |
| 391 | 391 | /** |
| 392 | 392 | * Trigger Action. |
@@ -395,14 +395,14 @@ discard block |
||
| 395 | 395 | * |
| 396 | 396 | * @since 1.8 |
| 397 | 397 | */ |
| 398 | - do_action( 'give_settings_' . sanitize_title( $value['id'] ) . '_end' ); |
|
| 398 | + do_action('give_settings_'.sanitize_title($value['id']).'_end'); |
|
| 399 | 399 | } |
| 400 | 400 | |
| 401 | - if ( $value['table_html'] ) { |
|
| 401 | + if ($value['table_html']) { |
|
| 402 | 402 | echo '</table>'; |
| 403 | 403 | } |
| 404 | 404 | |
| 405 | - if ( ! empty( $value['id'] ) ) { |
|
| 405 | + if ( ! empty($value['id'])) { |
|
| 406 | 406 | |
| 407 | 407 | /** |
| 408 | 408 | * Trigger Action. |
@@ -411,7 +411,7 @@ discard block |
||
| 411 | 411 | * |
| 412 | 412 | * @since 1.8 |
| 413 | 413 | */ |
| 414 | - do_action( 'give_settings_' . sanitize_title( $value['id'] ) . '_after' ); |
|
| 414 | + do_action('give_settings_'.sanitize_title($value['id']).'_after'); |
|
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | break; |
@@ -419,27 +419,27 @@ discard block |
||
| 419 | 419 | // Standard text inputs and subtypes like 'number'. |
| 420 | 420 | case 'colorpicker': |
| 421 | 421 | case 'hidden' : |
| 422 | - $value['wrapper_class'] = empty( $value['wrapper_class'] ) ? 'give-hidden' : trim( $value['wrapper_class'] ) . ' give-hidden'; |
|
| 422 | + $value['wrapper_class'] = empty($value['wrapper_class']) ? 'give-hidden' : trim($value['wrapper_class']).' give-hidden'; |
|
| 423 | 423 | case 'text': |
| 424 | 424 | case 'email': |
| 425 | 425 | case 'number': |
| 426 | 426 | case 'password' : |
| 427 | 427 | $type = $value['type']; |
| 428 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 428 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 429 | 429 | ?> |
| 430 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 430 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 431 | 431 | <th scope="row" class="titledesc"> |
| 432 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 432 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 433 | 433 | </th> |
| 434 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
| 434 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
| 435 | 435 | <input |
| 436 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 437 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 438 | - type="<?php echo esc_attr( $type ); ?>" |
|
| 439 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
| 440 | - value="<?php echo esc_attr( $option_value ); ?>" |
|
| 441 | - class="give-input-field<?php echo( empty( $value['class'] ) ? '' : ' ' . esc_attr( $value['class'] ) ); ?>" |
|
| 442 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 436 | + name="<?php echo esc_attr($value['id']); ?>" |
|
| 437 | + id="<?php echo esc_attr($value['id']); ?>" |
|
| 438 | + type="<?php echo esc_attr($type); ?>" |
|
| 439 | + style="<?php echo esc_attr($value['css']); ?>" |
|
| 440 | + value="<?php echo esc_attr($option_value); ?>" |
|
| 441 | + class="give-input-field<?php echo(empty($value['class']) ? '' : ' '.esc_attr($value['class'])); ?>" |
|
| 442 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 443 | 443 | /> <?php echo $description; ?> |
| 444 | 444 | </td> |
| 445 | 445 | </tr> |
@@ -449,23 +449,23 @@ discard block |
||
| 449 | 449 | // Textarea. |
| 450 | 450 | case 'textarea': |
| 451 | 451 | |
| 452 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 452 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 453 | 453 | |
| 454 | 454 | ?> |
| 455 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 455 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 456 | 456 | <th scope="row" class="titledesc"> |
| 457 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 457 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 458 | 458 | </th> |
| 459 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
| 459 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
| 460 | 460 | <textarea |
| 461 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 462 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 463 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
| 464 | - class="<?php echo esc_attr( $value['class'] ); ?>" |
|
| 461 | + name="<?php echo esc_attr($value['id']); ?>" |
|
| 462 | + id="<?php echo esc_attr($value['id']); ?>" |
|
| 463 | + style="<?php echo esc_attr($value['css']); ?>" |
|
| 464 | + class="<?php echo esc_attr($value['class']); ?>" |
|
| 465 | 465 | rows="10" |
| 466 | 466 | cols="60" |
| 467 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 468 | - ><?php echo esc_textarea( $option_value ); ?></textarea> |
|
| 467 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 468 | + ><?php echo esc_textarea($option_value); ?></textarea> |
|
| 469 | 469 | <?php echo $description; ?> |
| 470 | 470 | </td> |
| 471 | 471 | </tr><?php |
@@ -475,35 +475,35 @@ discard block |
||
| 475 | 475 | case 'select' : |
| 476 | 476 | case 'multiselect' : |
| 477 | 477 | |
| 478 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 478 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 479 | 479 | |
| 480 | 480 | ?> |
| 481 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 481 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 482 | 482 | <th scope="row" class="titledesc"> |
| 483 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 483 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 484 | 484 | </th> |
| 485 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
| 485 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
| 486 | 486 | <select |
| 487 | - name="<?php echo esc_attr( $value['id'] ); ?><?php if ( $value['type'] == 'multiselect' ) { |
|
| 487 | + name="<?php echo esc_attr($value['id']); ?><?php if ($value['type'] == 'multiselect') { |
|
| 488 | 488 | echo '[]'; |
| 489 | 489 | } ?>" |
| 490 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 491 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
| 492 | - class="<?php echo esc_attr( $value['class'] ); ?>" |
|
| 493 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 494 | - <?php echo ( 'multiselect' == $value['type'] ) ? 'multiple="multiple"' : ''; ?> |
|
| 490 | + id="<?php echo esc_attr($value['id']); ?>" |
|
| 491 | + style="<?php echo esc_attr($value['css']); ?>" |
|
| 492 | + class="<?php echo esc_attr($value['class']); ?>" |
|
| 493 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 494 | + <?php echo ('multiselect' == $value['type']) ? 'multiple="multiple"' : ''; ?> |
|
| 495 | 495 | > |
| 496 | 496 | |
| 497 | 497 | <?php |
| 498 | - if ( ! empty( $value['options'] ) ) { |
|
| 499 | - foreach ( $value['options'] as $key => $val ) { |
|
| 498 | + if ( ! empty($value['options'])) { |
|
| 499 | + foreach ($value['options'] as $key => $val) { |
|
| 500 | 500 | ?> |
| 501 | - <option value="<?php echo esc_attr( $key ); ?>" <?php |
|
| 501 | + <option value="<?php echo esc_attr($key); ?>" <?php |
|
| 502 | 502 | |
| 503 | - if ( is_array( $option_value ) ) { |
|
| 504 | - selected( in_array( $key, $option_value ), true ); |
|
| 503 | + if (is_array($option_value)) { |
|
| 504 | + selected(in_array($key, $option_value), true); |
|
| 505 | 505 | } else { |
| 506 | - selected( $option_value, $key ); |
|
| 506 | + selected($option_value, $key); |
|
| 507 | 507 | } |
| 508 | 508 | |
| 509 | 509 | ?>><?php echo $val ?></option> |
@@ -519,28 +519,28 @@ discard block |
||
| 519 | 519 | |
| 520 | 520 | // Radio inputs. |
| 521 | 521 | case 'radio_inline' : |
| 522 | - $value['class'] = empty( $value['class'] ) ? 'give-radio-inline' : $value['class'] . ' give-radio-inline'; |
|
| 522 | + $value['class'] = empty($value['class']) ? 'give-radio-inline' : $value['class'].' give-radio-inline'; |
|
| 523 | 523 | case 'radio' : |
| 524 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 524 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 525 | 525 | ?> |
| 526 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 526 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 527 | 527 | <th scope="row" class="titledesc"> |
| 528 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 528 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 529 | 529 | </th> |
| 530 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?> <?php echo( ! empty( $value['class'] ) ? $value['class'] : '' ); ?>"> |
|
| 530 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?> <?php echo( ! empty($value['class']) ? $value['class'] : ''); ?>"> |
|
| 531 | 531 | <fieldset> |
| 532 | 532 | <ul> |
| 533 | 533 | <?php |
| 534 | - foreach ( $value['options'] as $key => $val ) { |
|
| 534 | + foreach ($value['options'] as $key => $val) { |
|
| 535 | 535 | ?> |
| 536 | 536 | <li> |
| 537 | 537 | <label><input |
| 538 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 538 | + name="<?php echo esc_attr($value['id']); ?>" |
|
| 539 | 539 | value="<?php echo $key; ?>" |
| 540 | 540 | type="radio" |
| 541 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
| 542 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 543 | - <?php checked( $key, $option_value ); ?> |
|
| 541 | + style="<?php echo esc_attr($value['css']); ?>" |
|
| 542 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 543 | + <?php checked($key, $option_value); ?> |
|
| 544 | 544 | /> <?php echo $val ?></label> |
| 545 | 545 | </li> |
| 546 | 546 | <?php |
@@ -554,21 +554,21 @@ discard block |
||
| 554 | 554 | |
| 555 | 555 | // Checkbox input. |
| 556 | 556 | case 'checkbox' : |
| 557 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 557 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 558 | 558 | ?> |
| 559 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 559 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 560 | 560 | <th scope="row" class="titledesc"> |
| 561 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 561 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 562 | 562 | </th> |
| 563 | 563 | <td class="give-forminp"> |
| 564 | 564 | <input |
| 565 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 566 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 565 | + name="<?php echo esc_attr($value['id']); ?>" |
|
| 566 | + id="<?php echo esc_attr($value['id']); ?>" |
|
| 567 | 567 | type="checkbox" |
| 568 | - class="<?php echo esc_attr( isset( $value['class'] ) ? $value['class'] : '' ); ?>" |
|
| 568 | + class="<?php echo esc_attr(isset($value['class']) ? $value['class'] : ''); ?>" |
|
| 569 | 569 | value="1" |
| 570 | - <?php checked( $option_value, 'on' ); ?> |
|
| 571 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 570 | + <?php checked($option_value, 'on'); ?> |
|
| 571 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 572 | 572 | /> |
| 573 | 573 | <?php echo $description; ?> |
| 574 | 574 | </td> |
@@ -578,28 +578,28 @@ discard block |
||
| 578 | 578 | |
| 579 | 579 | // Multi Checkbox input. |
| 580 | 580 | case 'multicheck' : |
| 581 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 582 | - $option_value = is_array( $option_value ) ? $option_value : array(); |
|
| 581 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 582 | + $option_value = is_array($option_value) ? $option_value : array(); |
|
| 583 | 583 | ?> |
| 584 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 584 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 585 | 585 | <th scope="row" class="titledesc"> |
| 586 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 586 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 587 | 587 | </th> |
| 588 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?> <?php echo( ! empty( $value['class'] ) ? $value['class'] : '' ); ?>"> |
|
| 588 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?> <?php echo( ! empty($value['class']) ? $value['class'] : ''); ?>"> |
|
| 589 | 589 | <fieldset> |
| 590 | 590 | <ul> |
| 591 | 591 | <?php |
| 592 | - foreach ( $value['options'] as $key => $val ) { |
|
| 592 | + foreach ($value['options'] as $key => $val) { |
|
| 593 | 593 | ?> |
| 594 | 594 | <li> |
| 595 | 595 | <label> |
| 596 | 596 | <input |
| 597 | - name="<?php echo esc_attr( $value['id'] ); ?>[]" |
|
| 597 | + name="<?php echo esc_attr($value['id']); ?>[]" |
|
| 598 | 598 | value="<?php echo $key; ?>" |
| 599 | 599 | type="checkbox" |
| 600 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
| 601 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 602 | - <?php if ( in_array( $key, $option_value ) ) { |
|
| 600 | + style="<?php echo esc_attr($value['css']); ?>" |
|
| 601 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 602 | + <?php if (in_array($key, $option_value)) { |
|
| 603 | 603 | echo 'checked="checked"'; |
| 604 | 604 | } ?> |
| 605 | 605 | /> <?php echo $val ?> |
@@ -618,30 +618,30 @@ discard block |
||
| 618 | 618 | // File input field. |
| 619 | 619 | case 'file' : |
| 620 | 620 | case 'media' : |
| 621 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 622 | - $button_label = esc_html__( sprintf( 'Add or Upload %s', ( 'file' === $value['type'] ? 'File' : 'Image' ) ), 'give' ); |
|
| 623 | - $fvalue = empty( $value['fvalue'] ) ? 'url' : $value['fvalue']; |
|
| 624 | - |
|
| 625 | - $allow_media_preview_tags = array( 'jpg', 'jpeg', 'png', 'gif', 'ico' ); |
|
| 626 | - $preview_image_src = $option_value ? ( 'id' === $fvalue ? wp_get_attachment_url( $option_value ) : $option_value ) : '#'; |
|
| 627 | - $preview_image_extension = $preview_image_src ? pathinfo( $preview_image_src, PATHINFO_EXTENSION ) : ''; |
|
| 628 | - $is_show_preview = in_array( $preview_image_extension, $allow_media_preview_tags ); |
|
| 621 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 622 | + $button_label = esc_html__(sprintf('Add or Upload %s', ('file' === $value['type'] ? 'File' : 'Image')), 'give'); |
|
| 623 | + $fvalue = empty($value['fvalue']) ? 'url' : $value['fvalue']; |
|
| 624 | + |
|
| 625 | + $allow_media_preview_tags = array('jpg', 'jpeg', 'png', 'gif', 'ico'); |
|
| 626 | + $preview_image_src = $option_value ? ('id' === $fvalue ? wp_get_attachment_url($option_value) : $option_value) : '#'; |
|
| 627 | + $preview_image_extension = $preview_image_src ? pathinfo($preview_image_src, PATHINFO_EXTENSION) : ''; |
|
| 628 | + $is_show_preview = in_array($preview_image_extension, $allow_media_preview_tags); |
|
| 629 | 629 | ?> |
| 630 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 630 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 631 | 631 | <th scope="row" class="titledesc"> |
| 632 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 632 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 633 | 633 | </th> |
| 634 | 634 | <td class="give-forminp"> |
| 635 | 635 | <div class="give-field-wrap"> |
| 636 | 636 | <label for="<?php echo $value['id'] ?>"> |
| 637 | 637 | <input |
| 638 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 639 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 638 | + name="<?php echo esc_attr($value['id']); ?>" |
|
| 639 | + id="<?php echo esc_attr($value['id']); ?>" |
|
| 640 | 640 | type="text" |
| 641 | - class="give-input-field<?php echo esc_attr( isset( $value['class'] ) ? ' ' . $value['class'] : '' ); ?>" |
|
| 641 | + class="give-input-field<?php echo esc_attr(isset($value['class']) ? ' '.$value['class'] : ''); ?>" |
|
| 642 | 642 | value="<?php echo $option_value; ?>" |
| 643 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
| 644 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 643 | + style="<?php echo esc_attr($value['css']); ?>" |
|
| 644 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 645 | 645 | /> <input class="give-upload-button button" type="button" data-fvalue="<?php echo $fvalue; ?>" data-field-type="<?php echo $value['type']; ?>" value="<?php echo $button_label; ?>"> |
| 646 | 646 | <?php echo $description ?> |
| 647 | 647 | <div class="give-image-thumb<?php echo ! $option_value || ! $is_show_preview ? ' give-hidden' : ''; ?>"> |
@@ -658,17 +658,17 @@ discard block |
||
| 658 | 658 | // WordPress Editor. |
| 659 | 659 | case 'wysiwyg' : |
| 660 | 660 | // Get option value. |
| 661 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 661 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 662 | 662 | |
| 663 | 663 | // Get editor settings. |
| 664 | - $editor_settings = ! empty( $value['options'] ) ? $value['options'] : array(); |
|
| 664 | + $editor_settings = ! empty($value['options']) ? $value['options'] : array(); |
|
| 665 | 665 | ?> |
| 666 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 666 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 667 | 667 | <th scope="row" class="titledesc"> |
| 668 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 668 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 669 | 669 | </th> |
| 670 | 670 | <td class="give-forminp"> |
| 671 | - <?php wp_editor( $option_value, $value['id'], $editor_settings ); ?> |
|
| 671 | + <?php wp_editor($option_value, $value['id'], $editor_settings); ?> |
|
| 672 | 672 | <?php echo $description; ?> |
| 673 | 673 | </td> |
| 674 | 674 | </tr><?php |
@@ -677,9 +677,9 @@ discard block |
||
| 677 | 677 | // Custom: System setting field. |
| 678 | 678 | case 'system_info' : |
| 679 | 679 | ?> |
| 680 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 680 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 681 | 681 | <th scope="row" class="titledesc"> |
| 682 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 682 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 683 | 683 | </th> |
| 684 | 684 | <td class="give-forminp"> |
| 685 | 685 | <?php give_system_info_callback(); ?> |
@@ -690,14 +690,14 @@ discard block |
||
| 690 | 690 | |
| 691 | 691 | // Custom: Default gateways setting field. |
| 692 | 692 | case 'default_gateway' : |
| 693 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 693 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 694 | 694 | ?> |
| 695 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 695 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 696 | 696 | <th scope="row" class="titledesc"> |
| 697 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 697 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 698 | 698 | </th> |
| 699 | 699 | <td class="give-forminp"> |
| 700 | - <?php give_default_gateway_callback( $value, $option_value ); ?> |
|
| 700 | + <?php give_default_gateway_callback($value, $option_value); ?> |
|
| 701 | 701 | <?php echo $description; ?> |
| 702 | 702 | </td> |
| 703 | 703 | </tr><?php |
@@ -705,14 +705,14 @@ discard block |
||
| 705 | 705 | |
| 706 | 706 | // Custom: Enable gateways setting field. |
| 707 | 707 | case 'enabled_gateways' : |
| 708 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 708 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 709 | 709 | ?> |
| 710 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 710 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 711 | 711 | <th scope="row" class="titledesc"> |
| 712 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 712 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 713 | 713 | </th> |
| 714 | 714 | <td class="give-forminp"> |
| 715 | - <?php give_enabled_gateways_callback( $value, $option_value ); ?> |
|
| 715 | + <?php give_enabled_gateways_callback($value, $option_value); ?> |
|
| 716 | 716 | <?php echo $description; ?> |
| 717 | 717 | </td> |
| 718 | 718 | </tr><?php |
@@ -721,9 +721,9 @@ discard block |
||
| 721 | 721 | // Custom: Email preview buttons field. |
| 722 | 722 | case 'email_preview_buttons' : |
| 723 | 723 | ?> |
| 724 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 724 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 725 | 725 | <th scope="row" class="titledesc"> |
| 726 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 726 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 727 | 727 | </th> |
| 728 | 728 | <td class="give-forminp"> |
| 729 | 729 | <?php give_email_preview_buttons_callback(); ?> |
@@ -740,22 +740,22 @@ discard block |
||
| 740 | 740 | |
| 741 | 741 | // Custom: Gateway API key. |
| 742 | 742 | case 'api_key' : |
| 743 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 744 | - $type = ! empty( $option_value ) ? 'password' : 'text'; |
|
| 743 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 744 | + $type = ! empty($option_value) ? 'password' : 'text'; |
|
| 745 | 745 | ?> |
| 746 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 746 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 747 | 747 | <th scope="row" class="titledesc"> |
| 748 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 748 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 749 | 749 | </th> |
| 750 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
| 750 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
| 751 | 751 | <input |
| 752 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 753 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 754 | - type="<?php echo esc_attr( $type ); ?>" |
|
| 755 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
| 756 | - value="<?php echo esc_attr( trim( $option_value ) ); ?>" |
|
| 757 | - class="give-input-field<?php echo( empty( $value['class'] ) ? '' : ' ' . esc_attr( $value['class'] ) ); ?>" |
|
| 758 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 752 | + name="<?php echo esc_attr($value['id']); ?>" |
|
| 753 | + id="<?php echo esc_attr($value['id']); ?>" |
|
| 754 | + type="<?php echo esc_attr($type); ?>" |
|
| 755 | + style="<?php echo esc_attr($value['css']); ?>" |
|
| 756 | + value="<?php echo esc_attr(trim($option_value)); ?>" |
|
| 757 | + class="give-input-field<?php echo(empty($value['class']) ? '' : ' '.esc_attr($value['class'])); ?>" |
|
| 758 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 759 | 759 | /> <?php echo $description; ?> |
| 760 | 760 | </td> |
| 761 | 761 | </tr><?php |
@@ -772,7 +772,7 @@ discard block |
||
| 772 | 772 | * |
| 773 | 773 | * @since 1.0 |
| 774 | 774 | */ |
| 775 | - do_action( "give_logs_view_{$current_section}" ); |
|
| 775 | + do_action("give_logs_view_{$current_section}"); |
|
| 776 | 776 | |
| 777 | 777 | echo $description; |
| 778 | 778 | break; |
@@ -780,7 +780,7 @@ discard block |
||
| 780 | 780 | // Custom: Data field. |
| 781 | 781 | case 'data' : |
| 782 | 782 | |
| 783 | - include GIVE_PLUGIN_DIR . 'includes/admin/tools/views/html-admin-page-data.php'; |
|
| 783 | + include GIVE_PLUGIN_DIR.'includes/admin/tools/views/html-admin-page-data.php'; |
|
| 784 | 784 | |
| 785 | 785 | echo $description; |
| 786 | 786 | break; |
@@ -788,12 +788,12 @@ discard block |
||
| 788 | 788 | // Custom: Give Docs Link field type. |
| 789 | 789 | case 'give_docs_link' : |
| 790 | 790 | ?> |
| 791 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 791 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 792 | 792 | <td class="give-docs-link" colspan="2"> |
| 793 | 793 | <?php |
| 794 | - echo '<p class="give-docs-link"><a href="' . esc_url( $value['url'] ) |
|
| 794 | + echo '<p class="give-docs-link"><a href="'.esc_url($value['url']) |
|
| 795 | 795 | . '" target="_blank">' |
| 796 | - . sprintf( esc_html__( 'Need Help? See docs on "%s"', 'give' ), $value['title'] ) |
|
| 796 | + . sprintf(esc_html__('Need Help? See docs on "%s"', 'give'), $value['title']) |
|
| 797 | 797 | . '<span class="dashicons dashicons-editor-help"></span></a></p>'; |
| 798 | 798 | ?> |
| 799 | 799 | </td> |
@@ -804,8 +804,8 @@ discard block |
||
| 804 | 804 | // You can add or handle your custom field action. |
| 805 | 805 | default: |
| 806 | 806 | // Get option value. |
| 807 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 808 | - do_action( 'give_admin_field_' . $value['type'], $value, $option_value ); |
|
| 807 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 808 | + do_action('give_admin_field_'.$value['type'], $value, $option_value); |
|
| 809 | 809 | break; |
| 810 | 810 | } |
| 811 | 811 | } |
@@ -821,15 +821,15 @@ discard block |
||
| 821 | 821 | * |
| 822 | 822 | * @return string The HTML description of the field. |
| 823 | 823 | */ |
| 824 | - public static function get_field_description( $value ) { |
|
| 824 | + public static function get_field_description($value) { |
|
| 825 | 825 | $description = ''; |
| 826 | 826 | |
| 827 | 827 | // Support for both 'description' and 'desc' args. |
| 828 | - $description_key = isset( $value['description'] ) ? 'description' : 'desc'; |
|
| 829 | - $value = ( isset( $value[ $description_key ] ) && ! empty( $value[ $description_key ] ) ) ? $value[ $description_key ] : ''; |
|
| 828 | + $description_key = isset($value['description']) ? 'description' : 'desc'; |
|
| 829 | + $value = (isset($value[$description_key]) && ! empty($value[$description_key])) ? $value[$description_key] : ''; |
|
| 830 | 830 | |
| 831 | - if ( ! empty( $value ) ) { |
|
| 832 | - $description = '<p class="give-field-description">' . wp_kses_post( $value ) . '</p>'; |
|
| 831 | + if ( ! empty($value)) { |
|
| 832 | + $description = '<p class="give-field-description">'.wp_kses_post($value).'</p>'; |
|
| 833 | 833 | } |
| 834 | 834 | |
| 835 | 835 | return $description; |
@@ -846,11 +846,11 @@ discard block |
||
| 846 | 846 | * |
| 847 | 847 | * @return array The description and tip as a 2 element array |
| 848 | 848 | */ |
| 849 | - public static function get_field_title( $value ) { |
|
| 850 | - $title = esc_html( $value['title'] ); |
|
| 849 | + public static function get_field_title($value) { |
|
| 850 | + $title = esc_html($value['title']); |
|
| 851 | 851 | |
| 852 | 852 | // If html tag detected then allow them to print. |
| 853 | - if ( strip_tags( $title ) ) { |
|
| 853 | + if (strip_tags($title)) { |
|
| 854 | 854 | $title = $value['title']; |
| 855 | 855 | } |
| 856 | 856 | |
@@ -869,8 +869,8 @@ discard block |
||
| 869 | 869 | * |
| 870 | 870 | * @return bool |
| 871 | 871 | */ |
| 872 | - public static function save_fields( $options, $option_name = '' ) { |
|
| 873 | - if ( empty( $_POST ) ) { |
|
| 872 | + public static function save_fields($options, $option_name = '') { |
|
| 873 | + if (empty($_POST)) { |
|
| 874 | 874 | return false; |
| 875 | 875 | } |
| 876 | 876 | |
@@ -878,37 +878,37 @@ discard block |
||
| 878 | 878 | $update_options = array(); |
| 879 | 879 | |
| 880 | 880 | // Loop options and get values to save. |
| 881 | - foreach ( $options as $option ) { |
|
| 882 | - if ( ! isset( $option['id'] ) || ! isset( $option['type'] ) ) { |
|
| 881 | + foreach ($options as $option) { |
|
| 882 | + if ( ! isset($option['id']) || ! isset($option['type'])) { |
|
| 883 | 883 | continue; |
| 884 | 884 | } |
| 885 | 885 | |
| 886 | 886 | // Get posted value. |
| 887 | - if ( strstr( $option['id'], '[' ) ) { |
|
| 888 | - parse_str( $option['id'], $option_name_array ); |
|
| 889 | - $field_option_name = current( array_keys( $option_name_array ) ); |
|
| 890 | - $setting_name = key( $option_name_array[ $field_option_name ] ); |
|
| 891 | - $raw_value = isset( $_POST[ $field_option_name ][ $setting_name ] ) ? wp_unslash( $_POST[ $field_option_name ][ $setting_name ] ) : null; |
|
| 887 | + if (strstr($option['id'], '[')) { |
|
| 888 | + parse_str($option['id'], $option_name_array); |
|
| 889 | + $field_option_name = current(array_keys($option_name_array)); |
|
| 890 | + $setting_name = key($option_name_array[$field_option_name]); |
|
| 891 | + $raw_value = isset($_POST[$field_option_name][$setting_name]) ? wp_unslash($_POST[$field_option_name][$setting_name]) : null; |
|
| 892 | 892 | } else { |
| 893 | 893 | $field_option_name = $option['id']; |
| 894 | 894 | $setting_name = ''; |
| 895 | - $raw_value = isset( $_POST[ $option['id'] ] ) ? wp_unslash( $_POST[ $option['id'] ] ) : null; |
|
| 895 | + $raw_value = isset($_POST[$option['id']]) ? wp_unslash($_POST[$option['id']]) : null; |
|
| 896 | 896 | } |
| 897 | 897 | |
| 898 | 898 | // Format the value based on option type. |
| 899 | - switch ( $option['type'] ) { |
|
| 899 | + switch ($option['type']) { |
|
| 900 | 900 | case 'checkbox' : |
| 901 | - $value = is_null( $raw_value ) ? '' : 'on'; |
|
| 901 | + $value = is_null($raw_value) ? '' : 'on'; |
|
| 902 | 902 | break; |
| 903 | 903 | case 'wysiwyg' : |
| 904 | 904 | case 'textarea' : |
| 905 | - $value = wp_kses_post( trim( $raw_value ) ); |
|
| 905 | + $value = wp_kses_post(trim($raw_value)); |
|
| 906 | 906 | break; |
| 907 | 907 | case 'multiselect' : |
| 908 | - $value = array_filter( array_map( 'give_clean', (array) $raw_value ) ); |
|
| 908 | + $value = array_filter(array_map('give_clean', (array) $raw_value)); |
|
| 909 | 909 | break; |
| 910 | 910 | default : |
| 911 | - $value = give_clean( $raw_value ); |
|
| 911 | + $value = give_clean($raw_value); |
|
| 912 | 912 | break; |
| 913 | 913 | } |
| 914 | 914 | |
@@ -917,37 +917,37 @@ discard block |
||
| 917 | 917 | * |
| 918 | 918 | * @since 1.8 |
| 919 | 919 | */ |
| 920 | - $value = apply_filters( 'give_admin_settings_sanitize_option', $value, $option, $raw_value ); |
|
| 920 | + $value = apply_filters('give_admin_settings_sanitize_option', $value, $option, $raw_value); |
|
| 921 | 921 | |
| 922 | 922 | /** |
| 923 | 923 | * Sanitize the value of an option by option name. |
| 924 | 924 | * |
| 925 | 925 | * @since 1.8 |
| 926 | 926 | */ |
| 927 | - $value = apply_filters( "give_admin_settings_sanitize_option_{$field_option_name}", $value, $option, $raw_value ); |
|
| 927 | + $value = apply_filters("give_admin_settings_sanitize_option_{$field_option_name}", $value, $option, $raw_value); |
|
| 928 | 928 | |
| 929 | - if ( is_null( $value ) ) { |
|
| 929 | + if (is_null($value)) { |
|
| 930 | 930 | continue; |
| 931 | 931 | } |
| 932 | 932 | |
| 933 | 933 | // Check if option is an array and handle that differently to single values. |
| 934 | - if ( $field_option_name && $setting_name ) { |
|
| 935 | - if ( ! isset( $update_options[ $field_option_name ] ) ) { |
|
| 936 | - $update_options[ $field_option_name ] = get_option( $field_option_name, array() ); |
|
| 934 | + if ($field_option_name && $setting_name) { |
|
| 935 | + if ( ! isset($update_options[$field_option_name])) { |
|
| 936 | + $update_options[$field_option_name] = get_option($field_option_name, array()); |
|
| 937 | 937 | } |
| 938 | - if ( ! is_array( $update_options[ $field_option_name ] ) ) { |
|
| 939 | - $update_options[ $field_option_name ] = array(); |
|
| 938 | + if ( ! is_array($update_options[$field_option_name])) { |
|
| 939 | + $update_options[$field_option_name] = array(); |
|
| 940 | 940 | } |
| 941 | - $update_options[ $field_option_name ][ $setting_name ] = $value; |
|
| 941 | + $update_options[$field_option_name][$setting_name] = $value; |
|
| 942 | 942 | } else { |
| 943 | - $update_options[ $field_option_name ] = $value; |
|
| 943 | + $update_options[$field_option_name] = $value; |
|
| 944 | 944 | } |
| 945 | 945 | } |
| 946 | 946 | |
| 947 | 947 | // Save all options in our array or there own option name i.e. option id. |
| 948 | - if ( empty( $option_name ) ) { |
|
| 949 | - foreach ( $update_options as $name => $value ) { |
|
| 950 | - update_option( $name, $value ); |
|
| 948 | + if (empty($option_name)) { |
|
| 949 | + foreach ($update_options as $name => $value) { |
|
| 950 | + update_option($name, $value); |
|
| 951 | 951 | |
| 952 | 952 | /** |
| 953 | 953 | * Trigger action. |
@@ -956,13 +956,13 @@ discard block |
||
| 956 | 956 | * |
| 957 | 957 | * @since 1.8 |
| 958 | 958 | */ |
| 959 | - do_action( "give_save_option_{$name}", $value, $name ); |
|
| 959 | + do_action("give_save_option_{$name}", $value, $name); |
|
| 960 | 960 | } |
| 961 | 961 | } else { |
| 962 | - $old_options = ( $old_options = get_option( $option_name ) ) ? $old_options : array(); |
|
| 963 | - $update_options = array_merge( $old_options, $update_options ); |
|
| 962 | + $old_options = ($old_options = get_option($option_name)) ? $old_options : array(); |
|
| 963 | + $update_options = array_merge($old_options, $update_options); |
|
| 964 | 964 | |
| 965 | - update_option( $option_name, $update_options ); |
|
| 965 | + update_option($option_name, $update_options); |
|
| 966 | 966 | |
| 967 | 967 | /** |
| 968 | 968 | * Trigger action. |
@@ -971,7 +971,7 @@ discard block |
||
| 971 | 971 | * |
| 972 | 972 | * @since 1.8 |
| 973 | 973 | */ |
| 974 | - do_action( "give_save_settings_{$option_name}", $update_options, $option_name ); |
|
| 974 | + do_action("give_save_settings_{$option_name}", $update_options, $option_name); |
|
| 975 | 975 | } |
| 976 | 976 | |
| 977 | 977 | return true; |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -23,19 +23,19 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @return array An array of updated action links. |
| 25 | 25 | */ |
| 26 | -function give_plugin_action_links( $actions ) { |
|
| 26 | +function give_plugin_action_links($actions) { |
|
| 27 | 27 | $new_actions = array( |
| 28 | 28 | 'settings' => sprintf( |
| 29 | 29 | '<a href="%1$s">%2$s</a>', |
| 30 | - admin_url( 'edit.php?post_type=give_forms&page=give-settings' ), |
|
| 31 | - __( 'Settings', 'give' ) |
|
| 30 | + admin_url('edit.php?post_type=give_forms&page=give-settings'), |
|
| 31 | + __('Settings', 'give') |
|
| 32 | 32 | ), |
| 33 | 33 | ); |
| 34 | 34 | |
| 35 | - return array_merge( $new_actions, $actions ); |
|
| 35 | + return array_merge($new_actions, $actions); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | -add_filter( 'plugin_action_links_' . GIVE_PLUGIN_BASENAME, 'give_plugin_action_links' ); |
|
| 38 | +add_filter('plugin_action_links_'.GIVE_PLUGIN_BASENAME, 'give_plugin_action_links'); |
|
| 39 | 39 | |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -48,38 +48,38 @@ discard block |
||
| 48 | 48 | * |
| 49 | 49 | * @return array |
| 50 | 50 | */ |
| 51 | -function give_plugin_row_meta( $plugin_meta, $plugin_file ) { |
|
| 52 | - if ( $plugin_file != GIVE_PLUGIN_BASENAME ) { |
|
| 51 | +function give_plugin_row_meta($plugin_meta, $plugin_file) { |
|
| 52 | + if ($plugin_file != GIVE_PLUGIN_BASENAME) { |
|
| 53 | 53 | return $plugin_meta; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | $new_meta_links = array( |
| 57 | 57 | sprintf( |
| 58 | 58 | '<a href="%1$s" target="_blank">%2$s</a>', |
| 59 | - esc_url( add_query_arg( array( |
|
| 59 | + esc_url(add_query_arg(array( |
|
| 60 | 60 | 'utm_source' => 'plugins-page', |
| 61 | 61 | 'utm_medium' => 'plugin-row', |
| 62 | 62 | 'utm_campaign' => 'admin', |
| 63 | - ), 'https://givewp.com/documentation/' ) |
|
| 63 | + ), 'https://givewp.com/documentation/') |
|
| 64 | 64 | ), |
| 65 | - __( 'Documentation', 'give' ) |
|
| 65 | + __('Documentation', 'give') |
|
| 66 | 66 | ), |
| 67 | 67 | sprintf( |
| 68 | 68 | '<a href="%1$s" target="_blank">%2$s</a>', |
| 69 | - esc_url( add_query_arg( array( |
|
| 69 | + esc_url(add_query_arg(array( |
|
| 70 | 70 | 'utm_source' => 'plugins-page', |
| 71 | 71 | 'utm_medium' => 'plugin-row', |
| 72 | 72 | 'utm_campaign' => 'admin', |
| 73 | - ), 'https://givewp.com/addons/' ) |
|
| 73 | + ), 'https://givewp.com/addons/') |
|
| 74 | 74 | ), |
| 75 | - __( 'Add-ons', 'give' ) |
|
| 75 | + __('Add-ons', 'give') |
|
| 76 | 76 | ), |
| 77 | 77 | ); |
| 78 | 78 | |
| 79 | - return array_merge( $plugin_meta, $new_meta_links ); |
|
| 79 | + return array_merge($plugin_meta, $new_meta_links); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | -add_filter( 'plugin_row_meta', 'give_plugin_row_meta', 10, 2 ); |
|
| 82 | +add_filter('plugin_row_meta', 'give_plugin_row_meta', 10, 2); |
|
| 83 | 83 | |
| 84 | 84 | |
| 85 | 85 | /** |
@@ -97,19 +97,18 @@ discard block |
||
| 97 | 97 | $title = ''; |
| 98 | 98 | global $submenu, $plugin_page; |
| 99 | 99 | |
| 100 | - foreach ( array_keys( $submenu ) as $parent ) { |
|
| 101 | - if( 'edit.php?post_type=give_forms' !== $parent ) { |
|
| 100 | + foreach (array_keys($submenu) as $parent) { |
|
| 101 | + if ('edit.php?post_type=give_forms' !== $parent) { |
|
| 102 | 102 | continue; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - foreach ( $submenu[ $parent ] as $submenu_array ) { |
|
| 106 | - if( $plugin_page !== $submenu_array[2] ){ |
|
| 105 | + foreach ($submenu[$parent] as $submenu_array) { |
|
| 106 | + if ($plugin_page !== $submenu_array[2]) { |
|
| 107 | 107 | continue; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - $title = isset( $submenu_array[0] ) ? |
|
| 111 | - $submenu_array[0] : |
|
| 112 | - $submenu_array[3]; |
|
| 110 | + $title = isset($submenu_array[0]) ? |
|
| 111 | + $submenu_array[0] : $submenu_array[3]; |
|
| 113 | 112 | } |
| 114 | 113 | } |
| 115 | 114 | |
@@ -9,11 +9,11 @@ discard block |
||
| 9 | 9 | * @since 1.8 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 12 | +if ( ! defined('ABSPATH')) { |
|
| 13 | 13 | exit; // Exit if accessed directly |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | -if ( ! class_exists( 'Give_Settings_License' ) ) : |
|
| 16 | +if ( ! class_exists('Give_Settings_License')) : |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Give_Settings_License. |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | */ |
| 28 | 28 | public function __construct() { |
| 29 | 29 | $this->id = 'licenses'; |
| 30 | - $this->label = esc_html__( 'Licenses', 'give' ); |
|
| 30 | + $this->label = esc_html__('Licenses', 'give'); |
|
| 31 | 31 | |
| 32 | 32 | parent::__construct(); |
| 33 | 33 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * Filter the licenses settings. |
| 46 | 46 | * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8 |
| 47 | 47 | */ |
| 48 | - $settings = apply_filters( 'give_settings_licenses', $settings ); |
|
| 48 | + $settings = apply_filters('give_settings_licenses', $settings); |
|
| 49 | 49 | |
| 50 | 50 | /** |
| 51 | 51 | * Filter the settings. |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * |
| 55 | 55 | * @param array $settings |
| 56 | 56 | */ |
| 57 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
|
| 57 | + $settings = apply_filters('give_get_settings_'.$this->id, $settings); |
|
| 58 | 58 | |
| 59 | 59 | // Output. |
| 60 | 60 | return $settings; |