';
$body .= '
' . __('WP-Recover Test Notification', 'wp-recover') . '
';
$body .= '
' . __('This is a test email from the WP-Recover plugin to confirm that email notifications are working correctly.', 'wp-recover') . '
';
$body .= '
' . __('If you received this email, your notification settings are configured correctly.', 'wp-recover') . '
';
$body .= '
' . __('Site URL:', 'wp-recover') . ' ' . site_url() . '
';
$body .= '
' . __('Sent on:', 'wp-recover') . ' ' . date_i18n(get_option('date_format') . ' ' . get_option('time_format')) . '
';
$body .= '
' . __('This is an automated notification from the WP-Recover plugin.', 'wp-recover') . '
';
$body .= '
';
$headers = array('Content-Type: text/html; charset=UTF-8');
$result = wp_mail($recipients, $subject, $body, $headers);
if ($result) {
wp_send_json_success(array(
'message' => __('Test email sent successfully!', 'wp-recover'),
));
} else {
wp_send_json_error(array(
'message' => __('Failed to send test email. Please check your server\'s email configuration.', 'wp-recover'),
));
}
}
/**
* Retrieve the plugin name.
*
* @since 1.0.0
* @return string The plugin name.
*/
public function get_plugin_name() {
return $this->plugin_name;
}
/**
* Retrieve the plugin version.
*
* @since 1.0.0
* @return string The plugin version.
*/
public function get_version() {
return $this->version;
}
/**
* AJAX handler for testing notifications.
*
* @since 1.0.0
*/
public function ajax_test_notification() {
// Check nonce
if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'wp_recover_test_notification')) {
wp_send_json_error(array('message' => __('Security check failed.', 'wp-recover')));
}
// Check permissions
if (!current_user_can('manage_options')) {
wp_send_json_error(array('message' => __('You do not have permission to perform this action.', 'wp-recover')));
}
$settings = get_option('wp_recover_email_settings', array());
$recipients = !empty($settings['recipients']) ? $settings['recipients'] : get_option('admin_email');
$subject = __('Test Notification from WP-Recover', 'wp-recover');
$message = __('This is a test notification to verify your email settings for the WP-Recover plugin.', 'wp-recover');
$sent = wp_mail($recipients, $subject, $message);
if ($sent) {
wp_send_json_success(array('message' => __('Test notification sent successfully.', 'wp-recover')));
} else {
wp_send_json_error(array('message' => __('Failed to send test notification. Please check your WordPress email configuration.', 'wp-recover')));
}
}
/**
* The name of the plugin used to uniquely identify it within the context of
* WordPress and to define internationalization functionality.
*
* @since 1.0.0
* @return string The name of the plugin.
*/
public function get_plugin_name() {
return $this->plugin_name;
}
/**
* The reference to the class that orchestrates the hooks with the plugin.
*
* @since 1.0.0
* @return WP_Recover_Loader Orchestrates the hooks of the plugin.
*/
public function get_loader() {
return $this->loader;
}
/**
* Retrieve the version number of the plugin.
*
* @since 1.0.0
* @return string The version number of the plugin.
*/
public function get_version() {
return $this->version;
}
/**
* Get the logger instance.
*
* @since 1.0.0
* @return \WP_Recover_Logger The logger instance.
*/
public function get_logger() {
return $this->logger;
}
}