Function Reference: geodir_sanitize_location_name
Summary
Sanitize location name.
Package
GeoDirectory
Parameters
- $type
- (string) (required) Location type. Can be gd_country, gd_region, gd_city.
- Default: None
- $name
- (string) (required) Location name.
- Default: None
- $translate
- (bool) (required) Do you want to translate the name? Default: true.
- Default: None
Return Values
- (string)
- Sanitized name.
Change Log
Since: 1.0.0
Source File
geodir_sanitize_location_name() is located in geodirectory-functions/general_functions.php [Line: 2712]
Source Code
function geodir_sanitize_location_name( $type, $name, $translate = true ) { if ( $name == '' ) { return null; } $type = $type == 'gd_country' ? 'country' : $type; $type = $type == 'gd_region' ? 'region' : $type; $type = $type == 'gd_city' ? 'city' : $type; $return = $name; if ( function_exists( 'get_actual_location_name' ) ) { $return = get_actual_location_name( $type, $name, $translate ); } else { $return = preg_replace( '/-(\d+)$/', '', $return ); $return = preg_replace( '/[_-]/', ' ', $return ); $return = geodir_ucwords( $return ); $return = $translate ? __( $return, 'geodirectory' ) : $return; } return $return; }