Skip to main content

benecaster_outlinks_get_redirects()

Utilities Premium outlinks
benecaster_outlinks_get_redirects( ?int $show_id ): array

Lists a show’s tracked Outlinks links, for a picker in another add-on (a sponsor’s links in Sponsor Manager, for example). Store the id you pick: it is what benecaster_outlinks_count_clicks() takes, and it survives a slug or destination edit. See List a show’s Outlinks links and count their clicks.

Parameters

Name Type Default Required Description
show_id ?int — Yes The show whose tracked links to list, or null for the site-wide links (those with no show).

Return Value

Type: array

The links, oldest first, each [ 'id' => int, 'slug' => string, 'label' => ?string, 'destination_url' => string, 'go_url' => string ]. label is the reference library item's label, and null for a link whose item was deleted or has no label, and for every site-wide link. [] for a show where Outlinks is switched off or lapsed, and for the site-wide links while Outlinks is off for every show.

Example

$choices = function_exists( 'benecaster_outlinks_get_redirects' ) ? benecaster_outlinks_get_redirects( $show_id ) : [];
foreach ( $choices as $link ) {
    printf( '<option value="%d">%s</option>', $link['id'], esc_html( $link['label'] ?? $link['slug'] ) );
}

Notes

Defined only while Outlinks is switched on for at least one show. Guard with function_exists(). Read links through this function, never by querying Outlinks' tables, which are not a published contract.

Need this built rather than just documented? See our services →