benecaster_outlinks_get_site_link()
benecaster_outlinks_get_site_link( int $id ): ?array
Reads one site-wide Outlinks link by id, for drawing a link whose id you stored when you created it with benecaster_outlinks_site_link(). Publish its go_url. See Track a link that belongs to no show and get its /go/ address.
Parameters
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
id |
int |
— | Yes | The site-wide link's id, as returned by benecaster_outlinks_site_link(). |
Return Value
Type:
array|null
[ 'id' => int, 'slug' => string, 'go_url' => string, 'destination_url' => string, 'affiliate_url' => ?string ], the keys of benecaster_outlinks_site_link() without created. null for an unknown id and for the id of a show's tracked link.
Example
$tracked = ! empty( $publication['outlinks_id'] ) && function_exists( 'benecaster_outlinks_get_site_link' )
? benecaster_outlinks_get_site_link( (int) $publication['outlinks_id'] )
: null;
$href = null !== $tracked ? $tracked['go_url'] : $publication['url'];
Notes
Defined only while Outlinks is switched on for at least one show. It loads with the add-on, so
function_exists() answers "installed and running". When it is missing, or it returns null, draw the
plain URL you stored: a page drawn now should not send visitors through a link Outlinks is not tracking.
Need this built rather than just documented? See our services →