slug = $slug; $this->format = $format; // Only show notice if global option not set $global_notice_hidden = get_option('post_smtp_global_recommendation_notice_hidden', false); if ($global_notice_hidden) { $show_admin_notice = false; } add_action('rest_api_init', array($this, 'rest_api_init')); // Register AJAX actions early add_action('wp_ajax_post_smtp_request', array($this, 'request_post_smtp_ajax')); add_action('wp_ajax_nopriv_post_smtp_request', array($this, 'request_post_smtp_ajax')); if ($show_admin_notice || $parent_menu) { add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts')); add_action('admin_head', array($this, 'admin_head')); if (!function_exists('is_plugin_active')) { require_once(ABSPATH . 'wp-admin/includes/plugin.php'); } foreach ($this->plugins as $plugin) { if (is_plugin_active($plugin)) { break; } else { if ($parent_menu) { if ('login-designer' === $this->slug) { add_action('admin_menu', function () use ($parent_menu) { add_theme_page('SMTP', 'SMTP Free', 'manage_options', "{$this->slug}-recommend-post-smtp", array($this, 'recommend_post_smtp_submenu'), 99); }, 9999); } else { add_action('admin_menu', function () use ($parent_menu) { add_submenu_page( $parent_menu, 'SMTP', 'SMTP Free', 'manage_options', "{$this->slug}-recommend-post-smtp", array($this, 'recommend_post_smtp_submenu'), 99 ); }, 9999); } } if (file_exists(WP_PLUGIN_DIR . "/{$this->plugins[0]}")) { $this->is_installed = true; } break; } } } } /** * Hide the admin notice | Action Callback * * @return void */ public function hide_post_smtp_recommendation_notice() { if (!current_user_can('manage_options') || !isset($_GET['nonce']) || !wp_verify_nonce($_GET['nonce'], 'hide-post-smtp-recommendation-notice')) { wp_die(__('Security Check.', 'file-manager-advanced')); } if (isset($_GET['action']) && $_GET['action'] === 'hide-post-smtp-recommendation-notice') { update_option('post-smtp-recommendation-notice-hidden', true); wp_redirect(wp_get_referer()); } } /** * Display the submenu page for the plugin | Action Callback * * @return void */ public function recommend_post_smtp_submenu() { $button = array( 'text' => 'Install and Activate Post SMTP Now!', 'action' => 'install-plugin_post-smtp', ); if ($this->is_installed) { $button['text'] = 'Activate Post SMTP Now!'; $button['action'] = 'activate-plugin_post-smtp'; } ?>
slug}/assets/icon-128x128.{$this->format}"); ?>" alt="slug} Logo" ?>" width="75px" /> Attachment Post SMTP Logo

Boost Wordpress Email Deliverability with Post SMTP

Post SMTP is #1 SMTP plugin trusted by over 400,000 WordPress sites. Experience flawless email deliverability, detailed email logs, instant failure notifications and much more.

Post SMTP Banner

Post SMTP - Your WordPress Email Solution

Ensure guaranteed email deliverability with seamless integration to top SMTP services. Manage your emails confidently and ensure they always reach the inbox. Learn more about Post SMTP


Exclusive API support for all popular ESPs

Gmail SMTP

Microsoft 365 (Office 365)

Mailgun

SendGrid

Brevo (fomerly SendInBlue)

Amazon SES

Twilio (SMS Notifications)

Zoho Mail

+Any SMTP Provider

'No nonce provided')); } if (!wp_verify_nonce($_POST['nonce'], 'post_smtp_request_nonce')) { wp_send_json_error(array('message' => 'Security check failed')); } if (!current_user_can('manage_options')) { wp_send_json_error(array('message' => 'Insufficient permissions')); } // Check if status is provided if (!isset($_POST['status'])) { wp_send_json_error(array('message' => 'No status provided')); } // Handle consent grant request if (isset($_POST['grant_consent']) && $_POST['grant_consent'] === '1') { self::grant_data_consent(); } // Only send data to external server if admin has given consent if (!self::has_data_consent()) { wp_send_json_success(array( 'message' => __('Action completed (data sharing skipped — no consent)', 'file-manager-advanced'), 'consent' => false )); return; } $site_url = get_bloginfo('url'); $status = sanitize_text_field($_POST['status']); $plugin_slug = $this->slug; $secret_key = self::get_site_secret_key(); $response = wp_remote_post("https://connect.postmansmtp.com/wp-json/update/v1/update?site_url={$site_url}&status={$status}&plugin_slug={$plugin_slug}", array( 'method' => 'POST', 'headers' => array( 'Content-Type' => 'application/json', 'Secret-Key' => $secret_key ) )); if (is_wp_error($response)) { wp_send_json_error(array( 'message' => 'Failed to send request: ' . $response->get_error_message() )); } else { wp_send_json_success(array( 'message' => __('Request sent successfully', 'file-manager-advanced') )); } } /** * Add the admin footer script to the notice | Action Callback */ public function admin_enqueue_scripts() { wp_enqueue_script('updates'); wp_enqueue_script('recommend-post-smtp-script', plugin_dir_url(__FILE__) . 'assets/js/admin-script.js', array('updates', 'jquery'), '1.0.0', true); wp_localize_script('recommend-post-smtp-script', 'recommendPostSMTP', array( 'redirectURL' => admin_url("admin-post.php?action=hide-post-smtp-recommendation-notice&nonce=" . wp_create_nonce('hide-post-smtp-recommendation-notice')), 'postSMTPURL' => admin_url("admin.php?page=postman"), 'ajaxURL' => admin_url('admin-ajax.php'), 'ajaxNonce' => wp_create_nonce('post_smtp_request_nonce'), 'hasConsent' => self::has_data_consent(), )); } } endif;