Integration slug => plugin. */ abstract public function getSupportedPlugins(): array; abstract public function isOwnPluginActive(): bool; abstract public function getOwnPluginName(): string; /** * Asset path of the plugin icon, relative to the assets directory. */ abstract public function getOwnPluginIconAsset(): string; /** * Asset path of the plugin's wp.org banner (772×250), relative to the assets directory. */ abstract public function getOwnPluginBannerAsset(): string; /** * @return array */ abstract public function getOwnPluginPills(): array; abstract public function getOwnPluginWporgURL(): string; abstract public function getOwnPluginSiteURL(): string; /** * utm_campaign prefix, e.g. 'multicurrency' → 'multicurrency-tab' / 'multicurrency-switch'. */ abstract public function getUtmCampaignBase(): string; abstract public function getIntroHeading(): string; abstract public function getIntroText(): string; abstract public function getPromoText(): string; abstract public function getPairedBannerText(): string; abstract public function getIntegrationEnabledText(): string; abstract public function getIntegrationDisabledText(): string; /** * @param string $competitorNames Human-readable list of the detected plugins. */ abstract public function getConflictText( string $competitorNames ): string; public function getConflictBannerClass(): string { return 'tpt-pairing__banner--danger'; } public function getFieldType(): string { return 'tiered-pricing_' . $this->getSlug() . '-ui'; } public function __construct() { add_action( 'woocommerce_admin_field_' . $this->getFieldType(), array( $this, 'renderUI' ) ); } public function getSettings(): array { // Pairing sections are informational — there is nothing to save. $GLOBALS['hide_save_button'] = true; return array( array( 'type' => $this->getFieldType(), ), ); } /** * @return array Active competitor plugins only. */ public function getDetectedCompetitors(): array { return array_filter( $this->getSupportedPlugins(), function ( $plugin ) { return $plugin['active']; } ); } protected function isIntegrationEnabled( string $slug ): bool { return get_option( Settings::SETTINGS_PREFIX . '_integration_' . $slug, 'yes' ) === 'yes'; } protected function getIntegrationsPageURL(): string { return admin_url( 'admin.php?page=wc-settings&tab=' . Settings::SETTINGS_PAGE . '§ion=integrations' ); } public function renderUI() { $competitors = $this->getDetectedCompetitors(); $ownActive = $this->isOwnPluginActive(); ?>
getConflictText( implode( ', ', wp_list_pluck( $competitors, 'name' ) ) ) ); ?>
getPairedBannerText() ); ?>

→

$competitor ) : ?> isIntegrationEnabled( $slug ); ?>
getIntegrationEnabledText() : $this->getIntegrationDisabledText() ); ?> →
renderSupportedPlugins(); ?> renderPromo( array_key_first( $competitors ) ); ?>

getIntroHeading() ); ?>

getIntroText() ); ?>

renderSupportedPlugins(); ?> renderPromo(); ?>
getSupportedPlugins() as $plugin ) : ?>
getUtmCampaignBase() . ( $detectedCompetitor ? '-switch&utm_term=' . rawurlencode( $detectedCompetitor ) : '-tab' ); $iconURL = $this->getContainer()->getFileManager()->locateAsset( $this->getOwnPluginIconAsset() ); $title = $detectedCompetitor /* translators: %s: U2Code plugin name */ ? sprintf( __( 'Switch to %s', 'tier-pricing-table' ), $this->getOwnPluginName() ) : $this->getOwnPluginName(); ?>

getPromoText() ); ?>

    getOwnPluginPills() as $pill ) : ?>