Automattic\WooCommerce\Admin\Features
LaunchYourStore::is_mailpoet_connected()
Check if the Mailpoet is connected.
Method of the class: LaunchYourStore{}
No Hooks.
Return
true|false
. true if Mailpoet is fully connected, meaning the API key is valid and approved.
Usage
// private - for code of main (parent) class only $result = $this->is_mailpoet_connected();
LaunchYourStore::is_mailpoet_connected() LaunchYourStore::is mailpoet connected code WC 9.7.1
private function is_mailpoet_connected() { if ( ! class_exists( '\MailPoet\DI\ContainerWrapper' ) || ! class_exists( '\MailPoet\Settings\SettingsController' ) ) { return false; } $container = \MailPoet\DI\ContainerWrapper::getInstance( WP_DEBUG ); // SettingController retrieves data from wp_mailpoet_settings table. $settings = $container->get( \MailPoet\Settings\SettingsController::class ); if ( false === $settings instanceof \MailPoet\Settings\SettingsController ) { return false; } $mta = $settings->get( 'mta' ); $api_state = $mta['mailpoet_api_key_state'] ?? null; if ( ! $api_state || ! isset( $api_state['state'], $api_state['code'] ) ) { return false; } return 'valid' === $api_state['state'] && 200 === $api_state['code']; }