Compatibility adapters for plugins with their own full-page UI
Some plugins draw their own full-page interface, such as a page builder. Addofy should stay out of those screens. An adapter tells Addofy which screens to leave alone and can add compatibility CSS.
Write an adapter
use AddoBack\Compat\AbstractAdapter;
final class My_Builder_Adapter extends AbstractAdapter {
public function id(): string { return 'myplugin-builder'; }
public function is_available(): bool { return defined( 'MYPLUGIN_VERSION' ); }
protected function excluded_fragments(): array { return array( 'myplugin-builder' ); } // Screen id fragments.
public function boot(): void {
parent::boot();
add_action( 'adba_screen', static function () {
adba( 'assets' )->enqueue_external( 'myplugin-adba-compat', plugins_url( 'adba-compat.css', __FILE__ ) );
} );
}
}
add_filter( 'adba_compat_adapters', static function ( array $adapters ) {
$adapters[] = My_Builder_Adapter::class;
return $adapters;
} );
How it works
is_available()says whether the plugin you adapt to is active. Addofy boots only the available adapters.excluded_fragments()lists fragments of screen ids. A screen whose id contains one of them is excluded: it gets no Addofy styling and looks fully native.- Extra CSS goes through
enqueue_external(), like any other asset.
A site administrator can also exclude screens in the settings. To decide in code, use the adba_is_excluded_screen filter. Safe mode always wins: that filter cannot switch Addofy back on while it is active.