require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($sql); add_action('after_switch_theme', 'mymail_create_table'); // Shortcode: [mymail_form] function mymail_subscription_form() ob_start(); ?> <form method="post" class="mymail-form"> <input type="email" name="mymail_email" placeholder="Your email address" required> <input type="text" name="mymail_name" placeholder="Your name (optional)"> <input type="submit" name="mymail_subscribe" value="Subscribe"> <?php wp_nonce_field('mymail_subscribe_action', 'mymail_nonce'); ?> </form> <?php return ob_get_clean();
<hr style="margin: 30px 0;">
// Create newsletter table on theme activation function mymail_create_table() global $wpdb; $table_name = $wpdb->prefix . 'mymail_subscribers'; $charset_collate = $wpdb->get_charset_collate(); $sql = "CREATE TABLE $table_name ( id mediumint(9) NOT NULL AUTO_INCREMENT, email varchar(100) NOT NULL, name varchar(100) DEFAULT '', status tinyint(1) DEFAULT 1, subscribed_at datetime DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (id), UNIQUE KEY email (email) ) $charset_collate;"; mymail wordpress
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>MyMail Newsletter</title> <style> body font-family: Arial, sans-serif; background: #f4f4f4; margin: 0; padding: 0; .container max-width: 600px; margin: 20px auto; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 5px rgba(0,0,0,0.1); .header background: #0073aa; color: #fff; padding: 20px; text-align: center; .content padding: 20px; line-height: 1.6; .footer background: #eee; padding: 15px; text-align: center; font-size: 12px; color: #777; .button display: inline-block; background: #0073aa; color: #fff; padding: 10px 20px; text-decoration: none; border-radius: 4px; @media only screen and (max-width: 600px) .container width: 100% !important; </style> </head> <body> <div class="container"> <div class="header"> <h1>📧 MyMail Newsletter</h1> </div> <div class="content"> <h2>Hello, [Subscriber Name]!</h2> <p>Here's your latest update from our website.</p> <h3>📝 Featured Post</h3> <p>Check out our newest article: <strong>10 Ways to Grow Your Email List</strong></p> <a href="https://yourwebsite.com/article" class="button">Read More →</a> require_once(ABSPATH
?> <div class="wrap"> <h1>MyMail Newsletter</h1> <h2>Subscribers (<?php echo count($subscribers); ?>)</h2> <ul> <?php foreach ($subscribers as $sub): ?> <li><?php echo esc_html($sub->email); ?> (<?php echo esc_html($sub->name); ?>)</li> <?php endforeach; ?> </ul> Use code: <strong>MYMAIL20</strong></p>
<h3>🔥 Hot Offers</h3> <p>Get 20% off all products this week only. Use code: <strong>MYMAIL20</strong></p>