Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/woocomme.../src/Utilitie...
File: DiscountsUtil.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* DiscountsUtil class file.
[2] Fix | Delete
*/
[3] Fix | Delete
[4] Fix | Delete
namespace Automattic\WooCommerce\Utilities;
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* The DiscountsUtil class provides utilities to assist discounts calculation and validation.
[8] Fix | Delete
*/
[9] Fix | Delete
class DiscountsUtil {
[10] Fix | Delete
[11] Fix | Delete
/**
[12] Fix | Delete
* Checks if the given email address(es) matches the ones specified on the coupon.
[13] Fix | Delete
*
[14] Fix | Delete
* @param array $check_emails Array of customer email addresses.
[15] Fix | Delete
* @param array $restrictions Array of allowed email addresses.
[16] Fix | Delete
*
[17] Fix | Delete
* @return bool
[18] Fix | Delete
*/
[19] Fix | Delete
public static function is_coupon_emails_allowed( $check_emails, $restrictions ) {
[20] Fix | Delete
[21] Fix | Delete
foreach ( $check_emails as $check_email ) {
[22] Fix | Delete
// With a direct match we return true.
[23] Fix | Delete
if ( in_array( $check_email, $restrictions, true ) ) {
[24] Fix | Delete
return true;
[25] Fix | Delete
}
[26] Fix | Delete
[27] Fix | Delete
// Go through the allowed emails and return true if the email matches a wildcard.
[28] Fix | Delete
foreach ( $restrictions as $restriction ) {
[29] Fix | Delete
// Convert to PHP-regex syntax.
[30] Fix | Delete
$regex = '/^' . str_replace( '*', '(.+)?', $restriction ) . '$/';
[31] Fix | Delete
preg_match( $regex, $check_email, $match );
[32] Fix | Delete
if ( ! empty( $match ) ) {
[33] Fix | Delete
return true;
[34] Fix | Delete
}
[35] Fix | Delete
}
[36] Fix | Delete
}
[37] Fix | Delete
[38] Fix | Delete
// No matches, this one isn't allowed.
[39] Fix | Delete
return false;
[40] Fix | Delete
}
[41] Fix | Delete
}
[42] Fix | Delete
[43] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function