Skip to main content

Tell the Add-ons screen that this add-on plugin is loaded

Premium Beginner

Benecaster fires benecaster_installed_addons during admin bootstrapping to build the list of loaded add-ons. Each add-on plugin should hook this filter inside its benecaster_boot callback and append its fully-qualified slug. Without this hook, a purchased-and-activated add-on renders as “Ready to install” because the Add-ons screen has no other way to distinguish entitled from actually loaded. The registry deduplicates.

Also declare the add-on in its plugin header. A deactivated plugin runs no code, so the filter cannot report it. Benecaster recognises a deactivated add-on by a Benecaster Add-on header in its main plugin file instead, whose value is the same slug:

<?php
/**
 * Plugin Name:       Benecaster Guest Manager
 * Version:           1.0.0
 * Benecaster Add-on: benecaster-addon-guest-manager
 */

The folder name does not matter, so a renamed folder still counts. A plugin without the header is never treated as an add-on while it is deactivated, whatever it is called, and does not appear in the deactivated_addons figure that opted-in sites report.

Code

<?php
add_action( 'benecaster_boot', function (): void {
    add_filter( 'benecaster_installed_addons', static function ( array $slugs ): array {
        $slugs[] = 'benecaster-addon-guest-manager';
        return $slugs;
    } );
} );

View on GitHub →

Hooks Used

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