__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
/**
* DiscountsUtil class file.
*/
namespace Automattic\WooCommerce\Utilities;
/**
* The DiscountsUtil class provides utilities to assist discounts calculation and validation.
*/
class DiscountsUtil {
/**
* Checks if the given email address(es) matches the ones specified on the coupon.
*
* @param array $check_emails Array of customer email addresses.
* @param array $restrictions Array of allowed email addresses.
*
* @return bool
*/
public static function is_coupon_emails_allowed( $check_emails, $restrictions ) {
foreach ( $check_emails as $check_email ) {
// With a direct match we return true.
if ( in_array( $check_email, $restrictions, true ) ) {
return true;
}
// Go through the allowed emails and return true if the email matches a wildcard.
foreach ( $restrictions as $restriction ) {
// Convert to PHP-regex syntax.
$regex = '/^' . str_replace( '*', '(.+)?', $restriction ) . '$/';
preg_match( $regex, $check_email, $match );
if ( ! empty( $match ) ) {
return true;
}
}
}
// No matches, this one isn't allowed.
return false;
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| ArrayUtil.php | File | 12.99 KB | 0664 |
|
| DiscountsUtil.php | File | 1.1 KB | 0664 |
|
| FeaturesUtil.php | File | 4.23 KB | 0664 |
|
| I18nUtil.php | File | 1.69 KB | 0664 |
|
| LoggingUtil.php | File | 3.18 KB | 0664 |
|
| NumberUtil.php | File | 7.11 KB | 0664 |
|
| OrderUtil.php | File | 9.19 KB | 0664 |
|
| PluginUtil.php | File | 12.99 KB | 0664 |
|
| RestApiUtil.php | File | 5.01 KB | 0664 |
|
| ShippingUtil.php | File | 1020 B | 0664 |
|
| StringUtil.php | File | 5.09 KB | 0664 |
|
| TimeUtil.php | File | 1.16 KB | 0664 |
|