/**
Theme Name: Epixable Child
Author: Brainstorm Force
Author URI: http://wpastra.com/about/
Description: Astra is the fastest, fully customizable & beautiful theme suitable for blogs, personal portfolios and business websites. It is very lightweight (less than 50KB on frontend) and offers unparalleled speed. Built with SEO in mind, Astra comes with schema.org code integrated so search engines will love your site. Astra offers plenty of sidebar options and widget areas giving you a full control for customizations. Furthermore, we have included special features and templates so feel free to choose any of your favorite page builder plugin to create pages flexibly. Some of the other features: # WooCommerce Ready # Responsive # Compatible with major plugins # Translation Ready # Extendible with premium addons # Regularly updated # Designed, Developed, Maintained & Supported by Brainstorm Force. Looking for a perfect base theme? Look no further. Astra is fast, fully customizable and beautiful theme!
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: epixable-child
Template: astra
*/

<?php
/**
 * "Notify me" launch sign-up — handled entirely by WordPress.
 * Add this to your child theme's functions.php.
 */

add_action( 'wp_ajax_epx_notify_me', 'epx_handle_notify_me' );
add_action( 'wp_ajax_nopriv_epx_notify_me', 'epx_handle_notify_me' ); // allow logged-out visitors

function epx_handle_notify_me() {

    // Honeypot: a hidden field real visitors never fill in, bots often do.
    if ( ! empty( $_POST['epx_hp'] ) ) {
        wp_send_json_error( array( 'message' => 'Spam detected.' ) );
    }

    if ( empty( $_POST['email'] ) || ! is_email( wp_unslash( $_POST['email'] ) ) ) {
        wp_send_json_error( array( 'message' => 'Please enter a valid email address.' ) );
    }

    $email = sanitize_email( wp_unslash( $_POST['email'] ) );

    // 1) Email YOU when someone signs up
    $to      = 'yathin@epixable.com';
    $subject = 'New "notify me" sign-up';
    $body    = "A visitor signed up to be notified at launch:\n\nEmail: {$email}\nDate: " . current_time( 'mysql' );
    $headers = array( 'Content-Type: text/plain; charset=UTF-8' );

    $sent = wp_mail( $to, $subject, $body, $headers );

    // 2) Optional: also keep a running list in the database (uncomment to enable)
    // $list   = get_option( 'epx_notify_list', array() );
    // $list[] = array( 'email' => $email, 'date' => current_time( 'mysql' ) );
    // update_option( 'epx_notify_list', $list );

    if ( $sent ) {
        wp_send_json_success( array( 'message' => "You're on the list — we'll email you at launch." ) );
    } else {
        wp_send_json_error( array( 'message' => 'Something went wrong sending the notification. Please try again.' ) );
    }
}