is_activelayer_active() ) {
return $this->is_api_key_connected() ? 'connected' : 'connect';
}
$is_installed = $this->is_activelayer_installed();
if ( ! $is_installed && $this->can_install() ) {
return 'install';
}
if ( $is_installed && current_user_can( 'activate_plugins' ) ) {
return 'activate';
}
// Admins who cannot run the installer (file mods locked) can still follow a link.
if ( current_user_can( 'install_plugins' ) ) {
return 'goto-url';
}
// Users who cannot act at all (e.g. shop managers) get no dead-end card.
return '';
}
/**
* Whether the section should be displayed for the current user.
*
* @since 4.9.0
*
* @return bool
*/
private function should_display() {
/**
* Filters whether the ActiveLayer education section is rendered on the
* WooCommerce Accounts & Privacy settings tab.
*
* @since 4.9.0
*
* @param bool $should_display Whether the section should be displayed.
*/
if ( ! apply_filters( 'wp_mail_smtp_admin_woo_commerce_active_layer_education_should_display', true ) ) {
return false;
}
if ( get_user_meta( get_current_user_id(), self::DISMISS_META, true ) ) {
return false;
}
return $this->get_state() !== '';
}
/**
* Output the section after the WooCommerce account settings block.
*
* Fires on woocommerce_settings_account_registration_options_after, which
* WooCommerce runs after the section's closing table tag, so free-form
* markup is safe here.
*
* @since 4.9.0
*/
public function output_section() {
if ( ! $this->should_display() ) {
return;
}
$state = $this->get_state();
?>
output_state( $state ); ?>
should_display() ) { return; } wp_enqueue_style( 'wp-mail-smtp-activelayer-wc', wp_mail_smtp()->assets_url . '/css/smtp-activelayer-wc' . WP::asset_min() . '.css', [], WPMS_PLUGIN_VER ); wp_enqueue_script( 'wp-mail-smtp-activelayer-wc', wp_mail_smtp()->assets_url . '/js/smtp-activelayer-wc' . WP::asset_min() . '.js', [ 'jquery' ], WPMS_PLUGIN_VER, true ); wp_localize_script( 'wp-mail-smtp-activelayer-wc', 'wp_mail_smtp_activelayer_wc', [ 'ajax_url' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'wp-mail-smtp-admin' ), 'plugin' => self::PLUGIN_BASENAME, 'download_url' => self::DOWNLOAD_URL, 'settings_url' => $this->get_settings_url(), 'wporg_url' => self::WPORG_URL, 'installing' => esc_html__( 'Installing...', 'wp-mail-smtp' ), 'activating' => esc_html__( 'Activating...', 'wp-mail-smtp' ), 'goto_settings' => esc_html__( 'Connect Your Free Account', 'wp-mail-smtp' ), 'get_activelayer' => esc_html__( 'Get ActiveLayer', 'wp-mail-smtp' ), 'error_install' => esc_html__( 'Could not install ActiveLayer. Please download it from WordPress.org and install manually.', 'wp-mail-smtp' ), 'error_activate' => esc_html__( 'Could not activate ActiveLayer. Please activate it from the Plugins page.', 'wp-mail-smtp' ), ] ); } /** * AJAX: dismiss the section for the current user. * * @since 4.9.0 */ public function ajax_dismiss() { if ( check_ajax_referer( 'wp-mail-smtp-admin', 'nonce', false ) === false ) { wp_send_json_error( esc_html__( 'Could not dismiss the section. Please reload the page and try again.', 'wp-mail-smtp' ) ); } update_user_meta( get_current_user_id(), self::DISMISS_META, time() ); wp_send_json_success(); } }