Add Check Connection and Start Campaign buttons to email account tools tab

- Added Check Connection button that tests email account connectivity
- Added Start Campaign button that redirects to campaign creation with email pre-selected
- Added AJAX functionality to display connection test results

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Ruben Ramirez 2025-03-07 09:12:39 -06:00
parent efc50f3b4e
commit 9ed17a4f29

View file

@ -299,9 +299,11 @@ get_header(); ?>
<div>
<?php //rl_mailwarmer_render_fix_deliverability_dns_issues_box($post); ?>
</div>
<div>
<div class="account-tools">
<button id="check-connection-btn" class="button button-primary">Check Connection</button>
<a href="<?php echo esc_url('/dashboard/campaigns/edit-campaign?Email_ID=' . $post_id); ?>" class="button button-secondary">Start Campaign</a>
</div>
<div id="connection-check-result"></div>
</div>
</div>
@ -353,6 +355,8 @@ get_header(); ?>
</div>
<script>
var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>';
jQuery(document).ready(function($) {
// Initialize tabs
$('#email-account-tabs').tabs();
@ -361,6 +365,42 @@ get_header(); ?>
$('.status-sent').css('color', 'green');
$('.status-failed').css('color', 'red');
$('.status-pending').css('color', 'orange');
// Handle Check Connection button click
$('#check-connection-btn').on('click', function(e) {
e.preventDefault();
var button = $(this);
var resultContainer = $('#connection-check-result');
// Disable button and show loading state
button.prop('disabled', true).text('Checking...');
resultContainer.html('<p>Checking connection...</p>');
// Make AJAX call to check connection
$.ajax({
url: ajaxurl,
type: 'POST',
data: {
action: 'rl_mailwarmer_check_mail_login',
post_id: <?php echo intval($post_id); ?>,
security: '<?php echo wp_create_nonce('check_mail_login_nonce'); ?>'
},
success: function(response) {
if (response.success) {
resultContainer.html('<p style="color: green;"><strong>Success:</strong> ' + JSON.stringify(response.data) + '</p>');
} else {
resultContainer.html('<p style="color: red;"><strong>Error:</strong> ' + response.data + '</p>');
}
},
error: function() {
resultContainer.html('<p style="color: red;"><strong>Error:</strong> Connection check failed. Please try again.</p>');
},
complete: function() {
// Re-enable button
button.prop('disabled', false).text('Check Connection');
}
});
});
});
</script>