get_admin()->is_admin_page() ) {
return;
}
$dismissed = get_user_meta( get_current_user_id(), self::DISMISS_NOTICE_BAR_KEY, true );
if ( ! empty( $dismissed ) ) {
return;
}
$current_screen = get_current_screen();
$upgrade_utm_content = $current_screen === null ? 'Upgrade to Pro' : 'Upgrade to Pro - ' . $current_screen->base;
$upgrade_utm_content = empty( $_GET['tab'] ) ? $upgrade_utm_content : $upgrade_utm_content . ' -- ' . sanitize_key( $_GET['tab'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
printf(
'
',
wp_kses(
sprintf( /* translators: %s - WPMailSMTP.com Upgrade page URL. */
__( 'You’re using WP Mail SMTP Lite. To unlock more features, consider upgrading to Pro.', 'wp-mail-smtp' ),
wp_mail_smtp()->get_upgrade_link( [ 'medium' => 'notice-bar', 'content' => $upgrade_utm_content ] ) // phpcs:ignore WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound
),
[
'a' => [
'href' => [],
'rel' => [],
'target' => [],
],
]
),
esc_attr__( 'Dismiss this message.', 'wp-mail-smtp' )
);
}
/**
* Ajax handler for dismissing notices.
*
* @since 2.3.0
*/
public function notice_bar_ajax_dismiss() {
// Run a security check.
check_ajax_referer( 'wp-mail-smtp-admin', 'nonce' );
// Check for permissions.
if ( ! current_user_can( wp_mail_smtp()->get_capability_manage_options() ) ) {
wp_send_json_error();
}
update_user_meta( get_current_user_id(), self::DISMISS_NOTICE_BAR_KEY, time() );
wp_send_json_success();
}
}