Skip to main content

benecaster_get_admin_url()

Free
benecaster_get_admin_url( string $route = '/', int $show_id = 0 ): string

A link into Benecaster’s admin, optionally opening it on a given show. Use it for any per-show link an add-on sends, such as a digest email or a notice; without it, the reader lands on the first show.

An id the admin cannot select (a show that doesn’t exist or isn’t published) opens the first show, silently. The show_id is removed from the address bar once read, so the switcher works as usual afterwards and a reload doesn’t jump back. A route that names its own show (/shows/{id}/settings/…) selects that show whatever show_id says. The route isn’t checked: an unknown one opens an empty pane, not an error.

Parameters

Name Type Default Required Description
$route string '/' No A hash route the admin app renders, starting with / (for example /analytics, /episodes, /settings/notifications).
$show_id int 0 No The show the admin selects on load. 0 leaves the choice to the app, which is the first show.

Return Value

Type: string

A raw URL, shaped …/wp-admin/admin.php?page=benecaster&show_id=12#/analytics. Escape it with esc_url() for output.

Example

$url = benecaster_get_admin_url( '/analytics', $show_id );
printf( '<a href="%s">%s</a>', esc_url( $url ), esc_html__( 'Manage digest preferences', 'my-addon' ) );

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