| |
| <?php
|
| <?php
|
|
|
|
|
|
|
|
|
|
|
| function pcg_render_chess_form() {
|
|
|
| $message = '';
|
| if (isset($_POST['pcg_submit_book_request'])) {
|
| $message = pcg_handle_form_submission();
|
| }
|
|
|
|
|
| $nonce_field = wp_nonce_field('pcg_download_book_action', 'pcg_download_book_nonce', true, false);
|
|
|
|
|
| $time_trap = base64_encode(time());
|
|
|
| ob_start();
|
| ?>
|
| <style>
|
|
|
| :root {
|
| --pcg-primary:
|
| --pcg-accent:
|
| --pcg-text:
|
| --pcg-bg:
|
| --pcg-input-border:
|
| --pcg-radius: 4px;
|
| }
|
|
|
|
|
| .pcg-book-form {
|
| background: var(--pcg-bg);
|
| border: 1px solid
|
| border-left: 5px solid var(--pcg-primary);
|
| padding: 40px;
|
| border-radius: var(--pcg-radius);
|
| max-width: 600px;
|
| margin: 40px auto;
|
| font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
| box-shadow: 0 4px 12px rgba(0,0,0,0.05);
|
| }
|
|
|
| .pcg-book-form h3 {
|
| color: var(--pcg-primary);
|
| margin-top: 0;
|
| font-size: 24px;
|
| font-weight: 700;
|
| }
|
|
|
| .pcg-book-form p {
|
| color: var(--pcg-text);
|
| line-height: 1.6;
|
| margin-bottom: 25px;
|
| font-size: 15px;
|
| }
|
|
|
|
|
| .pcg-form-row {
|
| display: flex;
|
| gap: 15px;
|
| margin-bottom: 15px;
|
| }
|
| .pcg-field-group {
|
| flex: 1;
|
| display: flex;
|
| flex-direction: column;
|
| }
|
|
|
|
|
| @media (max-width: 480px) {
|
| .pcg-form-row { flex-direction: column; gap: 0; }
|
| .pcg-field-group { margin-bottom: 15px; }
|
| }
|
|
|
| .pcg-book-form label {
|
| font-size: 13px;
|
| font-weight: 600;
|
| color:
|
| margin-bottom: 5px;
|
| text-transform: uppercase;
|
| letter-spacing: 0.5px;
|
| }
|
|
|
| .pcg-book-form input[type="text"],
|
| .pcg-book-form input[type="email"],
|
| .pcg-book-form input[type="tel"] {
|
| width: 100%;
|
| padding: 12px;
|
| border: 1px solid var(--pcg-input-border);
|
| border-radius: var(--pcg-radius);
|
| font-size: 15px;
|
| transition: border-color 0.3s ease;
|
| box-sizing: border-box;
|
| }
|
|
|
| .pcg-book-form input:focus {
|
| border-color: var(--pcg-primary);
|
| outline: none;
|
| box-shadow: 0 0 0 3px rgba(0, 51, 102, 0.1);
|
| }
|
|
|
|
|
| .pcg-business-url-field {
|
| display: none !important;
|
| visibility: hidden;
|
| opacity: 0;
|
| }
|
|
|
|
|
| .pcg-submit-btn {
|
| background-color: var(--pcg-primary);
|
| color: white;
|
| border: none;
|
| padding: 15px 30px;
|
| font-size: 16px;
|
| font-weight: 600;
|
| border-radius: var(--pcg-radius);
|
| cursor: pointer;
|
| width: 100%;
|
| transition: background 0.3s ease;
|
| margin-top: 10px;
|
| }
|
|
|
| .pcg-submit-btn:hover {
|
| background-color:
|
| }
|
|
|
|
|
| .pcg-message {
|
| padding: 15px;
|
| margin-bottom: 20px;
|
| border-radius: var(--pcg-radius);
|
| font-size: 14px;
|
| }
|
| .pcg-success { background-color:
|
| .pcg-error { background-color:
|
| </style>
|
|
|
| <div class="pcg-book-form">
|
| <?php if ($message) echo $message; ?>
|
|
|
| <h3>Download "Chess Not Checkers"</h3>
|
| <p>Make the right move for your business. Discover how to choose the perfect AI provider to enhance your operations. Enter your details below to receive your free copy immediately.</p>
|
|
|
| <form method="post" action="">
|
| <?php echo $nonce_field; ?>
|
| <!-- Time Trap -->
|
| <input type="hidden" name="pcg_time_trap" value="<?php echo $time_trap; ?>">
|
|
|
| <!-- Honeypot (Hidden from humans) -->
|
| <div class="pcg-business-url-field">
|
| <label>If you are human, leave this field blank.</label>
|
| <input type="text" name="pcg_business_url" tabindex="-1" autocomplete="off">
|
| </div>
|
|
|
| <div class="pcg-form-row">
|
| <div class="pcg-field-group">
|
| <label for="pcg-fname">First Name *</label>
|
| <input type="text" id="pcg-fname" name="pcg_fname" required>
|
| </div>
|
| <div class="pcg-field-group">
|
| <label for="pcg-lname">Last Name *</label>
|
| <input type="text" id="pcg-lname" name="pcg_lname" required>
|
| </div>
|
| </div>
|
|
|
| <div class="pcg-field-group" style="margin-bottom: 15px;">
|
| <label for="pcg-company">Company</label>
|
| <input type="text" id="pcg-company" name="pcg_company">
|
| </div>
|
|
|
| <div class="pcg-form-row">
|
| <div class="pcg-field-group">
|
| <label for="pcg-email">Email Address *</label>
|
| <input type="email" id="pcg-email" name="pcg_email" required>
|
| </div>
|
| <div class="pcg-field-group">
|
| <label for="pcg-phone">Phone</label>
|
| <input type="tel" id="pcg-phone" name="pcg_phone">
|
| </div>
|
| </div>
|
|
|
| <button type="submit" name="pcg_submit_book_request" class="pcg-submit-btn">Get the Book</button>
|
| </form>
|
| </div>
|
| <?php
|
| return ob_get_clean();
|
| }
|
| add_shortcode('chess_not_checkers_form', 'pcg_render_chess_form');
|
|
|
| /**
|
| * Handler Logic for Form Submission
|
| */
|
| function pcg_handle_form_submission() {
|
|
|
|
|
| if (!isset($_POST['pcg_download_book_nonce']) || !wp_verify_nonce($_POST['pcg_download_book_nonce'], 'pcg_download_book_action')) {
|
| return '<div class="pcg-message pcg-error">Security check failed. Please refresh and try again.</div>';
|
| }
|
|
|
|
|
|
|
| if (!empty($_POST['pcg_business_url'])) {
|
|
|
| return '<div class="pcg-message pcg-success">Thanks! Check your email.</div>';
|
| }
|
|
|
|
|
|
|
| $submitted_time = base64_decode($_POST['pcg_time_trap']);
|
| if ((time() - intval($submitted_time)) < 3) {
|
| return '<div class="pcg-message pcg-error">You were too fast! Please take a moment to fill out the form correctly.</div>';
|
| }
|
|
|
|
|
| $fname = sanitize_text_field($_POST['pcg_fname']);
|
| $lname = sanitize_text_field($_POST['pcg_lname']);
|
| $company = sanitize_text_field($_POST['pcg_company']);
|
| $email = sanitize_email($_POST['pcg_email']);
|
| $phone = sanitize_text_field($_POST['pcg_phone']);
|
|
|
| if (!is_email($email)) {
|
| return '<div class="pcg-message pcg-error">Please enter a valid email address.</div>';
|
| }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| $to = $email;
|
| $subject = "Your copy of Chess Not Checkers";
|
| $headers = array('Content-Type: text/html; charset=UTF-8');
|
|
|
|
|
| $pdf_link = "https://pearson-consulting-group.com/wp-content/uploads/Chess-Not-Checkers.pdf";
|
|
|
| $message_body = "
|
| Hi $fname,<br><br>
|
| Thank you for requesting a copy of <strong>Chess Not Checkers</strong>.<br>
|
| <br>
|
| This guide will help you make the strategic moves required to select the right AI provider for your business.<br><br>
|
| <a href='$pdf_link' style='background:#003366;color:#fff;padding:10px 20px;text-decoration:none;border-radius:5px;'>Download PDF Now</a>
|
| <br><br>
|
| Best regards,<br>
|
| Pearson Consulting Group
|
| ";
|
|
|
| wp_mail($to, $subject, $message_body, $headers);
|
|
|
|
|
| $admin_email = get_option('admin_email');
|
| wp_mail($admin_email, "New Book Download: $fname $lname", "Details:\nName: $fname $lname\nCompany: $company\nEmail: $email\nPhone: $phone");
|
|
|
| return '<div class="pcg-message pcg-success">Success! We have sent the download link to <strong>' . esc_html($email) . '</strong>. Please check your inbox.</div>';
|
| }
|
| |
| |
Comments