maybe_render_hints();
?>
has_submissions() ) {
return;
}
if ( $this->should_show_site_mailer_hint() ) {
$this->render_site_mailer_notice();
}
}
private function render_site_mailer_notice() {
$notice_id = 'site_mailer_forms_submissions_notice';
if ( ! current_user_can( 'install_plugins' ) ) {
return;
}
$plugin_slug = 'site-mailer';
$one_subscription = method_exists( Hints::class, 'is_plugin_connected_to_one_subscription' ) && Hints::is_plugin_connected_to_one_subscription();
$is_installed = Hints::is_plugin_installed( $plugin_slug );
$is_active = Hints::is_plugin_active( $plugin_slug );
if ( $is_active ) {
return;
}
if ( $one_subscription ) {
$title = esc_html__( 'Get your emails delivered with Site Mailer', 'elementor-pro' );
if ( ! $is_installed ) {
$description = esc_html__( 'Ensure form submission emails reach the inbox and track delivery with built-in logs. Site Mailer is included in your ONE subscription.', 'elementor-pro' );
$button_text = esc_html__( 'Install now', 'elementor-pro' );
$button_url = Hints::get_plugin_install_url( $plugin_slug );
$campaign_data = [
'name' => 'site_mailer_forms_submissions_notice',
'campaign' => 'sm-plg-submission-v1',
'source' => 'sm-submission-one-install',
'medium' => 'wp-dash-one',
];
} elseif ( ! $is_active ) {
$description = esc_html__( 'Ensure form submission emails reach the inbox and track delivery with built-in logs. Site Mailer is included in your ONE subscription. Activate it to continue.', 'elementor-pro' );
$button_text = esc_html__( 'Activate now', 'elementor-pro' );
$button_url = Hints::get_plugin_action_url( $plugin_slug );
$campaign_data = [
'name' => 'site_mailer_forms_submissions_notice',
'campaign' => 'sm-plg-submission-v1',
'source' => 'sm-submission-one-activate',
'medium' => 'wp-dash-one',
];
}
} else {
$title = esc_html__( 'Get Your Emails Delivered With Site Mailer', 'elementor-pro' );
$description = esc_html__( 'Make sure emails reach the inbox every time with improved deliverability, detailed email logs, and an easy setup with no need for an SMTP plugin.', 'elementor-pro' );
if ( ! $is_installed ) {
$button_text = esc_html__( 'Install now', 'elementor-pro' );
$button_url = Hints::get_plugin_install_url( $plugin_slug );
$campaign_data = [
'name' => 'site_mailer_forms_submissions_notice',
'campaign' => 'sm-plg-submission-v1',
'source' => 'sm-submission-install',
'medium' => 'wp-dash',
];
} elseif ( ! $is_active ) {
$button_text = esc_html__( 'Activate now', 'elementor-pro' );
$button_url = Hints::get_plugin_action_url( $plugin_slug );
$campaign_data = [
'name' => 'site_mailer_forms_submissions_notice',
'campaign' => 'sm-plg-submission-v1',
'source' => 'sm-submission-activate',
'medium' => 'wp-dash',
];
}
}
$notice_options = [
'id' => $notice_id,
'title' => $title,
'description' => $description,
'type' => 'cta',
'button_secondary' => [
'text' => $button_text,
'url' => $button_url,
'type' => 'cta',
'data' => [
'source' => $campaign_data['source'],
],
],
];
/**
* @var Admin_Notices $admin_notices
*/
$admin_notices = Plugin::elementor()->admin->get_component( 'admin-notices' );
$admin_notices->print_admin_notice( $notice_options );
}
public function has_submissions( $min_count = 1 ): bool {
global $wpdb;
$table = $wpdb->prefix . Query::E_SUBMISSIONS;
// The placeholder ignores can be removed when %i is supported by WPCS.
// See https://core.trac.wordpress.org/ticket/56091#comment:11
// phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.UnsupportedPlaceholder, WordPress.DB.PreparedSQLPlaceholders.ReplacementsWrongNumber
$submissions_count = (int) $wpdb->get_var( $wpdb->prepare( 'SELECT COUNT(*) FROM %i LIMIT %d', $table, $min_count ) );
return $min_count <= $submissions_count;
}
public function should_show_site_mailer_hint(): bool {
return ( Hints::should_show_hint( 'site_mailer_forms_submissions_notice' )
&& ! User::is_user_notice_viewed( 'site_mailer_forms_submissions_notice' )
);
}
}