[ Index ]

PHP Cross Reference of YOURLS

title

Body

[close]

/includes/ -> functions-links.php (summary)

(no description)

File Size: 276 lines (9 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 10 functions

  yourls_add_query_arg()
  yourls_urlencode_deep()
  yourls_remove_query_arg()
  yourls_link()
  yourls_statlink()
  yourls_admin_url()
  yourls_site_url()
  yourls_get_yourls_site()
  yourls_match_current_protocol()
  yourls_get_yourls_favicon_url()

Functions
Functions that are not part of a class:

yourls_add_query_arg()   X-Ref
Add a query var to a URL and return URL. Completely stolen from WP.

Works with one of these parameter patterns:
array( 'var' => 'value' )
array( 'var' => 'value' ), $url
'var', 'value'
'var', 'value', $url
If $url omitted, uses $_SERVER['REQUEST_URI']

The result of this function call is a URL : it should be escaped before being printed as HTML

return: string New URL query string.
param: string|array $param1 Either newkey or an associative_array.
param: string       $param2 Either newvalue or oldquery or URI.
param: string       $param3 Optional. Old query or URI.
since: 1.5

yourls_urlencode_deep( $value )   X-Ref
Navigates through an array and encodes the values to be used in a URL. Stolen from WP, used in yourls_add_query_arg()

return: array|string
param: array|string $value The array or string to be encoded.

yourls_remove_query_arg( $key, $query = false )   X-Ref
Remove arg from query. Opposite of yourls_add_query_arg. Stolen from WP.

The result of this function call is a URL : it should be escaped before being printed as HTML

return: string New URL query string.
param: string|array $key   Query key or keys to remove.
param: bool|string  $query Optional. When false uses the $_SERVER value. Default false.
since: 1.5

yourls_link( $keyword = '', $stats = false )   X-Ref
Converts keyword into short link (prepend with YOURLS base URL) or stat link (sho.rt/abc+)

This function does not check for a valid keyword.
The resulting link is normalized to allow for IDN translation to UTF8

return: string           Short URL, or keyword stat URL
param: string $keyword  Short URL keyword
param: bool   $stats    Optional, true to return a stat link (eg sho.rt/abc+)

yourls_statlink( $keyword = '' )   X-Ref
Converts keyword into stat link (prepend with YOURLS base URL, append +)

This function does not make sure the keyword matches an actual short URL

return: string           Short URL stat link
param: string $keyword  Short URL keyword

yourls_admin_url( $page = '' )   X-Ref
Return admin link, with SSL preference if applicable.

return: string
param: string $page  Page name, eg "index.php"

yourls_site_url($echo = true, $url = '' )   X-Ref
Return YOURLS_SITE or URL under YOURLS setup, with SSL preference

return: string
param: bool $echo   Echo if true, or return if false
param: string $url

yourls_get_yourls_site()   X-Ref
Get YOURLS_SITE value, trimmed and filtered

In addition of being filtered for plugins to hack this, this function is mostly here
to help people entering "sho.rt/" instead of "sho.rt" in their config

return: string  YOURLS_SITE, trimmed and filtered
since: 1.7.7

yourls_match_current_protocol( $url, $normal = 'http:)   X-Ref
Change protocol of a URL to HTTPS if we are currently on HTTPS

This function is used to avoid insert 'http://' images or scripts in a page when it's served through HTTPS,
to avoid "mixed content" errors.
So:
- if you are on http://sho.rt/, 'http://something' and 'https://something' are left untouched.
- if you are on https:/sho.rt/, 'http://something' is changed to 'https://something'

So, arguably, this function is poorly named. It should be something like yourls_match_current_protocol_if_we_re_on_https

return: string            the modified URL, if applicable
param: string $url        a URL
param: string $normal     Optional, the standard scheme (defaults to 'http://')
param: string $ssl        Optional, the SSL scheme (defaults to 'https://')
since: 1.5.1

yourls_get_yourls_favicon_url( $echo = true )   X-Ref
Auto detect custom favicon in /user directory, fallback to YOURLS favicon, and echo/return its URL

This function supersedes function yourls_favicon(), deprecated in 1.7.10, with a better naming.

return: string       favicon URL
param: bool $echo   true to echo, false to silently return
since: 1.7.10



Generated: Sat Feb 22 05:10:06 2025 Cross-referenced by PHPXref 0.7.1