*/
public function integrations(): array {
/**
* Filter the integrations shown on the Integrations screen.
*
* @param array $integrations
*/
$integrations = (array) apply_filters( 'submex_admin_integrations', array() );
usort(
$integrations,
static fn( array $a, array $b ): int => strcasecmp( (string) ( $a['title'] ?? '' ), (string) ( $b['title'] ?? '' ) )
);
return $integrations;
}
public function render(): void {
if ( ! current_user_can( Menu::CAPABILITY ) ) {
wp_die( esc_html__( 'You do not have permission to manage subscriptions.', 'submex' ) );
}
App_Host::start( self::SLUG );
$this->render_screen();
App_Host::end();
}
private function render_screen(): void {
$integrations = $this->integrations();
Page_Shell::open(
__( 'Integrations', 'submex' ),
__( 'Hand a subscription to the plugin that delivers what it pays for, and take it back when it ends.', 'submex' )
);
if ( ! $integrations ) {
printf(
'
%s
%s
',
esc_html__( 'Nothing to connect yet', 'submex' ),
esc_html__( 'Integrations hand a subscription to the plugin that grants what it pays for — a course, a mailing list, a licence key. Submex Pro adds them.', 'submex' )
);
Page_Shell::close();
return;
}
$groups = array();
foreach ( $integrations as $integration ) {
$category = (string) ( $integration['category'] ?? '' );
$category = '' !== $category ? $category : __( 'Other', 'submex' );
$groups[ $category ][] = $integration;
}
foreach ( $groups as $category => $items ) {
echo '
' . esc_html__( 'An integration only does anything while the plugin it connects to is active, and only for products you have configured it on.', 'submex' ) . '