Initial commit

This commit is contained in:
Ruben Ramirez 2024-12-26 12:33:40 -06:00
commit a2ab138939
15 changed files with 2580 additions and 0 deletions

89
footer.php Normal file
View file

@ -0,0 +1,89 @@
<?php
/**
* The template for displaying the footer.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
?>
</div>
</div>
<?php
/**
* generate_before_footer hook.
*
* @since 0.1
*/
do_action( 'generate_before_footer' );
?>
<div <?php generate_do_attr( 'footer' ); ?>>
<?php
/**
* generate_before_footer_content hook.
*
* @since 0.1
*/
do_action( 'generate_before_footer_content' );
/**
* generate_footer hook.
*
* @since 1.3.42
*
* @hooked generate_construct_footer_widgets - 5
* @hooked generate_construct_footer - 10
*/
do_action( 'generate_footer' );
/**
* generate_after_footer_content hook.
*
* @since 0.1
*/
do_action( 'generate_after_footer_content' );
?>
</div>
<?php
/**
* generate_after_footer hook.
*
* @since 2.1
*/
do_action( 'generate_after_footer' );
wp_footer();
?>
<!-- <script>
// $.noConflict();
jQuery(document).ready(function(){
console.log("jQuery Loaded");
jQuery('.widget_nav_menu .menu-item-has-children > a').hover(
function() {
var submenu = jQuery(this).siblings('.sub-menu');
submenu.removeClass('sliding-up').addClass('sliding-down').show();
},
function() {
var submenu = jQuery(this).siblings('.sub-menu');
setTimeout(function() {
if (!submenu.is(':hover')) {
submenu.removeClass('sliding-down').addClass('sliding-up');
setTimeout(function() {
if (submenu.hasClass('sliding-up')) {
submenu.hide();
}
}, 300); // Match animation duration
}
}, 200);
}
);
});
</script> -->
</body>
</html>

33
functions.php Normal file
View file

@ -0,0 +1,33 @@
<?php
/**
* GeneratePress child theme functions and definitions.
*
*/
/**
* Basic logging function for debugging. Allows passing of an object or array for the $data paramater
*
* Set the CUSTOM_DEBUG_LOG file in wp-config.php
*
*/
/*
function log_to_file($message = false, $data = false){
if ($message) {
$log_File = CUSTOM_DEBUG_LOG;
$date = new DateTime();
$date = $date->format("Y/m/d h:i:s");
// Convert arrays and objects to JSON format
if (is_array($data) || is_object($data)) {
$data = json_encode($data);
$message = $message . " " . $data;
} else if ($data) {
$message = $message . " " . $data;
}
error_log("[$date] " . $message ."\r\n",3,$log_File);
}
}
*/

186
page-campaigns.php Normal file
View file

@ -0,0 +1,186 @@
<?php
/**
* Template Name: Campaign List template
* Template Post Type: page
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
$items_per_page = isset($_GET['per_page']) ? intval($_GET['per_page']) : 10;
get_header(); ?>
<div <?php generate_do_attr( 'content' ); ?>>
<main <?php generate_do_attr( 'main' ); ?>>
<?php
/**
* generate_before_main_content hook.
*
* @since 0.1
*/
do_action( 'generate_before_main_content' );
if ( generate_has_default_loop() ) {
while ( have_posts() ) :
the_post();
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?> <?php generate_do_microdata( 'article' ); ?>>
<div class="inside-article">
<?php
/**
* generate_before_content hook.
*
* @since 0.1
*
* @hooked generate_featured_page_header_inside_single - 10
*/
do_action( 'generate_before_content' );
if ( generate_show_entry_header() ) :
?>
<header <?php generate_do_attr( 'entry-header' ); ?>>
<?php
/**
* generate_before_entry_title hook.
*
* @since 0.1
*/
do_action( 'generate_before_entry_title' );
// if ( generate_show_title() ) {
// $params = generate_get_the_title_parameters();
// the_title( $params['before'], $params['after'] );
// }
?>
<!-- Items per page dropdown -->
<div class="tablenav top">
<div class="alignright tablenav-actions">
<form method="get" class="items-per-page-form" id="items-per-page-form">
<select name="per_page" id="per_page" onchange="handlePerPageChange(this)">
<?php
$options = array(10, 25, 50, 100);
foreach ($options as $option) {
printf(
'<option value="%1$d" %2$s>%1$d per page</option>',
$option,
selected($items_per_page, $option, false)
);
}
?>
</select>
<?php
// Maintain any existing query parameters except paged
foreach ($_GET as $key => $value) {
if ($key !== 'per_page' && $key !== 'paged') {
echo '<input type="hidden" name="' . esc_attr($key) . '" value="' . esc_attr($value) . '">';
}
}
?>
</form>
</div>
</div>
<?php
/**
* generate_after_entry_title hook.
*
* @since 0.1
*
* @hooked generate_post_meta - 10
*/
do_action( 'generate_after_entry_title' );
?>
</header>
<?php
endif;
/**
* generate_after_entry_header hook.
*
* @since 0.1
*
* @hooked generate_post_image - 10
*/
do_action( 'generate_after_entry_header' );
$itemprop = '';
if ( 'microdata' === generate_get_schema_type() ) {
$itemprop = ' itemprop="text"';
}
?>
<div class="entry-content"<?php echo $itemprop; // phpcs:ignore -- No escaping needed. ?>>
<?php
$list = new PostTypeList('campaign', [
'title' => 'My Campaigns',
'no_items' => 'You haven\'t added any campaigns yet.',
'delete_confirm' => 'Are you sure you want to delete this campaign? This action cannot be undone.'
]);
$list->render();
// the_content();
// wp_link_pages(
// array(
// 'before' => '<div class="page-links">' . __( 'Pages:', 'generatepress' ),
// 'after' => '</div>',
// )
// );
?>
</div>
<?php
/**
* generate_after_entry_content hook.
*
* @since 0.1
*
* @hooked generate_footer_meta - 10
*/
do_action( 'generate_after_entry_content' );
/**
* generate_after_content hook.
*
* @since 0.1
*/
do_action( 'generate_after_content' );
?>
</div>
</article>
<?php
endwhile;
}
/**
* generate_after_main_content hook.
*
* @since 0.1
*/
do_action( 'generate_after_main_content' );
?>
</main>
</div>
<?php
/**
* generate_after_primary_content_area hook.
*
* @since 2.0
*/
do_action( 'generate_after_primary_content_area' );
generate_construct_sidebars();
get_footer();

209
page-dashboard.php Normal file
View file

@ -0,0 +1,209 @@
<?php
/**
* The Template for displaying the dashboard.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
$current_user_id = get_current_user_id();
$cloudflare_email = get_user_meta($current_user_id, 'cloudflare_api_email', true);
$cloudflare_key = get_user_meta($current_user_id, 'cloudflare_api_key', true);
if (! ($cloudflare_email || $cloudflare_key) ) {
$message = '<a href="/membership-account/your-profile/">It looks like you haven\'t set up your CloudFlare API info yet. Click here to save that in your profile and get started!</a>';
}
$domain_count = count(get_posts([
'post_type' => 'domain',
'posts_per_page' => -1,
'meta_query' => [['key' => 'owner_id', 'value' => $current_user_id]]
]));
$campaign_count = count(get_posts([
'post_type' => 'campaign',
'posts_per_page' => -1,
'meta_query' => [['key' => 'owner_id', 'value' => $current_user_id]]
]));
$email_count = count(get_posts([
'post_type' => 'email-account',
'posts_per_page' => -1,
'meta_query' => [['key' => 'owner_id', 'value' => $current_user_id]]
]));
get_header(); ?>
<div <?php generate_do_attr( 'content' ); ?>>
<main <?php generate_do_attr( 'main' ); ?>>
<?php
/**
* generate_before_main_content hook.
*
* @since 0.1
*/
do_action( 'generate_before_main_content' );
if ( generate_has_default_loop() ) {
while ( have_posts() ) :
the_post();
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?> <?php generate_do_microdata( 'article' ); ?>>
<div class="inside-article">
<?php
/**
* generate_before_content hook.
*
* @since 0.1
*
* @hooked generate_featured_page_header_inside_single - 10
*/
do_action( 'generate_before_content' );
if ( generate_show_entry_header() ) :
?>
<header <?php generate_do_attr( 'entry-header' ); ?>>
<?php
/**
* generate_before_entry_title hook.
*
* @since 0.1
*/
do_action( 'generate_before_entry_title' );
// if ( generate_show_title() ) {
// $params = generate_get_the_title_parameters();
// the_title( $params['before'], $params['after'] );
// }
?>
<div class="dash_summary">
<div class="summary_table_wrapper">
<table class="summary-table">
<tr>
<th>Total Domains</th>
<th>Total Campaigns</th>
<th>Total Email Accounts</th>
</tr>
<tr>
<td><?php echo $domain_count; ?></td>
<td><?php echo $campaign_count; ?></td>
<td><?php echo $email_count; ?></td>
</tr>
</table>
</div>
<?php if (isset($message) ) : ?>
<div class="message_area_wrapper">
<div class="message_area">
<?php echo $message; ?>
</div>
</div>
<?php endif; ?>
</div>
<?php
/**
* generate_after_entry_title hook.
*
* @since 0.1
*
* @hooked generate_post_meta - 10
*/
do_action( 'generate_after_entry_title' );
?>
</header>
<?php
endif;
/**
* generate_after_entry_header hook.
*
* @since 0.1
*
* @hooked generate_post_image - 10
*/
do_action( 'generate_after_entry_header' );
$itemprop = '';
if ( 'microdata' === generate_get_schema_type() ) {
$itemprop = ' itemprop="text"';
}
?>
<div class="entry-content mf-dashboard-page"<?php echo $itemprop; // phpcs:ignore -- No escaping needed. ?>>
<?php
the_content();
wp_link_pages(
array(
'before' => '<div class="page-links">' . __( 'Pages:', 'generatepress' ),
'after' => '</div>',
)
);
?>
<h2>Get Started:</h2>
<ol>
<li><a href="/membership-account/your-profile/">Save your CloudFlare API Credentials</a></li>
<li><a href="/dashboard/domains/edit-domain/">Add a Domain and verify DNS records</a></li>
<li><a href="/dashboard/email-accounts/edit-email-account/">Add one or more Email Accounts</a></li>
<li><a href="/dashboard/campaigns/edit-campaign/">Create a Campaign</a></li>
</ol>
</div>
<?php
/**
* generate_after_entry_content hook.
*
* @since 0.1
*
* @hooked generate_footer_meta - 10
*/
do_action( 'generate_after_entry_content' );
/**
* generate_after_content hook.
*
* @since 0.1
*/
do_action( 'generate_after_content' );
?>
</div>
</article>
<?php
endwhile;
}
/**
* generate_after_main_content hook.
*
* @since 0.1
*/
do_action( 'generate_after_main_content' );
?>
</main>
</div>
<?php
/**
* generate_after_primary_content_area hook.
*
* @since 2.0
*/
do_action( 'generate_after_primary_content_area' );
generate_construct_sidebars();
get_footer();

186
page-domains.php Normal file
View file

@ -0,0 +1,186 @@
<?php
/**
* Template Name: Domain List template
* Template Post Type: page
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
$items_per_page = isset($_GET['per_page']) ? intval($_GET['per_page']) : 10;
get_header(); ?>
<div <?php generate_do_attr( 'content' ); ?>>
<main <?php generate_do_attr( 'main' ); ?>>
<?php
/**
* generate_before_main_content hook.
*
* @since 0.1
*/
do_action( 'generate_before_main_content' );
if ( generate_has_default_loop() ) {
while ( have_posts() ) :
the_post();
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?> <?php generate_do_microdata( 'article' ); ?>>
<div class="inside-article">
<?php
/**
* generate_before_content hook.
*
* @since 0.1
*
* @hooked generate_featured_page_header_inside_single - 10
*/
do_action( 'generate_before_content' );
if ( generate_show_entry_header() ) :
?>
<header <?php generate_do_attr( 'entry-header' ); ?>>
<?php
/**
* generate_before_entry_title hook.
*
* @since 0.1
*/
do_action( 'generate_before_entry_title' );
// if ( generate_show_title() ) {
// $params = generate_get_the_title_parameters();
// the_title( $params['before'], $params['after'] );
// }
?>
<!-- Items per page dropdown -->
<div class="tablenav top">
<div class="alignright tablenav-actions">
<form method="get" class="items-per-page-form" id="items-per-page-form">
<select name="per_page" id="per_page" onchange="handlePerPageChange(this)">
<?php
$options = array(10, 25, 50, 100);
foreach ($options as $option) {
printf(
'<option value="%1$d" %2$s>%1$d per page</option>',
$option,
selected($items_per_page, $option, false)
);
}
?>
</select>
<?php
// Maintain any existing query parameters except paged
foreach ($_GET as $key => $value) {
if ($key !== 'per_page' && $key !== 'paged') {
echo '<input type="hidden" name="' . esc_attr($key) . '" value="' . esc_attr($value) . '">';
}
}
?>
</form>
</div>
</div>
<?php
/**
* generate_after_entry_title hook.
*
* @since 0.1
*
* @hooked generate_post_meta - 10
*/
do_action( 'generate_after_entry_title' );
?>
</header>
<?php
endif;
/**
* generate_after_entry_header hook.
*
* @since 0.1
*
* @hooked generate_post_image - 10
*/
do_action( 'generate_after_entry_header' );
$itemprop = '';
if ( 'microdata' === generate_get_schema_type() ) {
$itemprop = ' itemprop="text"';
}
?>
<div class="entry-content"<?php echo $itemprop; // phpcs:ignore -- No escaping needed. ?>>
<?php
$list = new PostTypeList('domain', [
'title' => 'My Domains',
'no_items' => 'You haven\'t added any domains yet.',
'delete_confirm' => 'Are you sure you want to delete this domain? This action cannot be undone.'
]);
$list->render();
// the_content();
// wp_link_pages(
// array(
// 'before' => '<div class="page-links">' . __( 'Pages:', 'generatepress' ),
// 'after' => '</div>',
// )
// );
?>
</div>
<?php
/**
* generate_after_entry_content hook.
*
* @since 0.1
*
* @hooked generate_footer_meta - 10
*/
do_action( 'generate_after_entry_content' );
/**
* generate_after_content hook.
*
* @since 0.1
*/
do_action( 'generate_after_content' );
?>
</div>
</article>
<?php
endwhile;
}
/**
* generate_after_main_content hook.
*
* @since 0.1
*/
do_action( 'generate_after_main_content' );
?>
</main>
</div>
<?php
/**
* generate_after_primary_content_area hook.
*
* @since 2.0
*/
do_action( 'generate_after_primary_content_area' );
generate_construct_sidebars();
get_footer();

439
page-edit-campaign.php Normal file
View file

@ -0,0 +1,439 @@
<?php
/**
* Template Name: Campaign Edit template
* Template Post Type: page
*/
if (!defined('ABSPATH')) {
exit;
}
// log_to_file("Campaign Edit template - Loaded");
$current_user_id = get_current_user_id();
$message = false;
$new_post = true;
$professions = [];
// log_to_file("Campaign Edit template - Current user ID: $current_user_id");
// log_to_file("Campaign Edit template - Server Request Method: ", $_SERVER['REQUEST_METHOD']);
// log_to_file("Campaign Edit template - Post Data: ", $_POST);
// Handle form submission
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['campaign_submit'])) {
// log_to_file("Campaign Edit template - Handling post request");
$post_data = array(
'post_title' => sanitize_text_field($_POST['campaign_name']),
'post_type' => 'campaign',
'post_status' => 'publish'
);
if (isset($_POST['post_id']) && !empty($_POST['post_id'])) {
// log_to_file("Campaign Edit template - Updating campaign");
$post_data['ID'] = intval($_POST['post_id']);
$post_id = wp_update_post($post_data);
$new_post = false;
$message = ['status' => 'success', 'message' => 'Campaign updated successfully.'];
} else {
// log_to_file("Campaign Edit template - Creating new campaign");
$post_id = wp_insert_post($post_data);
$message = ['status' => 'success', 'message' => 'Campaign added successfully.'];
}
if (!is_wp_error($post_id)) {
// log_to_file("Campaign Edit template - Create/update successful!");
$acf_fields = [
'domain_id',
'email_accounts',
// 'num_additional_emails',
'start_date',
'warmup_period',
'starting_volume',
'target_volume',
'target_profession',
'target_profession_other',
'campaign_conversation_topics'
];
foreach ($acf_fields as $field) {
if (isset($_POST[$field])) {
// log_to_file("Campaign Edit template - Checking for $field in POST: ", $_POST[$field]);
switch ($field) {
case 'email_accounts':
// log_to_file("Campaign Edit template - Found email_accounts in POST", $_POST[$field]);
update_field($field, $_POST[$field], $post_id);
break;
case 'domain_id':
// log_to_file("Campaign Edit template - Found domain in POST", $_POST['domain_id']);
try {
update_field('domain', $_POST['domain_id'], $post_id);
} catch (Exception $e) {
throw new Exception(__('fetch_dns_records - Campaign Edit template: Unable to update domain field for Campaign', 'rl-mailwarmer') . $e->getMessage());
}
break;
default:
update_field($field, sanitize_text_field($_POST[$field]), $post_id);
break;
}
}
}
// log_to_file("Campaign Edit template - Setting campaign owner_id to $current_user_id");
update_post_meta($post_id, 'owner_id', $current_user_id);
// Run a domain health check
$campaign_timeline = RL_MailWarmer_Campaign_Helper::calculate_campaign_timeline($post_id);
log_to_file("Campaign Edit template - Campaign timeline: ", $campaign_timeline);
} else {
$message = ['status' => 'error', 'message' => 'Error: ' . $post_id->get_error_message()];
}
if ( !(isset($_POST['stay_on_page']) && ($_POST['stay_on_page'] === 'on')) ) {
// log_to_file("Domain Edit template - stay_on_page not set; redirecting!");
wp_redirect( get_permalink( $post_id ) );
exit;
}
} else {
// log_to_file("Campaign Edit template - Post request not set");
}
// Get existing post data if editing
if (isset($_GET['edit'])) {
$post_id = intval($_GET['edit']);
$new_post = false;
} else {
$post_id = 0;
}
$campaign_data = [
'campaign_name' => '',
'domain_id' => '',
'email_accounts' => [],
'num_additional_emails' => '',
'start_date' => '',
'warmup_period' => '8',
'starting_volume' => '5',
'target_volume' => '50',
'target_profession' => '',
'target_profession_other' => '',
'campaign_conversation_topics' => ''
];
if ($post_id > 0) {
$post_item = get_post($post_id);
if ($post_item && $post_item->post_type === 'campaign') {
$campaign_data['campaign_name'] = $post_item->post_title;
foreach ($campaign_data as $key => $value) {
if ($key !== 'campaign_name') {
switch ($key) {
case 'domain_id':
$domain_id = get_field('domain', $post_id);
$campaign_data[$key] = $domain_id->ID;
break;
case 'email_accounts':
$email_accounts = get_field($key, $post_id);
// log_to_file("Campaign Edit template - Email accounts: ", $email_accounts);
$campaign_data[$key] = $email_accounts;
break;
case 'start_date':
$start_date = get_field($key, $post_id);
$campaign_data[$key] = date('Y-m-d', strtotime($start_date));
break;
default:
$campaign_data[$key] = get_field($key, $post_id);
break;
}
// if ($key === 'domain_id') {
// $domain_id = get_field('domain', $post_id);
// $campaign_data[$key] = $domain_id->ID;
// } else {
// $campaign_data[$key] = get_field($key, $post_id);
// }
}
}
}
}
// Get domains for current user
$domains = get_posts([
'orderby' => 'title',
'order' => 'ASC',
'post_type' => 'domain',
'posts_per_page' => -1,
'meta_query' => [
[
'key' => 'owner_id',
'value' => $current_user_id
]
]
]);
// log_to_file("Campaign Edit template - Domains: ", $domains);
// Get the list of default professions
$professions = rl_get_textarea_meta_as_array('option', 'default_profession_pool');
// log_to_file("Campaign Edit template - Professions: ", $professions);
get_header(); ?>
<div <?php generate_do_attr('content'); ?>>
<main <?php generate_do_attr('main'); ?>>
<?php do_action('generate_before_main_content');
if (generate_has_default_loop()) {
while (have_posts()) :
the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?> <?php generate_do_microdata('article'); ?>>
<div class="inside-article mf-dashboard-page">
<header <?php generate_do_attr('entry-header'); ?>>
<?php if ($message): ?>
<div class="notice notice-<?php echo $message['status']; ?> is-dismissible">
<p><?php echo esc_html($message['message']); ?></p>
<button type="button" class="notice-dismiss">
<span class="screen-reader-text">Dismiss this notice.</span>
</button>
</div>
<?php endif; ?>
</header>
<div class="entry-content">
<div class="wrap">
<h1><?php echo $post_id ? 'Edit Campaign' : 'Add New Campaign'; ?></h1>
<form method="post" action="" class="mf-dashboard-form">
<?php wp_nonce_field('campaign_form_nonce', 'campaign_nonce'); ?>
<?php if ($post_id) : ?>
<input type="hidden" name="post_id" value="<?php echo esc_attr($post_id); ?>">
<?php endif; ?>
<div class="mf-form-field-block">
<table class="mf-form-table">
<tr>
<th><label for="campaign_name">Campaign Name</label></th>
<td>
<input type="text" id="campaign_name" name="campaign_name"
value="<?php echo esc_attr($campaign_data['campaign_name']); ?>"
class="regular-text" required>
</td>
</tr>
<tr>
<th><label for="domain_id">Domain</label></th>
<td>
<select id="domain_id" name="domain_id" required>
<option value="">Select Domain</option>
<?php foreach ($domains as $domain) : ?>
<option value="<?php echo $domain->ID; ?>"<?php selected($campaign_data['domain_id'], $domain->ID); ?>><?php echo esc_html($domain->post_title); ?></option>
<?php endforeach; ?>
</select>
</td>
</tr>
<tr>
<th><label for="email_accounts">Email Accounts</label></th>
<td>
<select id="email_accounts" name="email_accounts[]" multiple required class="email-accounts-select">
<?php
$email_accounts = get_posts([
'post_type' => 'email-account',
'posts_per_page' => -1,
'meta_query' => [
[
'key' => 'owner_id',
'value' => $current_user_id
]
]
]);
$selected_accounts = isset($campaign_data['email_accounts']) ? $campaign_data['email_accounts'] : [];
// log_to_file("Selected email accounts: ", $selected_accounts);
foreach ($email_accounts as $account) :
$account_id = $account->ID;
$account_name = $account->post_title; ?>
<option value="<?php echo esc_attr($account_id); ?>"<?php echo in_array($account_id, $selected_accounts) ? 'selected' : ''; ?>><?php echo esc_html($account_name); ?></option>
<?php endforeach; ?>
</select>
</td>
</tr>
<!-- <tr>
<th><label for="num_additional_emails">Number of Additional Emails</label></th>
<td>
<input type="number" id="num_additional_emails" name="num_additional_emails"
value="<?php //echo esc_attr($campaign_data['num_additional_emails']); ?>"
class="small-text" required>
</td>
</tr> -->
<tr>
<th><label for="start_date">Start Date</label></th>
<td>
<input type="date" id="start_date" name="start_date"
value="<?php echo esc_attr($campaign_data['start_date']); ?>" required>
</td>
</tr>
<tr>
<th><label for="warmup_period">Warmup Period (in weeks)</label></th>
<td>
<input type="number" id="warmup_period" name="warmup_period"
value="<?php echo esc_attr($campaign_data['warmup_period']); ?>"
class="small-text" min="2" max="52" placeholder="8" required>
</td>
</tr>
<tr>
<th><label for="starting_volume">Starting Daily Volume</label></th>
<td>
<input type="number" id="starting_volume" name="starting_volume"
value="<?php echo esc_attr($campaign_data['starting_volume']); ?>"
class="small-text" min="1" max="50" placeholder="5" required>
</td>
</tr>
<tr>
<th><label for="target_volume">Target Daily Volume</label></th>
<td>
<input type="number" id="target_volume" name="target_volume"
value="<?php echo esc_attr($campaign_data['target_volume']); ?>"
class="small-text" min="10" max="1000" placeholder="50" required>
</td>
</tr>
<tr>
<th><label for="target_profession">Target Profession</label></th>
<td>
<select id="target_profession" name="target_profession" required>
<option value="">Select Profession</option>
<?php foreach ($professions as $profession) :
?>
<option value="<?php echo htmlentities($profession); ?>"<?php selected($campaign_data['target_profession'], $profession); ?>><?php echo htmlentities($profession); ?></option>
<?php endforeach; ?>
</select>
</td>
</tr>
<tr>
<th><label for="target_profession_other">Other Profession</label></th>
<td>
<input type="text" id="target_profession_other" name="target_profession_other"
value="<?php echo esc_attr($campaign_data['target_profession_other']); ?>"
class="regular-text">
</td>
</tr>
<tr>
<th><label for="campaign_conversation_topics">Conversation Topics</label></th>
<td>
<textarea id="campaign_conversation_topics" name="campaign_conversation_topics"
class="regular-text" rows="5"><?php echo esc_textarea($campaign_data['campaign_conversation_topics']); ?></textarea>
</td>
</tr>
</table>
</div>
<p class="submit">
<input type="submit" name="campaign_submit" class="button button-primary"
value="<?php echo $post_id ? 'Update Campaign' : 'Add Campaign'; ?>">
</p>
<?php if ($new_post) : ?>
<div class="mf-form-field-block">
<label for="stay_on_page">Stay on this page to create another?</label>
<input type="checkbox"
id="stay_on_page"
name="stay_on_page"
class="">
</div>
<?php endif; ?>
</form>
</div>
</div>
</div>
</article>
<?php endwhile;
wp_reset_postdata();
}
do_action('generate_after_main_content'); ?>
</main>
</div>
<script>
jQuery(document).ready(function($) {
/*
* Filter email accounts to only display those matching the selected domain
*
*/
const $domainSelect = $('#domain_id');
const $emailSelect = $('#email_accounts');
const $emailOptions = $emailSelect.find('option');
function filterEmailAccounts() {
const selectedDomain = $domainSelect.val();
console.log("Filtering for " + selectedDomain);
$emailOptions.hide();
if (selectedDomain) {
$emailOptions.each(function() {
const $option = $(this);
const email = $option.text();
// console.log("Checking " + email);
const domain = $domainSelect.find('option:selected').text();
// console.log("Domain " + domain);
if (email.endsWith('@' + domain)) {
// console.log("Showing this option");
$option.show();
}
});
}
}
$domainSelect.on('change', function() {
$emailSelect.val([]); // Clear selection
filterEmailAccounts();
});
// Initial filter
filterEmailAccounts();
/*
* Show the Other Profession field when the Target Profession is set to "Other"
*
*/
const $professionSelect = $('#target_profession');
const $otherField = $('#target_profession_other').closest('tr');
function toggleOtherField() {
if ($professionSelect.val() === 'Other') {
$otherField.show();
} else {
$otherField.hide();
$('#target_profession_other').val('');
}
}
$professionSelect.on('change', toggleOtherField);
// Initial state
toggleOtherField();
});
</script>
<?php
do_action('generate_after_primary_content_area');
generate_construct_sidebars();
get_footer();

338
page-edit-domain.php Normal file
View file

@ -0,0 +1,338 @@
<?php
/**
* Template Name: Domain Edit template
* Template Post Type: page
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
$current_user_id = get_current_user_id();
$message = false;
$new_post = true;
// Handle form submission
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['domain_submit'])) {
$post_title = sanitize_text_field($_POST['domain_name']);
$cloudflare_email = isset($_POST['cloudflare_api_email']) ? sanitize_email($_POST['cloudflare_api_email']) : '';
$cloudflare_key = isset($_POST['cloudflare_api_key']) ? sanitize_text_field($_POST['cloudflare_api_key']) : '';
$domain_in_use = isset($_POST['domain_in_use']) ? $_POST['domain_in_use'] : '';
$post_data = array(
'post_title' => $post_title,
'post_type' => 'domain',
'post_status' => 'publish'
);
// Check if editing existing post
if (isset($_POST['post_id']) && !empty($_POST['post_id'])) {
$post_data['ID'] = intval($_POST['post_id']);
$post_id = wp_update_post($post_data);
$new_post = false;
$message = ['status' => 'success', 'message' => 'Domain updated successfully.'];
} else {
$post_id = wp_insert_post($post_data);
$message = ['status' => 'success', 'message' => 'Domain added successfully.'];
}
if (!is_wp_error($post_id)) {
update_post_meta($post_id, 'cloudflare_api_email', $cloudflare_email);
update_post_meta($post_id, 'cloudflare_api_key', $cloudflare_key);
update_post_meta($post_id, 'domain_in_use', $domain_in_use);
if ($new_post) {
// set the owner_id to the creator of the post if this is a new domain
update_post_meta($post_id, 'owner_id', $current_user_id);
// Run a domain health check
$domain_report_id = RL_MailWarmer_Domain_Helper::save_domain_health_report($post_id);
}
} else {
$message = ['status' => 'error', 'message' => 'Error: ' . $post_id->get_error_message()];
// $message = 'Error: ' . $post_id->get_error_message();
}
if (isset($_POST['update_dns']) && !empty($_POST['update_dns'])) {
log_to_file("Domain Edit template - Running Fix Domain");
$results = RL_MailWarmer_Domain_Helper::fix_deliverability_dns_issues($post_id);
log_to_file("Domain Edit template - Results: ", $results);
}
if ( !(isset($_POST['stay_on_page']) && ($_POST['stay_on_page'] === 'on')) ) {
// log_to_file("Domain Edit template - stay_on_page not set; redirecting!");
wp_redirect( get_permalink( $post_id ) );
exit;
}
}
// Get existing post data if editing
if (isset($_GET['edit'])) {
$post_id = intval($_GET['edit']);
$new_post = false;
} else {
$post_id = 0;
}
$domain_name = '';
$cloudflare_email = '';
$cloudflare_key = '';
$domain_in_use = '';
if ($post_id > 0) {
$post_item = get_post($post_id);
if ($post_item && $post_item->post_type === 'domain') {
$domain_name = $post_item->post_title;
$cloudflare_email = get_post_meta($post_id, 'cloudflare_api_email', true) ?: '';
$cloudflare_key = get_post_meta($post_id, 'cloudflare_api_key', true) ?: '';
$domain_in_use = get_post_meta($post_id, 'domain_in_use', true) ?: '';
}
}
get_header(); ?>
<div <?php generate_do_attr( 'content' ); ?>>
<main <?php generate_do_attr( 'main' ); ?>>
<?php
/**
* generate_before_main_content hook.
*
* @since 0.1
*/
do_action( 'generate_before_main_content' );
if ( generate_has_default_loop() ) {
while ( have_posts() ) :
the_post();
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?> <?php generate_do_microdata( 'article' ); ?>>
<div class="inside-article mf-dashboard-page">
<?php
/**
* generate_before_content hook.
*
* @since 0.1
*
* @hooked generate_featured_page_header_inside_single - 10
*/
do_action( 'generate_before_content' );
if ( generate_show_entry_header() ) :
?>
<header <?php generate_do_attr( 'entry-header' ); ?>>
<?php
/**
* generate_before_entry_title hook.
*
* @since 0.1
*/
do_action( 'generate_before_entry_title' );
if ($message): ?>
<div class="notice notice-<?php echo $message['status']; ?> is-dismissible">
<p><?php echo esc_html($message['message']); ?></p>
<button type="button" class="notice-dismiss">
<span class="screen-reader-text">Dismiss this notice.</span>
</button>
</div>
<?php endif;
// if ( generate_show_title() ) {
// $params = generate_get_the_title_parameters();
// the_title( $params['before'], $params['after'] );
// }
/**
* generate_after_entry_title hook.
*
* @since 0.1
*
* @hooked generate_post_meta - 10
*/
do_action( 'generate_after_entry_title' );
?>
</header>
<?php
endif;
/**
* generate_after_entry_header hook.
*
* @since 0.1
*
* @hooked generate_post_image - 10
*/
do_action( 'generate_after_entry_header' );
$itemprop = '';
if ( 'microdata' === generate_get_schema_type() ) {
$itemprop = ' itemprop="text"';
}
?>
<div class="entry-content"<?php echo $itemprop; // phpcs:ignore -- No escaping needed. ?>>
<div class="wrap">
<h1><?php echo $post_id ? 'Edit Domain' : 'Add New Domain'; ?></h1>
<form method="post" action="" class="mf-dashboard-form">
<?php wp_nonce_field('domain_form_nonce', 'domain_nonce'); ?>
<?php if ($post_id) : ?>
<input type="hidden" name="post_id" value="<?php echo esc_attr($post_id); ?>">
<?php endif; ?>
<div class="mf-form-field-block">
<table class="mf-form-table">
<tr>
<th><label for="domain_name">Domain Name</label></th>
<td>
<input type="text"
id="domain_name"
name="domain_name"
value="<?php echo esc_attr($domain_name); ?>"
class="regular-text"
required>
</td>
</tr>
<tr>
<th><label for="update_dns">Update DNS Settings?</label></th>
<td>
<input type="checkbox"
id="update_dns"
name="update_dns"
<?php echo $new_post ? 'checked' : ''; ?>
class="">
<span>Warning! This will attempt to update your DNS records!</span>
</td>
</tr>
<tr>
<th><label for="domain_in_use">Is this domain in use (already sending & receiving email)?</label></th>
<td>
<input type="checkbox"
id="domain_in_use"
name="domain_in_use"
<?php echo $domain_in_use || $new_post ? 'checked' : ''; ?>
class="">
<span>If the domain is already in use we won't change the MX records</span>
</td>
</tr>
</table>
</div>
<div class="mf-form-field-block advanced-settings">
<h3 class="advanced-toggle">CloudFlare Settings</h3>
<p>Only if different than the credentials in your profile</p>
<div class="advanced-content" style="display: none;">
<table class="mf-form-table">
<tr>
<th><label for="cloudflare_api_email">Cloudflare API Email</label></th>
<td>
<input type="email"
id="cloudflare_api_email"
name="cloudflare_api_email"
value="<?php echo esc_attr($cloudflare_email); ?>"
class="regular-text">
</td>
</tr>
<tr>
<th><label for="cloudflare_api_key">Cloudflare API Key</label></th>
<td>
<input type="password"
id="cloudflare_api_key"
name="cloudflare_api_key"
value="<?php echo esc_attr($cloudflare_key); ?>"
class="regular-text">
</td>
</tr>
</table>
</div>
</div>
<p class="submit">
<input type="submit"
name="domain_submit"
class="button button-primary"
value="<?php echo $post_id ? 'Update Domain' : 'Add Domain'; ?>">
</p>
<?php if ($new_post) : ?>
<div class="mf-form-field-block">
<label for="stay_on_page">Stay on this page to create another?</label>
<input type="checkbox"
id="stay_on_page"
name="stay_on_page"
class="">
</div>
<?php endif; ?>
</form>
</div>
<?php
// the_content();
// wp_link_pages(
// array(
// 'before' => '<div class="page-links">' . __( 'Pages:', 'generatepress' ),
// 'after' => '</div>',
// )
// );
?>
</div>
<?php
/**
* generate_after_entry_content hook.
*
* @since 0.1
*
* @hooked generate_footer_meta - 10
*/
do_action( 'generate_after_entry_content' );
/**
* generate_after_content hook.
*
* @since 0.1
*/
do_action( 'generate_after_content' );
?>
</div>
</article>
<?php
endwhile;
wp_reset_postdata();
}
/**
* generate_after_main_content hook.
*
* @since 0.1
*/
do_action( 'generate_after_main_content' );
?>
</main>
</div>
<?php
/**
* generate_after_primary_content_area hook.
*
* @since 2.0
*/
do_action( 'generate_after_primary_content_area' );
generate_construct_sidebars();
get_footer();

332
page-edit-email-account.php Normal file
View file

@ -0,0 +1,332 @@
<?php
/**
* Template Name: Email Account Edit template
* Template Post Type: page
*/
if (!defined('ABSPATH')) {
exit;
}
$current_user_id = get_current_user_id();
$message = false;
$new_post = true;
log_to_file("Email Account Edit template - Current user ID: $current_user_id");
log_to_file("Email Account Edit template - Server Request Method: ", $_SERVER['REQUEST_METHOD']);
log_to_file("Email Account Edit template - Post Data: ", $_POST);
// Handle form submission
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['email_submit']) && isset($_POST['email_address'])) {
$post_data = array(
'post_title' => sanitize_email($_POST['email_address']),
'post_type' => 'email-account',
'post_status' => 'publish'
);
$meta_fields = [
'domain_id', 'mail_password', 'full_name', 'email_signature',
'email_provider', 'smtp_password', 'smtp_server', 'smtp_port',
'imap_password', 'imap_server', 'imap_port'
];
if (isset($_POST['post_id']) && !empty($_POST['post_id'])) {
$post_data['ID'] = intval($_POST['post_id']);
$post_id = wp_update_post($post_data);
$new_post = false;
$message = ['status' => 'success', 'message' => 'Email account updated successfully.'];
} else {
$post_id = wp_insert_post($post_data);
$message = ['status' => 'success', 'message' => 'Email account added successfully.'];
}
if (!is_wp_error($post_id)) {
foreach ($meta_fields as $field) {
if (isset($_POST[$field])) {
update_post_meta($post_id, $field, sanitize_text_field($_POST[$field]));
}
}
// include new accounts in the warmup pool and set the owner_id to the creator of the post
if ($new_post) {
update_post_meta($post_id, 'owner_id', $current_user_id);
update_post_meta($post_id, 'include_in_warmup_pool', $current_user_id);
}
} else {
$message = ['status' => 'error', 'message' => 'Error: ' . $post_id->get_error_message()];
}
if ( !(isset($_POST['stay_on_page']) && ($_POST['stay_on_page'] === 'on')) ) {
// log_to_file("Email Account Edit template - stay_on_page not set; redirecting!");
wp_redirect( get_permalink( $post_id ) );
exit;
}
}
// Get existing post data if editing
if (isset($_GET['edit'])) {
$post_id = intval($_GET['edit']);
$new_post = false;
} else {
$post_id = 0;
}
$email_data = [
'email_address' => '',
'domain_id' => '',
'mail_password' => '',
'full_name' => '',
'email_signature' => '',
'email_provider' => '',
'smtp_password' => '',
'smtp_server' => '',
'smtp_port' => '',
'imap_password' => '',
'imap_server' => '',
'imap_port' => ''
];
if ($post_id > 0) {
$post_item = get_post($post_id);
if ($post_item && $post_item->post_type === 'email-account') {
$email_data['email_address'] = $post_item->post_title;
foreach ($email_data as $key => $value) {
if ($key !== 'email_address') {
$email_data[$key] = get_post_meta($post_id, $key, true);
}
}
}
}
// Get domains for current user
$domains = get_posts([
'orderby' => 'title',
'order' => 'ASC',
'post_type' => 'domain',
'posts_per_page' => -1,
'meta_query' => [
[
'key' => 'owner_id',
'value' => $current_user_id
]
]
]);
// Get email providers
$providers = get_posts([
'orderby' => 'title',
'order' => 'ASC',
'post_type' => 'email-provider',
'posts_per_page' => -1
]);
get_header(); ?>
<div <?php generate_do_attr('content'); ?>>
<main <?php generate_do_attr('main'); ?>>
<?php do_action('generate_before_main_content');
if (generate_has_default_loop()) {
while (have_posts()) :
the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?> <?php generate_do_microdata('article'); ?>>
<div class="inside-article mf-dashboard-page">
<header <?php generate_do_attr('entry-header'); ?>>
<?php if ($message): ?>
<div class="notice notice-<?php echo $message['status']; ?> is-dismissible">
<p><?php echo esc_html($message['message']); ?></p>
<button type="button" class="notice-dismiss">
<span class="screen-reader-text">Dismiss this notice.</span>
</button>
</div>
<?php endif; ?>
</header>
<div class="entry-content">
<div class="wrap">
<h1><?php echo $post_id ? 'Edit Email Account' : 'Add New Email Account'; ?></h1>
<form method="post" action="" class="mf-dashboard-form">
<?php wp_nonce_field('email_form_nonce', 'email_nonce'); ?>
<?php if ($post_id) : ?>
<input type="hidden" name="post_id" value="<?php echo esc_attr($post_id); ?>">
<?php endif; ?>
<div class="mf-form-field-block">
<table class="mf-form-table">
<tr>
<th><label for="domain_id">Domain</label></th>
<td>
<select id="domain_id" name="domain_id" required>
<option value="">Select Domain</option>
<?php foreach ($domains as $domain) : ?>
<option value="<?php echo esc_attr($domain->ID); ?>"<?php selected($email_data['domain_id'], $domain->ID); ?>><?php echo esc_html($domain->post_title); ?></option>
<?php endforeach; ?>
</select>
</td>
</tr>
<tr>
<th><label for="email_address">Email Address</label></th>
<td>
<input type="email" id="email_address" name="email_address"
value="<?php echo esc_attr($email_data['email_address']); ?>"
class="regular-text" required>
</td>
</tr>
<tr>
<th><label for="mail_password">Mail Password</label></th>
<td>
<input type="password" id="mail_password" name="mail_password"
value="<?php echo esc_attr($email_data['mail_password']); ?>"
class="regular-text" required>
</td>
</tr>
<tr>
<th><label for="full_name">Full Name</label></th>
<td>
<input type="text" id="full_name" name="full_name"
value="<?php echo esc_attr($email_data['full_name']); ?>"
class="regular-text" required>
</td>
</tr>
<tr>
<th><label for="email_signature">Email Signature</label></th>
<td>
<textarea id="email_signature" name="email_signature"
class="regular-text"><?php echo esc_textarea($email_data['email_signature']); ?></textarea>
</td>
</tr>
<tr>
<th><label for="email_provider">Email Provider</label></th>
<td>
<select id="email_provider" name="email_provider" required>
<option value="">Select Provider</option>
<?php foreach ($providers as $provider) : ?>
<option value="<?php echo esc_attr($provider->ID); ?>"<?php selected($email_data['email_provider'], $provider->ID); ?>><?php echo esc_html($provider->post_title); ?></option>
<?php endforeach; ?>
</select>
</td>
</tr>
</table>
</div>
<div class="mf-form-field-block advanced-settings">
<h3 class="advanced-toggle">Advanced Settings</h3>
<div class="advanced-content" style="display: none;">
<table class="mf-form-table">
<tr>
<th><label for="smtp_password">SMTP Password</label></th>
<td>
<input type="password" id="smtp_password" name="smtp_password"
value="<?php echo esc_attr($email_data['smtp_password']); ?>"
class="regular-text">
</td>
</tr>
<tr>
<th><label for="smtp_server">SMTP Server</label></th>
<td>
<input type="text" id="smtp_server" name="smtp_server"
value="<?php echo esc_attr($email_data['smtp_server']); ?>"
class="regular-text">
</td>
</tr>
<tr>
<th><label for="smtp_port">SMTP Port</label></th>
<td>
<input type="number" id="smtp_port" name="smtp_port"
value="<?php echo esc_attr($email_data['smtp_port']); ?>"
class="small-text">
</td>
</tr>
<tr>
<th><label for="imap_password">IMAP Password</label></th>
<td>
<input type="password" id="imap_password" name="imap_password"
value="<?php echo esc_attr($email_data['imap_password']); ?>"
class="regular-text">
</td>
</tr>
<tr>
<th><label for="imap_server">IMAP Server</label></th>
<td>
<input type="text" id="imap_server" name="imap_server"
value="<?php echo esc_attr($email_data['imap_server']); ?>"
class="regular-text">
</td>
</tr>
<tr>
<th><label for="imap_port">IMAP Port</label></th>
<td>
<input type="number" id="imap_port" name="imap_port"
value="<?php echo esc_attr($email_data['imap_port']); ?>"
class="small-text">
</td>
</tr>
</table>
</div>
</div>
<p class="submit">
<input type="submit" name="email_submit" class="button button-primary"
value="<?php echo $post_id ? 'Update Email Account' : 'Add Email Account'; ?>">
</p>
<?php if ($new_post) : ?>
<div class="mf-form-field-block">
<label for="stay_on_page">Stay on this page to create another?</label>
<input type="checkbox"
id="stay_on_page"
name="stay_on_page"
class="">
</div>
<?php endif; ?>
</form>
</div>
</div>
</div>
</article>
<?php endwhile;
wp_reset_postdata();
}
do_action('generate_after_main_content'); ?>
</main>
</div>
<script>
jQuery(document).ready(function($) {
// Email validation function
function validateEmail() {
var domain_id = $("#domain_id").val();
var email = $("#email_address").val();
if (!domain_id || !email) return true;
var domain_text = $("#domain_id option:selected").text();
var emailDomain = email.split("@")[1];
if (emailDomain !== domain_text) {
alert("Email address must match the selected domain: " + domain_text);
return false;
}
return true;
}
// Add validation to form submission
$("form").on("submit", function(e) {
if (!validateEmail()) {
e.preventDefault();
}
});
// Optional: Real-time validation as user types
$("#email_address, #domain_id").on("change", validateEmail);
});
</script>
<?php
do_action('generate_after_primary_content_area');
generate_construct_sidebars();
get_footer();

186
page-email-accounts.php Normal file
View file

@ -0,0 +1,186 @@
<?php
/**
* Template Name: Email Account List template
* Template Post Type: page
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
$items_per_page = isset($_GET['per_page']) ? intval($_GET['per_page']) : 10;
get_header(); ?>
<div <?php generate_do_attr( 'content' ); ?>>
<main <?php generate_do_attr( 'main' ); ?>>
<?php
/**
* generate_before_main_content hook.
*
* @since 0.1
*/
do_action( 'generate_before_main_content' );
if ( generate_has_default_loop() ) {
while ( have_posts() ) :
the_post();
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?> <?php generate_do_microdata( 'article' ); ?>>
<div class="inside-article">
<?php
/**
* generate_before_content hook.
*
* @since 0.1
*
* @hooked generate_featured_page_header_inside_single - 10
*/
do_action( 'generate_before_content' );
if ( generate_show_entry_header() ) :
?>
<header <?php generate_do_attr( 'entry-header' ); ?>>
<?php
/**
* generate_before_entry_title hook.
*
* @since 0.1
*/
do_action( 'generate_before_entry_title' );
// if ( generate_show_title() ) {
// $params = generate_get_the_title_parameters();
// the_title( $params['before'], $params['after'] );
// }
?>
<!-- Items per page dropdown -->
<div class="tablenav top">
<div class="alignright tablenav-actions">
<form method="get" class="items-per-page-form" id="items-per-page-form">
<select name="per_page" id="per_page" onchange="handlePerPageChange(this)">
<?php
$options = array(10, 25, 50, 100);
foreach ($options as $option) {
printf(
'<option value="%1$d" %2$s>%1$d per page</option>',
$option,
selected($items_per_page, $option, false)
);
}
?>
</select>
<?php
// Maintain any existing query parameters except paged
foreach ($_GET as $key => $value) {
if ($key !== 'per_page' && $key !== 'paged') {
echo '<input type="hidden" name="' . esc_attr($key) . '" value="' . esc_attr($value) . '">';
}
}
?>
</form>
</div>
</div>
<?php
/**
* generate_after_entry_title hook.
*
* @since 0.1
*
* @hooked generate_post_meta - 10
*/
do_action( 'generate_after_entry_title' );
?>
</header>
<?php
endif;
/**
* generate_after_entry_header hook.
*
* @since 0.1
*
* @hooked generate_post_image - 10
*/
do_action( 'generate_after_entry_header' );
$itemprop = '';
if ( 'microdata' === generate_get_schema_type() ) {
$itemprop = ' itemprop="text"';
}
?>
<div class="entry-content"<?php echo $itemprop; // phpcs:ignore -- No escaping needed. ?>>
<?php
$list = new PostTypeList('email-account', [
'title' => 'Email Accounts',
'no_items' => 'You haven\'t added any email accounts yet.',
'delete_confirm' => 'Are you sure you want to delete this email-account? This action cannot be undone.'
]);
$list->render();
// the_content();
// wp_link_pages(
// array(
// 'before' => '<div class="page-links">' . __( 'Pages:', 'generatepress' ),
// 'after' => '</div>',
// )
// );
?>
</div>
<?php
/**
* generate_after_entry_content hook.
*
* @since 0.1
*
* @hooked generate_footer_meta - 10
*/
do_action( 'generate_after_entry_content' );
/**
* generate_after_content hook.
*
* @since 0.1
*/
do_action( 'generate_after_content' );
?>
</div>
</article>
<?php
endwhile;
}
/**
* generate_after_main_content hook.
*
* @since 0.1
*/
do_action( 'generate_after_main_content' );
?>
</main>
</div>
<?php
/**
* generate_after_primary_content_area hook.
*
* @since 2.0
*/
do_action( 'generate_after_primary_content_area' );
generate_construct_sidebars();
get_footer();

BIN
screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

41
sidebar-left.php Normal file
View file

@ -0,0 +1,41 @@
<?php
/**
* The Sidebar containing the main widget areas.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
?>
<div <?php generate_do_attr( 'left-sidebar' ); ?>>
<div class="inside-left-sidebar">
<?php
/**
* generate_before_left_sidebar_content hook.
*
* @since 0.1
*/
do_action( 'generate_before_left_sidebar_content' );
if (is_singular('domain')) {
dynamic_sidebar('sidebar-domain');
} elseif (is_singular('email-account')) {
dynamic_sidebar('sidebar-email');
} elseif (is_singular('campaign')) {
dynamic_sidebar('sidebar-campaign');
} elseif ( ! dynamic_sidebar( 'sidebar-2' ) ) {
generate_do_default_sidebar_widgets( 'left-sidebar' );
}
/**
* generate_after_left_sidebar_content hook.
*
* @since 0.1
*/
do_action( 'generate_after_left_sidebar_content' );
?>
</div>
</div>

149
single-campaign.php Normal file
View file

@ -0,0 +1,149 @@
<?php
/**
* The Template for displaying all single campaign posts.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
get_header(); ?>
<div <?php generate_do_attr( 'content' ); ?>>
<main <?php generate_do_attr( 'main' ); ?>>
<?php
/**
* generate_before_main_content hook.
*
* @since 0.1
*/
do_action( 'generate_before_main_content' );
if ( generate_has_default_loop() ) {
while ( have_posts() ) :
the_post();
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?> <?php generate_do_microdata( 'article' ); ?>>
<div class="inside-article">
<?php
/**
* generate_before_content hook.
*
* @since 0.1
*
* @hooked generate_featured_page_header_inside_single - 10
*/
do_action( 'generate_before_content' );
if ( generate_show_entry_header() ) :
?>
<header <?php generate_do_attr( 'entry-header' ); ?>>
<?php
/**
* generate_before_entry_title hook.
*
* @since 0.1
*/
do_action( 'generate_before_entry_title' );
if ( generate_show_title() ) {
$params = generate_get_the_title_parameters();
the_title( $params['before'], $params['after'] );
}
/**
* generate_after_entry_title hook.
*
* @since 0.1
*
* @hooked generate_post_meta - 10
*/
do_action( 'generate_after_entry_title' );
?>
</header>
<?php
endif;
/**
* generate_after_entry_header hook.
*
* @since 0.1
*
* @hooked generate_post_image - 10
*/
do_action( 'generate_after_entry_header' );
$itemprop = '';
if ( 'microdata' === generate_get_schema_type() ) {
$itemprop = ' itemprop="text"';
}
?>
<div class="entry-content"<?php echo $itemprop; // phpcs:ignore -- No escaping needed. ?>>
<?php
$post = get_post();
rl_mailwarmer_display_campaign_timeline($post);
the_content();
wp_link_pages(
array(
'before' => '<div class="page-links">' . __( 'Pages:', 'generatepress' ),
'after' => '</div>',
)
);
?>
</div>
<?php
/**
* generate_after_entry_content hook.
*
* @since 0.1
*
* @hooked generate_footer_meta - 10
*/
do_action( 'generate_after_entry_content' );
/**
* generate_after_content hook.
*
* @since 0.1
*/
do_action( 'generate_after_content' );
?>
</div>
</article>
<?php
endwhile;
}
/**
* generate_after_main_content hook.
*
* @since 0.1
*/
do_action( 'generate_after_main_content' );
?>
</main>
</div>
<?php
/**
* generate_after_primary_content_area hook.
*
* @since 2.0
*/
do_action( 'generate_after_primary_content_area' );
generate_construct_sidebars();
get_footer();

234
single-domain.php Normal file
View file

@ -0,0 +1,234 @@
<?php
/**
* The Template for displaying all single domain posts.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
get_header(); ?>
<div <?php generate_do_attr( 'content' ); ?>>
<main <?php generate_do_attr( 'main' ); ?>>
<?php
/**
* generate_before_main_content hook.
*
* @since 0.1
*/
do_action( 'generate_before_main_content' );
if ( generate_has_default_loop() ) {
while ( have_posts() ) :
the_post();
// $post = get_the_post();
$post_id = get_the_ID();
$credentials = RL_MailWarmer_Domain_Helper::get_cloudflare_credentials($post);
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?> <?php generate_do_microdata( 'article' ); ?>>
<div class="inside-article">
<?php
/**
* generate_before_content hook.
*
* @since 0.1
*
* @hooked generate_featured_page_header_inside_single - 10
*/
do_action( 'generate_before_content' );
if ( generate_show_entry_header() ) :
?>
<header <?php generate_do_attr( 'entry-header' ); ?>>
<?php
/**
* generate_before_entry_title hook.
*
* @since 0.1
*/
do_action( 'generate_before_entry_title' );
if ( generate_show_title() ) {
$params = generate_get_the_title_parameters();
the_title( $params['before'], $params['after'] );
}
/**
* generate_after_entry_title hook.
*
* @since 0.1
*
* @hooked generate_post_meta - 10
*/
do_action( 'generate_after_entry_title' );
?>
</header>
<?php
endif;
/**
* generate_after_entry_header hook.
*
* @since 0.1
*
* @hooked generate_post_image - 10
*/
do_action( 'generate_after_entry_header' );
$itemprop = '';
if ( 'microdata' === generate_get_schema_type() ) {
$itemprop = ' itemprop="text"';
}
?>
<div class="entry-content"<?php echo $itemprop; // phpcs:ignore -- No escaping needed. ?>>
<div id="domain-tabs">
<ul>
<li><a href="#info_tab">Info</a></li>
<!-- <li><a href="#account_tab">Email Accounts</a></li>
<li><a href="#campaign_tab">Campaigns</a></li> -->
<li><a href="#report_tab">Health Report</a></li>
<li><a href="#tools_tab">Tools</a></li>
</ul>
<div id="info_tab">
<table class="credentials-table">
<tr>
<th>API Email</th>
<th>API Key</th>
<th>Zone ID</th>
<th>CloudFlare Connection</th>
</tr>
<tr>
<td><?php echo $credentials ? htmlspecialchars($credentials['api_email']) : ''; ?></td>
<td><?php echo $credentials ? htmlspecialchars(mask_api_key($credentials['api_key'])) : ''; ?></td>
<td><?php echo $credentials ? htmlspecialchars($credentials['zone_id']) : ''; ?></td>
<td><?php echo htmlspecialchars(get_connection_status($credentials)); ?></td>
</tr>
</table>
</div>
<!-- <div id="account_tab">
</div>
<div id="campaign_tab">
</div> -->
<div id="report_tab">
<?php rl_mailwarmer_render_domain_metadata_table($post); ?>
</div>
<div id="tools_tab">
<div>
<?php rl_mailwarmer_check_domain_health_box_callback($post); ?>
</div>
<div>
<?php rl_mailwarmer_render_fix_deliverability_dns_issues_box($post); ?>
</div>
<div>
</div>
</div>
</div>
<?php
// the_content();
// wp_link_pages(
// array(
// 'before' => '<div class="page-links">' . __( 'Pages:', 'generatepress' ),
// 'after' => '</div>',
// )
// );
?>
</div>
<?php
/**
* generate_after_entry_content hook.
*
* @since 0.1
*
* @hooked generate_footer_meta - 10
*/
do_action( 'generate_after_entry_content' );
/**
* generate_after_content hook.
*
* @since 0.1
*/
do_action( 'generate_after_content' );
?>
</div>
</article>
<?php
endwhile;
}
/**
* generate_after_main_content hook.
*
* @since 0.1
*/
do_action( 'generate_after_main_content' );
?>
</main>
</div>
<script>
jQuery(document).ready(function($) {
$('#domain-tabs').tabs();
// $('#check-domain-health-button').on('click', function (e) {
// e.preventDefault();
// var postId = <?php echo $post_id; ?>; // Get the current post ID
// var postData = {
// action: 'rl_mailwarmer_check_domain_health',
// post_id: rlMailWarmer_healthcheck.post_id,
// security: rlMailWarmer_healthcheck.nonce,
// };
// // console.log("AJAX URL: " + rlMailWarmer.ajax_url);
// // console.log("Post Action: " + postData.action);
// console.log("Post postId: " + rlMailWarmer_healthcheck.post_id);
// console.log("Post security: " + rlMailWarmer_healthcheck.post_id.nonce);
// $('#domain-health-result').html('<p>Checking domain health...</p>');
// // $.ajax({
// // url: rlMailWarmer_healthcheck.ajax_url,
// // type: 'POST',
// // data: postData,
// // success: function (response) {
// // if (response.success) {
// // $('#domain-health-result').html('<p>Report saved successfully. Post ID: ' + response.data + '</p>');
// // } else {
// // $('#domain-health-result').html('<p>Error: ' + response.data + '</p>');
// // }
// // },
// // error: function (xhr, status, error) {
// // $('#domain-health-result').html('<p>AJAX Error: ' + error + '</p>');
// // },
// // });
// });
});
</script>
<?php
/**
* generate_after_primary_content_area hook.
*
* @since 2.0
*/
do_action( 'generate_after_primary_content_area' );
generate_construct_sidebars();
get_footer();

148
single-email-account.php Normal file
View file

@ -0,0 +1,148 @@
<?php
/**
* The Template for displaying all single email-account posts.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
get_header(); ?>
<div <?php generate_do_attr( 'content' ); ?>>
<main <?php generate_do_attr( 'main' ); ?>>
<?php
/**
* generate_before_main_content hook.
*
* @since 0.1
*/
do_action( 'generate_before_main_content' );
if ( generate_has_default_loop() ) {
while ( have_posts() ) :
the_post();
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?> <?php generate_do_microdata( 'article' ); ?>>
<div class="inside-article">
<?php
/**
* generate_before_content hook.
*
* @since 0.1
*
* @hooked generate_featured_page_header_inside_single - 10
*/
do_action( 'generate_before_content' );
if ( generate_show_entry_header() ) :
?>
<header <?php generate_do_attr( 'entry-header' ); ?>>
<?php
/**
* generate_before_entry_title hook.
*
* @since 0.1
*/
do_action( 'generate_before_entry_title' );
if ( generate_show_title() ) {
$params = generate_get_the_title_parameters();
the_title( $params['before'], $params['after'] );
}
/**
* generate_after_entry_title hook.
*
* @since 0.1
*
* @hooked generate_post_meta - 10
*/
do_action( 'generate_after_entry_title' );
?>
</header>
<?php
endif;
/**
* generate_after_entry_header hook.
*
* @since 0.1
*
* @hooked generate_post_image - 10
*/
do_action( 'generate_after_entry_header' );
$itemprop = '';
if ( 'microdata' === generate_get_schema_type() ) {
$itemprop = ' itemprop="text"';
}
?>
<div class="entry-content"<?php echo $itemprop; // phpcs:ignore -- No escaping needed. ?>>
Hi, Bob.
<?php
the_content();
wp_link_pages(
array(
'before' => '<div class="page-links">' . __( 'Pages:', 'generatepress' ),
'after' => '</div>',
)
);
?>
</div>
<?php
/**
* generate_after_entry_content hook.
*
* @since 0.1
*
* @hooked generate_footer_meta - 10
*/
do_action( 'generate_after_entry_content' );
/**
* generate_after_content hook.
*
* @since 0.1
*/
do_action( 'generate_after_content' );
?>
</div>
</article>
<?php
endwhile;
}
/**
* generate_after_main_content hook.
*
* @since 0.1
*/
do_action( 'generate_after_main_content' );
?>
</main>
</div>
<?php
/**
* generate_after_primary_content_area hook.
*
* @since 2.0
*/
do_action( 'generate_after_primary_content_area' );
generate_construct_sidebars();
get_footer();

10
style.css Normal file
View file

@ -0,0 +1,10 @@
/*
Theme Name: Mailferno
Theme URI: https://mailferno.com
Description: Mailferno WordPress theme
Author: Ruben Ramirez
Author URI: https://redlotusaustin.com
Template: generatepress
Version: 0.1
*/