You appear to be a bot. Output may be restricted
Description
Constructs a suitable URLWe've been given what may be an URL. What can we do to make the link really easy to use? parse_url produces an array which may contain these fields:
- scheme – e.g. http
- host
- port
- user
- pass
- path
- query – after the question mark ?
- fragment – after the hashmark #
Usage
$string = bw_link_url( $url, $atts );
Parameters
- $url
- ( string ) required – an URL – or part thereof
- $atts
- ( array ) required – shortcode parameters
Returns
string the newly constructed urlSource
File name: oik/shortcodes/oik-link.phpLines:
1 to 34 of 34
function bw_link_url( $url, $atts ) { $newurl = $url; $parts = parse_url( $url ); bw_trace2( $parts, "parts" ); $scheme = bw_array_get( $parts, "scheme", null ); if ( !$scheme ) { $path = bw_array_get( $parts, "path", null ); if ( $path ) { $parts['scheme'] = is_ssl() ? 'https://' : 'http://'; $parts['host'] = bw_array_get( $parts, "host", null ); if ( $parts['host'] ) { // No need to check if this is a domain, just use it. // OR do we? //gobang(); } else { // No host... // check to see if the path is a domain? $parts = bw_host_or_path( $parts ); //$newurl = set_url_scheme( "$domain/$url" ); } } else { $parts['scheme'] = null; $parts['host'] = null; } $newurl = bw_build_url( $parts ); } else { // Let whatever they've typed be used } //$newurl = set_url_scheme( $newurl ); //e("bw_link_url: $newurl" ); return( $newurl ); }View on GitHub View on Trac