Function Reference: geodir_parse_custom_field_url
Summary
Returns parsed url and title.
Description
This function converts string to url and title if there is “|” separator used in url.
Ex: “http://wpgeodirectory.com|GeoDirectory” will return array( url => http://wpgeodirectory.com, label => GeoDirectory ).
Package
Geodirectory
Parameters
- $url
- (string) (required) The website url.
- Default: None
- $formatted
- (bool) (required) True if returns formatted url. False if not.
- Default: true
Return Values
- (array)
- Parsed url and title.
Change Log
Since: 1.5.7
Source File
geodir_parse_custom_field_url() is located in geodirectory-functions/helper_functions.php [Line: 301]
Source Code
function geodir_parse_custom_field_url($url, $formatted = true) { if ($url == '' || !is_string($url)) { return NULL; } $original_url = $url; $url = stripcslashes($url); $parts = explode('|', $url, 2); $url = trim($parts[0]); if ($formatted && $url != '') { $url = str_replace( ' ', '%20', $url ); $url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\[\]\\x80-\\xff]|i', '', $url); if (0 !== stripos($url, 'mailto:')) { $strip = array('%0d', '%0a', '%0D', '%0A'); $url = _deep_replace($strip, $url); } $url = str_replace(';//', '://', $url); if (strpos($url, ':') === false && ! in_array($url[0], array('/', '#', '?')) && !preg_match('/^[a-z0-9-]+?\.php/i', $url)) { $url = 'http://' . $url; } $url = wp_kses_normalize_entities($url); $url = str_replace('&', '&', $url); $url = str_replace("'", ''', $url); } $return = array(); $return['url'] = $url; if (!empty($parts[1]) && trim($parts[1]) != '') { $return['label'] = trim($parts[1]); } return $return; }