0
X
Add Snippet To Project
New Project
Add To Existing Project
<?php
<?php
/**
* Plugin Name: WP Turbo Email Marketing
* Description: A full-featured email marketing system for managing email lists, campaigns, and more.
* Version: 1.0
* Author: WP Turbo
* Author URI: https://wpturbo.dev
* Text Domain: wpturbo
*/
namespace WPTurboEmailMarketing;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
// Register custom post type for email lists
function wpturbo_register_email_lists() {
$args = [
'labels' => [
'name' => __( 'Email Lists', 'wpturbo' ),
'singular_name' => __( 'Email List', 'wpturbo' ),
],
'public' => true,
'has_archive' => true,
'supports' => ['title', 'editor', 'custom-fields'],
];
register_post_type( 'email_list', $args );
}
add_action( 'init', 'WPTurboEmailMarketingwpturbo_register_email_lists' );
// SMTP settings page
function wpturbo_add_smtp_settings_page() {
add_options_page(
__( 'SMTP Settings', 'wpturbo' ),
__( 'SMTP Settings', 'wpturbo' ),
'manage_options',
'wpturbo-smtp-settings',
'wpturbo_render_smtp_settings_page'
);
}
add_action( 'admin_menu', 'WPTurboEmailMarketingwpturbo_add_smtp_settings_page' );
function wpturbo_render_smtp_settings_page() {
?>
<div class="wrap">
<h1><?php esc_html_e( 'SMTP Configuration', 'wpturbo' ); ?></h1>
<form method="post" action="options.php">
<?php
settings_fields( 'wpturbo_smtp_options' );
do_settings_sections( 'wpturbo_smtp_options' );
?>
<table class="form-table">
<tr valign="top">
<th scope="row"><?php esc_html_e( 'SMTP Host', 'wpturbo' ); ?></th>
<td><input type="text" name="smtp_host" value="<?php echo esc_attr( get_option('smtp_host') ); ?>" /></td>
</tr>
<tr valign="top">
<th scope="row"><?php esc_html_e( 'SMTP Port', 'wpturbo' ); ?></th>
<td><input type="number" name="smtp_port" value="<?php echo esc_attr( get_option('smtp_port') ); ?>" /></td>
</tr>
<tr valign="top">
<th scope="row"><?php esc_html_e( 'Username', 'wpturbo' ); ?></th>
<td><input type="text" name="smtp_username" value="<?php echo esc_attr( get_option('smtp_username') ); ?>" /></td>
</tr>
<tr valign="top">
<th scope="row"><?php esc_html_e( 'Password', 'wpturbo' ); ?></th>
<td><input type="password" name="smtp_password" value="<?php echo esc_attr( get_option('smtp_password') ); ?>" /></td>
</tr>
<tr valign="top">
<th scope="row"><?php esc_html_e( 'From Name', 'wpturbo' ); ?></th>
<td><input type="text" name="smtp_from_name" value="<?php echo esc_attr( get_option('smtp_from_name') ); ?>" /></td>
</tr>
<tr valign="top">
<th scope="row"><?php esc_html_e( 'From Email', 'wpturbo' ); ?></th>
<td><input type="email" name="smtp_from_email" value="<?php echo esc_attr( get_option('smtp_from_email') ); ?>" /></td>
</tr>
</table>
<?php submit_button(); ?>
</form>
</div>
<?php
}
function wpturbo_register_settings() {
register_setting( 'wpturbo_smtp_options', 'smtp_host' );
register_setting( 'wpturbo_smtp_options', 'smtp_port' );
register_setting( 'wpturbo_smtp_options', 'smtp_username' );
register_setting( 'wpturbo_smtp_options', 'smtp_password' );
register_setting( 'wpturbo_smtp_options', 'smtp_from_name' );
register_setting( 'wpturbo_smtp_options', 'smtp_from_email' );
}
add_action( 'admin_init', 'WPTurboEmailMarketingwpturbo_register_settings' );
This code establishes a basic framework for your email marketing plugin and lays the groundwork for further development of additional features like email campaign creation, automation, reporting, and more. You can build upon this foundation by implementing the remaining capabilities outlined in your request.
