@@ -358,9 +358,9 @@ |
||
| 358 | 358 | require_once GIVE_PLUGIN_DIR . 'includes/emails/template.php'; |
| 359 | 359 | require_once GIVE_PLUGIN_DIR . 'includes/emails/actions.php'; |
| 360 | 360 | |
| 361 | - if( defined( 'WP_CLI' ) && WP_CLI ) {
|
|
| 362 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-cli-commands.php'; |
|
| 363 | - } |
|
| 361 | + if( defined( 'WP_CLI' ) && WP_CLI ) {
|
|
| 362 | + require_once GIVE_PLUGIN_DIR . 'includes/class-give-cli-commands.php'; |
|
| 363 | + } |
|
| 364 | 364 | |
| 365 | 365 | if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
|
| 366 | 366 | |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * @return mixed |
| 24 | 24 | */ |
| 25 | 25 | function give_get_price_decimals() { |
| 26 | - return apply_filters( 'give_sanitize_amount_decimals', give_get_option( 'number_decimals', 0 ) ); |
|
| 26 | + return apply_filters( 'give_sanitize_amount_decimals', give_get_option( 'number_decimals', 0 ) ); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * @return mixed |
| 35 | 35 | */ |
| 36 | 36 | function give_get_price_thousand_separator() { |
| 37 | - return give_get_option( 'thousands_separator', ',' ); |
|
| 37 | + return give_get_option( 'thousands_separator', ',' ); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * @return mixed |
| 46 | 46 | */ |
| 47 | 47 | function give_get_price_decimal_separator() { |
| 48 | - return give_get_option( 'decimal_separator', '.' ); |
|
| 48 | + return give_get_option( 'decimal_separator', '.' ); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
@@ -64,58 +64,58 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | function give_sanitize_amount( $number, $dp = false, $trim_zeros = false ) { |
| 66 | 66 | |
| 67 | - // Bailout. |
|
| 68 | - if( empty( $number ) ) { |
|
| 69 | - return $number; |
|
| 70 | - } |
|
| 67 | + // Bailout. |
|
| 68 | + if( empty( $number ) ) { |
|
| 69 | + return $number; |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - $thousand_separator = give_get_price_thousand_separator(); |
|
| 72 | + $thousand_separator = give_get_price_thousand_separator(); |
|
| 73 | 73 | |
| 74 | - $locale = localeconv(); |
|
| 75 | - $decimals = array( give_get_price_decimal_separator(), $locale['decimal_point'], $locale['mon_decimal_point'] ); |
|
| 74 | + $locale = localeconv(); |
|
| 75 | + $decimals = array( give_get_price_decimal_separator(), $locale['decimal_point'], $locale['mon_decimal_point'] ); |
|
| 76 | 76 | |
| 77 | - // Remove locale from string |
|
| 78 | - if ( ! is_float( $number ) ) { |
|
| 79 | - $number = str_replace( $decimals, '.', $number ); |
|
| 80 | - } |
|
| 77 | + // Remove locale from string |
|
| 78 | + if ( ! is_float( $number ) ) { |
|
| 79 | + $number = str_replace( $decimals, '.', $number ); |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - // Remove thousand amount formatting if amount has. |
|
| 83 | - // This condition use to add backward compatibility to version before 1.6, because before version 1.6 we were saving formatted amount to db. |
|
| 84 | - // Do not replace thousand separator from price if it is same as decimal separator, because it will be already replace by above code. |
|
| 85 | - if( ! in_array( $thousand_separator, $decimals ) && ( false !== strpos( $number, $thousand_separator ) ) ) { |
|
| 86 | - $number = str_replace( $thousand_separator, '', $number ); |
|
| 87 | - } |
|
| 82 | + // Remove thousand amount formatting if amount has. |
|
| 83 | + // This condition use to add backward compatibility to version before 1.6, because before version 1.6 we were saving formatted amount to db. |
|
| 84 | + // Do not replace thousand separator from price if it is same as decimal separator, because it will be already replace by above code. |
|
| 85 | + if( ! in_array( $thousand_separator, $decimals ) && ( false !== strpos( $number, $thousand_separator ) ) ) { |
|
| 86 | + $number = str_replace( $thousand_separator, '', $number ); |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - // Remove non numeric entity before decimal separator. |
|
| 90 | - $number = preg_replace( '/[^0-9\.]/', '', $number ); |
|
| 91 | - $default_dp = give_get_price_decimals(); |
|
| 89 | + // Remove non numeric entity before decimal separator. |
|
| 90 | + $number = preg_replace( '/[^0-9\.]/', '', $number ); |
|
| 91 | + $default_dp = give_get_price_decimals(); |
|
| 92 | 92 | |
| 93 | - // Format number of decimals in number. |
|
| 94 | - if( false !== $dp ) { |
|
| 95 | - $dp = intval( empty( $dp ) ? $default_dp : $dp ); |
|
| 96 | - $dp = apply_filters( 'give_sanitize_amount_decimals', $dp, $number ); |
|
| 97 | - $number = number_format( floatval( $number ), $dp, '.', '' ); |
|
| 98 | - } |
|
| 93 | + // Format number of decimals in number. |
|
| 94 | + if( false !== $dp ) { |
|
| 95 | + $dp = intval( empty( $dp ) ? $default_dp : $dp ); |
|
| 96 | + $dp = apply_filters( 'give_sanitize_amount_decimals', $dp, $number ); |
|
| 97 | + $number = number_format( floatval( $number ), $dp, '.', '' ); |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - // Reset negative amount to zero. |
|
| 100 | + // Reset negative amount to zero. |
|
| 101 | 101 | if ( 0 > $number ) { |
| 102 | 102 | $number = number_format( 0, $default_dp, '.' ); |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - // If number does not have decimal then add number of decimals to it. |
|
| 106 | - if( |
|
| 107 | - false === strpos( $number, '.' ) |
|
| 108 | - || ( $default_dp > strlen( substr( $number, strpos( $number , '.' ) + 1 ) ) ) |
|
| 109 | - ) { |
|
| 110 | - $number = number_format( $number, $default_dp, '.', '' ); |
|
| 111 | - } |
|
| 105 | + // If number does not have decimal then add number of decimals to it. |
|
| 106 | + if( |
|
| 107 | + false === strpos( $number, '.' ) |
|
| 108 | + || ( $default_dp > strlen( substr( $number, strpos( $number , '.' ) + 1 ) ) ) |
|
| 109 | + ) { |
|
| 110 | + $number = number_format( $number, $default_dp, '.', '' ); |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - // Trim zeros. |
|
| 114 | - if ( $trim_zeros && strstr( $number, '.' ) ) { |
|
| 115 | - $number = rtrim( rtrim( $number, '0' ), '.' ); |
|
| 116 | - } |
|
| 113 | + // Trim zeros. |
|
| 114 | + if ( $trim_zeros && strstr( $number, '.' ) ) { |
|
| 115 | + $number = rtrim( rtrim( $number, '0' ), '.' ); |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | - return apply_filters( 'give_sanitize_amount', $number ); |
|
| 118 | + return apply_filters( 'give_sanitize_amount', $number ); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | /** |
@@ -186,42 +186,42 @@ discard block |
||
| 186 | 186 | */ |
| 187 | 187 | function give_human_format_large_amount( $amount ) { |
| 188 | 188 | |
| 189 | - // Get thousand separator. |
|
| 190 | - $thousands_sep = give_get_price_thousand_separator(); |
|
| 189 | + // Get thousand separator. |
|
| 190 | + $thousands_sep = give_get_price_thousand_separator(); |
|
| 191 | 191 | |
| 192 | - // Sanitize amount. |
|
| 193 | - $sanitize_amount = give_sanitize_amount( $amount ); |
|
| 192 | + // Sanitize amount. |
|
| 193 | + $sanitize_amount = give_sanitize_amount( $amount ); |
|
| 194 | 194 | |
| 195 | - // Explode amount to calculate name of large numbers. |
|
| 195 | + // Explode amount to calculate name of large numbers. |
|
| 196 | 196 | $amount_array = explode( $thousands_sep, $amount ); |
| 197 | 197 | |
| 198 | - // Calculate amount parts count. |
|
| 199 | - $amount_count_parts = count( $amount_array ); |
|
| 198 | + // Calculate amount parts count. |
|
| 199 | + $amount_count_parts = count( $amount_array ); |
|
| 200 | 200 | |
| 201 | - // Calculate large number formatted amount. |
|
| 202 | - if ( 4 < $amount_count_parts ){ |
|
| 203 | - $sanitize_amount = sprintf( |
|
| 201 | + // Calculate large number formatted amount. |
|
| 202 | + if ( 4 < $amount_count_parts ){ |
|
| 203 | + $sanitize_amount = sprintf( |
|
| 204 | 204 | /* translators: %s: number */ |
| 205 | 205 | esc_html__( '%s trillion', 'give' ), |
| 206 | 206 | round( ( $sanitize_amount / 1000000000000 ), 2 ) |
| 207 | 207 | ); |
| 208 | - } elseif ( 3 < $amount_count_parts ){ |
|
| 209 | - $sanitize_amount = sprintf( |
|
| 208 | + } elseif ( 3 < $amount_count_parts ){ |
|
| 209 | + $sanitize_amount = sprintf( |
|
| 210 | 210 | /* translators: %s: number */ |
| 211 | 211 | esc_html__( '%s billion', 'give' ), |
| 212 | 212 | round( ( $sanitize_amount / 1000000000 ), 2 ) |
| 213 | 213 | ); |
| 214 | - } elseif ( 2 < $amount_count_parts ) { |
|
| 215 | - $sanitize_amount = sprintf( |
|
| 214 | + } elseif ( 2 < $amount_count_parts ) { |
|
| 215 | + $sanitize_amount = sprintf( |
|
| 216 | 216 | /* translators: %s: number */ |
| 217 | 217 | esc_html__( '%s million', 'give' ), |
| 218 | 218 | round( ( $sanitize_amount / 1000000 ), 2 ) |
| 219 | 219 | ); |
| 220 | - } else{ |
|
| 221 | - $sanitize_amount = give_format_amount( $amount ); |
|
| 222 | - } |
|
| 220 | + } else{ |
|
| 221 | + $sanitize_amount = give_format_amount( $amount ); |
|
| 222 | + } |
|
| 223 | 223 | |
| 224 | - return apply_filters( 'give_human_format_large_amount', $sanitize_amount, $amount ); |
|
| 224 | + return apply_filters( 'give_human_format_large_amount', $sanitize_amount, $amount ); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | /** |
@@ -235,14 +235,14 @@ discard block |
||
| 235 | 235 | * @return string $amount Newly formatted amount or Price Not Available |
| 236 | 236 | */ |
| 237 | 237 | function give_format_decimal( $amount, $dp = false ){ |
| 238 | - $decimal_separator = give_get_price_decimal_separator(); |
|
| 239 | - $formatted_amount = give_sanitize_amount( $amount, $dp ); |
|
| 238 | + $decimal_separator = give_get_price_decimal_separator(); |
|
| 239 | + $formatted_amount = give_sanitize_amount( $amount, $dp ); |
|
| 240 | 240 | |
| 241 | - if( false !== strpos( $formatted_amount, '.' ) ) { |
|
| 242 | - $formatted_amount = str_replace( '.', $decimal_separator, $formatted_amount ); |
|
| 243 | - } |
|
| 241 | + if( false !== strpos( $formatted_amount, '.' ) ) { |
|
| 242 | + $formatted_amount = str_replace( '.', $decimal_separator, $formatted_amount ); |
|
| 243 | + } |
|
| 244 | 244 | |
| 245 | - return apply_filters( 'give_format_decimal', $formatted_amount, $amount, $decimal_separator ); |
|
| 245 | + return apply_filters( 'give_format_decimal', $formatted_amount, $amount, $decimal_separator ); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | |
@@ -286,66 +286,66 @@ discard block |
||
| 286 | 286 | $negative = $price < 0; |
| 287 | 287 | |
| 288 | 288 | if ( $negative ) { |
| 289 | - // Remove proceeding "-". |
|
| 289 | + // Remove proceeding "-". |
|
| 290 | 290 | $price = substr( $price, 1 ); |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | $symbol = give_currency_symbol( $currency ); |
| 294 | 294 | |
| 295 | - switch ( $currency ): |
|
| 296 | - case 'GBP' : |
|
| 297 | - case 'BRL' : |
|
| 298 | - case 'EUR' : |
|
| 299 | - case 'USD' : |
|
| 300 | - case 'AUD' : |
|
| 301 | - case 'CAD' : |
|
| 302 | - case 'HKD' : |
|
| 303 | - case 'MXN' : |
|
| 304 | - case 'NZD' : |
|
| 305 | - case 'SGD' : |
|
| 306 | - case 'JPY' : |
|
| 307 | - case 'THB' : |
|
| 308 | - case 'INR' : |
|
| 309 | - case 'RIAL' : |
|
| 310 | - case 'TRY' : |
|
| 311 | - case 'RUB' : |
|
| 312 | - case 'SEK' : |
|
| 313 | - case 'PLN' : |
|
| 314 | - case 'PHP' : |
|
| 315 | - case 'TWD' : |
|
| 316 | - case 'MYR' : |
|
| 317 | - case 'CZK' : |
|
| 318 | - case 'DKK' : |
|
| 319 | - case 'HUF' : |
|
| 320 | - case 'ILS' : |
|
| 321 | - case 'MAD' : |
|
| 322 | - case 'KRW' : |
|
| 323 | - case 'ZAR' : |
|
| 324 | - $formatted = ( 'before' === $position ? $symbol . $price : $price . $symbol ); |
|
| 325 | - break; |
|
| 326 | - case 'NOK' : |
|
| 327 | - $formatted = ( 'before' === $position ? $symbol . ' ' . $price : $price . ' ' . $symbol ); |
|
| 328 | - break; |
|
| 329 | - default : |
|
| 330 | - $formatted = ( 'before' === $position ? $currency . ' ' . $price : $price . ' ' . $currency ); |
|
| 331 | - break; |
|
| 332 | - endswitch; |
|
| 333 | - |
|
| 334 | - /** |
|
| 335 | - * Filter formatted amount with currency |
|
| 336 | - * |
|
| 337 | - * Filter name depends upon current value of currency and currency position. |
|
| 338 | - * For example : |
|
| 339 | - * if currency is USD and currency position is before then |
|
| 340 | - * filter name will be give_usd_currency_filter_before |
|
| 341 | - * |
|
| 342 | - * and if currency is USD and currency position is after then |
|
| 343 | - * filter name will be give_usd_currency_filter_after |
|
| 344 | - * |
|
| 345 | - */ |
|
| 346 | - $formatted = apply_filters( 'give_' . strtolower( $currency ) . "_currency_filter_{$position}", $formatted, $currency, $price ); |
|
| 347 | - |
|
| 348 | - if ( $negative ) { |
|
| 295 | + switch ( $currency ): |
|
| 296 | + case 'GBP' : |
|
| 297 | + case 'BRL' : |
|
| 298 | + case 'EUR' : |
|
| 299 | + case 'USD' : |
|
| 300 | + case 'AUD' : |
|
| 301 | + case 'CAD' : |
|
| 302 | + case 'HKD' : |
|
| 303 | + case 'MXN' : |
|
| 304 | + case 'NZD' : |
|
| 305 | + case 'SGD' : |
|
| 306 | + case 'JPY' : |
|
| 307 | + case 'THB' : |
|
| 308 | + case 'INR' : |
|
| 309 | + case 'RIAL' : |
|
| 310 | + case 'TRY' : |
|
| 311 | + case 'RUB' : |
|
| 312 | + case 'SEK' : |
|
| 313 | + case 'PLN' : |
|
| 314 | + case 'PHP' : |
|
| 315 | + case 'TWD' : |
|
| 316 | + case 'MYR' : |
|
| 317 | + case 'CZK' : |
|
| 318 | + case 'DKK' : |
|
| 319 | + case 'HUF' : |
|
| 320 | + case 'ILS' : |
|
| 321 | + case 'MAD' : |
|
| 322 | + case 'KRW' : |
|
| 323 | + case 'ZAR' : |
|
| 324 | + $formatted = ( 'before' === $position ? $symbol . $price : $price . $symbol ); |
|
| 325 | + break; |
|
| 326 | + case 'NOK' : |
|
| 327 | + $formatted = ( 'before' === $position ? $symbol . ' ' . $price : $price . ' ' . $symbol ); |
|
| 328 | + break; |
|
| 329 | + default : |
|
| 330 | + $formatted = ( 'before' === $position ? $currency . ' ' . $price : $price . ' ' . $currency ); |
|
| 331 | + break; |
|
| 332 | + endswitch; |
|
| 333 | + |
|
| 334 | + /** |
|
| 335 | + * Filter formatted amount with currency |
|
| 336 | + * |
|
| 337 | + * Filter name depends upon current value of currency and currency position. |
|
| 338 | + * For example : |
|
| 339 | + * if currency is USD and currency position is before then |
|
| 340 | + * filter name will be give_usd_currency_filter_before |
|
| 341 | + * |
|
| 342 | + * and if currency is USD and currency position is after then |
|
| 343 | + * filter name will be give_usd_currency_filter_after |
|
| 344 | + * |
|
| 345 | + */ |
|
| 346 | + $formatted = apply_filters( 'give_' . strtolower( $currency ) . "_currency_filter_{$position}", $formatted, $currency, $price ); |
|
| 347 | + |
|
| 348 | + if ( $negative ) { |
|
| 349 | 349 | // Prepend the minus sign before the currency sign. |
| 350 | 350 | $formatted = '-' . $formatted; |
| 351 | 351 | } |
@@ -363,18 +363,18 @@ discard block |
||
| 363 | 363 | */ |
| 364 | 364 | function give_currency_decimal_filter() { |
| 365 | 365 | |
| 366 | - remove_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
| 366 | + remove_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
| 367 | 367 | |
| 368 | - // Set default number of decimals. |
|
| 369 | - $decimals = give_get_price_decimals(); |
|
| 368 | + // Set default number of decimals. |
|
| 369 | + $decimals = give_get_price_decimals(); |
|
| 370 | 370 | |
| 371 | - add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
| 371 | + add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
| 372 | 372 | |
| 373 | 373 | |
| 374 | - // Get number of decimals with backward compatibility ( version < 1.6 ) |
|
| 375 | - if( 1 <= func_num_args() ){ |
|
| 376 | - $decimals = ( false === func_get_arg( 0 ) ? $decimals : absint( func_get_arg( 0 ) ) ); |
|
| 377 | - } |
|
| 374 | + // Get number of decimals with backward compatibility ( version < 1.6 ) |
|
| 375 | + if( 1 <= func_num_args() ){ |
|
| 376 | + $decimals = ( false === func_get_arg( 0 ) ? $decimals : absint( func_get_arg( 0 ) ) ); |
|
| 377 | + } |
|
| 378 | 378 | |
| 379 | 379 | $currency = give_get_currency(); |
| 380 | 380 | |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | * @return mixed |
| 407 | 407 | */ |
| 408 | 408 | function give_sanitize_thousand_separator( $value, $field_args, $field ){ |
| 409 | - return $value; |
|
| 409 | + return $value; |
|
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | |
@@ -437,5 +437,5 @@ discard block |
||
| 437 | 437 | * @return mixed |
| 438 | 438 | */ |
| 439 | 439 | function give_sanitize_price_field_value( $value, $field_args, $field ){ |
| 440 | - return give_sanitize_amount( $value ); |
|
| 440 | + return give_sanitize_amount( $value ); |
|
| 441 | 441 | } |
| 442 | 442 | \ No newline at end of file |
@@ -267,10 +267,10 @@ |
||
| 267 | 267 | 'donation' => esc_html__( 'Donation', 'give' ), |
| 268 | 268 | 'donation_form' => esc_html__( 'Donation Form', 'give' ), |
| 269 | 269 | 'status' => esc_html__( 'Status', 'give' ), |
| 270 | - 'date' => esc_html__( 'Date', 'give' ), |
|
| 271 | - 'amount' => esc_html__( 'Amount', 'give' ), |
|
| 272 | - 'details' => esc_html__( 'Details', 'give' ), |
|
| 273 | - ); |
|
| 270 | + 'date' => esc_html__( 'Date', 'give' ), |
|
| 271 | + 'amount' => esc_html__( 'Amount', 'give' ), |
|
| 272 | + 'details' => esc_html__( 'Details', 'give' ), |
|
| 273 | + ); |
|
| 274 | 274 | |
| 275 | 275 | return apply_filters( 'give_payments_table_columns', $columns ); |
| 276 | 276 | } |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | * @subcommand donors |
| 327 | 327 | */ |
| 328 | 328 | public function donors( $args, $assoc_args ) { |
| 329 | - global $wp_query; |
|
| 329 | + global $wp_query; |
|
| 330 | 330 | $donor_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? absint( $assoc_args['id'] ) : false; |
| 331 | 331 | $email = isset( $assoc_args ) && array_key_exists( 'email', $assoc_args ) ? $assoc_args['email'] : false; |
| 332 | 332 | $name = isset( $assoc_args ) && array_key_exists( 'name', $assoc_args ) ? $assoc_args['name'] : ''; |
@@ -492,7 +492,7 @@ discard block |
||
| 492 | 492 | * @subcommand donations |
| 493 | 493 | */ |
| 494 | 494 | public function donations( $args, $assoc_args ) { |
| 495 | - global $wp_query; |
|
| 495 | + global $wp_query; |
|
| 496 | 496 | $number = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? $assoc_args['number'] : 10; |
| 497 | 497 | |
| 498 | 498 | // Cache previous number query var. |
@@ -716,9 +716,9 @@ discard block |
||
| 716 | 716 | * @return mixed |
| 717 | 717 | */ |
| 718 | 718 | private function color_message( $heading, $message = '', $colon = true, $color = 'g' ) { |
| 719 | - // Add colon. |
|
| 720 | - if ( $colon ) { |
|
| 721 | - $heading = $heading . ': '; |
|
| 719 | + // Add colon. |
|
| 720 | + if ( $colon ) { |
|
| 721 | + $heading = $heading . ': '; |
|
| 722 | 722 | } |
| 723 | 723 | return WP_CLI::colorize( "%{$color}" . $heading . '%n' ) . $message; |
| 724 | 724 | } |
@@ -45,22 +45,22 @@ discard block |
||
| 45 | 45 | * @param string $default_path Default path. Default is empty. |
| 46 | 46 | */ |
| 47 | 47 | function give_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
| 48 | - if ( ! empty( $args ) && is_array( $args ) ) { |
|
| 49 | - extract( $args ); |
|
| 50 | - } |
|
| 48 | + if ( ! empty( $args ) && is_array( $args ) ) { |
|
| 49 | + extract( $args ); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - $template_names = array( $template_name . '.php' ); |
|
| 52 | + $template_names = array( $template_name . '.php' ); |
|
| 53 | 53 | |
| 54 | - $located = give_locate_template( $template_names, $template_path, $default_path ); |
|
| 54 | + $located = give_locate_template( $template_names, $template_path, $default_path ); |
|
| 55 | 55 | |
| 56 | - if ( ! file_exists( $located ) ) { |
|
| 56 | + if ( ! file_exists( $located ) ) { |
|
| 57 | 57 | /* translators: %s: the template */ |
| 58 | - give_output_error( sprintf( __( 'The %s template was not found.', 'give' ), $located ), true ); |
|
| 59 | - return; |
|
| 60 | - } |
|
| 58 | + give_output_error( sprintf( __( 'The %s template was not found.', 'give' ), $located ), true ); |
|
| 59 | + return; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - // Allow 3rd party plugin filter template file from their plugin. |
|
| 63 | - $located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
| 62 | + // Allow 3rd party plugin filter template file from their plugin. |
|
| 63 | + $located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
| 64 | 64 | |
| 65 | 65 | /** |
| 66 | 66 | * Fires in give template, before the file is included. |
@@ -74,9 +74,9 @@ discard block |
||
| 74 | 74 | * @param string $located Template file filter by 3rd party plugin. |
| 75 | 75 | * @param array $args Passed arguments. |
| 76 | 76 | */ |
| 77 | - do_action( 'give_before_template_part', $template_name, $template_path, $located, $args ); |
|
| 77 | + do_action( 'give_before_template_part', $template_name, $template_path, $located, $args ); |
|
| 78 | 78 | |
| 79 | - include( $located ); |
|
| 79 | + include( $located ); |
|
| 80 | 80 | |
| 81 | 81 | /** |
| 82 | 82 | * Fires in give template, after the file is included. |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * @param string $located Template file filter by 3rd party plugin. |
| 91 | 91 | * @param array $args Passed arguments. |
| 92 | 92 | */ |
| 93 | - do_action( 'give_after_template_part', $template_name, $template_path, $located, $args ); |
|
| 93 | + do_action( 'give_after_template_part', $template_name, $template_path, $located, $args ); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -33,20 +33,20 @@ discard block |
||
| 33 | 33 | $login_redirect = add_query_arg('give-login-success', 'true', give_get_current_page_url()); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - if ( empty( $logout_redirect ) ) { |
|
| 37 | - $logout_redirect = add_query_arg( 'give-logout-success', 'true', give_get_current_page_url() ); |
|
| 38 | - } |
|
| 36 | + if ( empty( $logout_redirect ) ) { |
|
| 37 | + $logout_redirect = add_query_arg( 'give-logout-success', 'true', give_get_current_page_url() ); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | 40 | |
| 41 | - // Add user_logout action to logout url. |
|
| 42 | - $logout_redirect = add_query_arg( |
|
| 43 | - array( |
|
| 44 | - 'give_action' => 'user_logout', |
|
| 45 | - 'give_logout_nonce' => wp_create_nonce( 'give-logout-nonce' ), |
|
| 46 | - 'give_logout_redirect' => urlencode( $logout_redirect ) |
|
| 47 | - ), |
|
| 48 | - home_url('/') |
|
| 49 | - ); |
|
| 41 | + // Add user_logout action to logout url. |
|
| 42 | + $logout_redirect = add_query_arg( |
|
| 43 | + array( |
|
| 44 | + 'give_action' => 'user_logout', |
|
| 45 | + 'give_logout_nonce' => wp_create_nonce( 'give-logout-nonce' ), |
|
| 46 | + 'give_logout_redirect' => urlencode( $logout_redirect ) |
|
| 47 | + ), |
|
| 48 | + home_url('/') |
|
| 49 | + ); |
|
| 50 | 50 | |
| 51 | 51 | $give_login_redirect = $login_redirect; |
| 52 | 52 | $give_logout_redirect = $logout_redirect; |
@@ -136,31 +136,31 @@ discard block |
||
| 136 | 136 | * @return void |
| 137 | 137 | */ |
| 138 | 138 | function give_process_user_logout( $data ) { |
| 139 | - if ( wp_verify_nonce( $data['give_logout_nonce'], 'give-logout-nonce' ) && is_user_logged_in() ) { |
|
| 139 | + if ( wp_verify_nonce( $data['give_logout_nonce'], 'give-logout-nonce' ) && is_user_logged_in() ) { |
|
| 140 | 140 | |
| 141 | - // Prevent occurring of any custom action on wp_logout. |
|
| 142 | - remove_all_actions( 'wp_logout' ); |
|
| 141 | + // Prevent occurring of any custom action on wp_logout. |
|
| 142 | + remove_all_actions( 'wp_logout' ); |
|
| 143 | 143 | |
| 144 | 144 | /** |
| 145 | 145 | * Fires before processing user logout. |
| 146 | 146 | * |
| 147 | 147 | * @since 1.0 |
| 148 | 148 | */ |
| 149 | - do_action( 'give_before_user_logout' ); |
|
| 149 | + do_action( 'give_before_user_logout' ); |
|
| 150 | 150 | |
| 151 | - // Logout user. |
|
| 152 | - wp_logout(); |
|
| 151 | + // Logout user. |
|
| 152 | + wp_logout(); |
|
| 153 | 153 | |
| 154 | 154 | /** |
| 155 | 155 | * Fires after processing user logout. |
| 156 | 156 | * |
| 157 | 157 | * @since 1.0 |
| 158 | 158 | */ |
| 159 | - do_action( 'give_after_user_logout' ); |
|
| 159 | + do_action( 'give_after_user_logout' ); |
|
| 160 | 160 | |
| 161 | - wp_redirect( $data['give_logout_redirect'] ); |
|
| 162 | - give_die(); |
|
| 163 | - } |
|
| 161 | + wp_redirect( $data['give_logout_redirect'] ); |
|
| 162 | + give_die(); |
|
| 163 | + } |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | add_action( 'give_user_logout', 'give_process_user_logout' ); |