Skip to main content

Point the podcaster at a companion add-on the right way — buy, install or open it

Free Beginner

An add-on whose feature works better with another add-on — a transcript editor that wants AI Search, say — should not build a shop link itself. An owner must never be sent to a sales page, an unreleased add-on must link nowhere, and an owned one is installed through the Add-on Manager or the Downloads panel. The add-on’s row in GET /benecaster/v1/addons already says which, so read it and render what it carries.

Code

<?php
$res  = rest_do_request( new WP_REST_Request( 'GET', '/benecaster/v1/addons' ) );
$rows = wp_list_pluck( $res->get_data()['items'] ?? [], null, 'entitlement_slug' );
$row  = $rows['benecaster-addon-ai-search'] ?? null;

if ( null === $row || $row['coming_soon'] ) {
    return; // Unknown or not released: say nothing, link nowhere.
}
if ( 'active' === $row['state'] ) {
    $href = $row['settings_url'] ?? null;            // Already running here.
} elseif ( isset( $row['purchase_url'] ) ) {
    $href = $row['purchase_url'];                    // Nobody here owns it.
} else {
    $href = admin_url( 'admin.php?page=benecaster#/settings/addons' ); // Owned: install it from Add-ons.
}

View on GitHub →

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