Plugin Directory

Changeset 3841745


Ignore:
Timestamp:
12/03/2026 07:09:02 AM (less than one hour ago)
Author:
wpshuffle
Message:

Update to version 1.3.1 from GitHub

Location:
subscribe-to-download-lite
Files:
32 edited
1 copied

Legend:

Unmodified
Added
Removed
  • subscribe-to-download-lite/tags/1.3.1/inc/classes/class-stdl-admin.php

    r3216457 r3841745  
    3232
    3333        function export_to_csv() {
    34             if (!empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'stdl_export_csv_nonce')) {
     34            if (current_user_can('manage_options') && !empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'stdl_export_csv_nonce')) {
    3535                $filename = "subscribers-list.csv";
    3636                header('Content-type: application/csv');
    … …  
    7171            $subscriber_table = STDL_SUBSCRIBERS_TABLE;
    7272
    73             $subscriber_query = "select * from $subscriber_table";
     73            $subscriber_query = $wpdb->prepare("SELECT * FROM $subscriber_table WHERE subscriber_form_alias = %s", 'stdl');
    7474
    7575            $subscriber_rows = $wpdb->get_results($subscriber_query);
    … …  
    7878            if (!empty($subscriber_rows)) {
    7979                foreach ($subscriber_rows as $subscriber_row) {
    80                     $download_status = (!empty($subscriber_row->subscriber_download_status)) ? esc_html__('Yes', 'subscribe-to-download-lite') : esc_html__('No', 'subscribe-to-download-lite');
     80                    $download_status = esc_html($this->get_download_status_label($subscriber_row->subscriber_download_status));
    8181                    $csv_row = array($subscriber_row->subscriber_name, $subscriber_row->subscriber_email, $download_status);
    8282                    $csv_rows[] = $csv_row;
  • subscribe-to-download-lite/tags/1.3.1/inc/classes/class-stdl-ajax-admin.php

    r2341208 r3841745  
    3434                $form_data = $this->sanitize_array($form_data, $sanitize_rule);
    3535                $stdl_settings = $form_data['form_details'];
     36                $terms = isset($stdl_settings['form']['terms_agreement']) ? $stdl_settings['form']['terms_agreement'] : array();
     37                if (!empty($terms['show']) && (empty($terms['agreement_text']) || trim(wp_strip_all_tags($terms['agreement_text'])) === '')) {
     38                    die(wp_json_encode(array('status' => 403, 'message' => esc_html__('Enter agreement text or disable the agreement field.', 'subscribe-to-download-lite'))));
     39                }
     40                $general = &$stdl_settings['general'];
     41                $file_url = !empty($general['download_file']) ? esc_url_raw($general['download_file'], array('http', 'https')) : '';
     42                $file_id = !empty($general['download_file_id']) ? absint($general['download_file_id']) : 0;
     43                $attachment_url = $file_id ? wp_get_attachment_url($file_id) : false;
     44                if (!$file_url || !$attachment_url || set_url_scheme($file_url) !== set_url_scheme($attachment_url)) {
     45                    $general['download_file_id'] = '';
     46                }
     47                $general['download_file'] = $file_url;
    3648                update_option('stdl_settings', $stdl_settings);
    3749                $response['status'] = 200;
    … …  
    4860                $subscriber_id = intval($_POST['subscriber_id']);
    4961                global $wpdb;
    50                 $delete_check = $wpdb->delete(STDL_SUBSCRIBERS_TABLE, array('subscriber_id' => $subscriber_id), array('%d'));
     62                $delete_check = $wpdb->delete(STDL_SUBSCRIBERS_TABLE, array('subscriber_id' => $subscriber_id, 'subscriber_form_alias' => 'stdl'), array('%d', '%s'));
    5163                if ($delete_check) {
    5264                    $response['status'] = 200;
  • subscribe-to-download-lite/tags/1.3.1/inc/classes/class-stdl-downloader.php

    r2341208 r3841745  
    1111
    1212        function initialize_downloader() {
    13             if (!empty($_REQUEST['stdl_encryption_key'])) {
    14                 $encryption_key = sanitize_text_field($_REQUEST['stdl_encryption_key']);
    15                 if (isset($_COOKIE['stdl_encryption_key']) && $encryption_key == $_COOKIE['stdl_encryption_key']) {
    16                     $encryption_key = sanitize_text_field($_COOKIE['stdl_encryption_key']);
     13            if (!empty($_GET['stdl_encryption_key']) && is_string($_GET['stdl_encryption_key'])) {
     14                nocache_headers();
     15                $encryption_key = sanitize_text_field(wp_unslash($_GET['stdl_encryption_key']));
     16                if (isset($_COOKIE['stdl_encryption_key']) && is_string($_COOKIE['stdl_encryption_key']) && hash_equals($encryption_key, $_COOKIE['stdl_encryption_key']) && $this->check_if_already_subscribed($encryption_key)) {
    1717                    $download_path = $this->get_download_path($encryption_key);
    1818
    … …  
    2626                     */
    2727                    $download_path = apply_filters('stdl_download_path', $download_path, $encryption_key);
    28                     if (file_exists($download_path)) {
     28                    if (!$download_path) {
     29                        $form_details = get_option('stdl_settings');
     30                        $url = !empty($form_details['general']['download_file']) ? esc_url_raw($form_details['general']['download_file'], array('http', 'https')) : '';
     31                        if ($url && wp_redirect($url)) {
     32                            $this->update_download_status($encryption_key, 2);
     33                            exit;
     34                        }
     35                    } elseif (is_file($download_path) && is_readable($download_path)) {
    2936                        header('Content-Description: File Transfer');
    3037                        header('Content-Type: application/octet-stream');
    31                         header('Content-Disposition: attachment; filename="' . basename($download_path) . '"');
    32                         header('Expires: 0');
    33                         header('Cache-Control: must-revalidate');
    34                         header('Pragma: public');
     38                        header('Content-Disposition: attachment; filename="' . sanitize_file_name(basename($download_path)) . '"');
    3539                        header('Content-Length: ' . filesize($download_path));
    36                         readfile($download_path);
    37                         $this->update_download_status($encryption_key);
     40                        if (readfile($download_path) !== false) {
     41                            $this->update_download_status($encryption_key);
     42                        }
    3843                        exit;
    3944                    }
    … …  
    4247        }
    4348
    44         function update_download_status($encryption_key) {
     49        function update_download_status($encryption_key, $status = 1) {
    4550            global $wpdb;
    46             $wpdb->update(STDL_SUBSCRIBERS_TABLE, array('subscriber_download_status' => 1), array('subscriber_encryption_key' => $encryption_key), array('%d'), array('%s'));
     51            if ($status === 2) {
     52                $table = STDL_SUBSCRIBERS_TABLE;
     53                $wpdb->query($wpdb->prepare("UPDATE $table SET subscriber_download_status = 2 WHERE subscriber_encryption_key = %s AND subscriber_form_alias = %s AND subscriber_download_status = 0", $encryption_key, 'stdl'));
     54                return;
     55            }
     56            $wpdb->update(STDL_SUBSCRIBERS_TABLE, array('subscriber_download_status' => $status), array('subscriber_encryption_key' => $encryption_key, 'subscriber_form_alias' => 'stdl'), array('%d'), array('%s', '%s'));
    4757        }
    4858
  • subscribe-to-download-lite/tags/1.3.1/inc/classes/class-stdl-enqueue.php

    r2341208 r3841745  
    1212
    1313        function register_frontend_assets() {
    14             $stdl_frontend_obj = array('ajax_url' => admin_url('admin-ajax.php'), 'ajax_nonce' => wp_create_nonce('stdl_frontend_ajax_nonce'));
     14            $stdl_frontend_obj = array(
     15                'ajax_url' => admin_url('admin-ajax.php'),
     16                'ajax_nonce' => wp_create_nonce('stdl_frontend_ajax_nonce'),
     17                'request_error' => __('Could not submit the form. Please try again.', 'subscribe-to-download-lite'),
     18            );
    1519            wp_enqueue_style('fontawesome', STDL_URL . 'fontawesome/css/all.min.css', array(), STDL_VERSION);
    1620            wp_enqueue_script('stdl-frontend-script', STDL_JS_DIR . '/stdl-frontend.js', array('jquery'), STDL_VERSION);
  • subscribe-to-download-lite/tags/1.3.1/inc/classes/class-stdl-library.php

    r3260547 r3841745  
    1313        function permission_denied() {
    1414            die('No script kiddies please!!');
     15        }
     16
     17        function get_download_status_label($status) {
     18            switch ((int) $status) {
     19                case 1:
     20                    return __('Downloaded', 'subscribe-to-download-lite');
     21                case 2:
     22                    return __('Redirected', 'subscribe-to-download-lite');
     23                default:
     24                    return __('Untracked', 'subscribe-to-download-lite');
     25            }
    1526        }
    1627
    … …  
    177188            global $wpdb;
    178189            $subscriber_table = STDL_SUBSCRIBERS_TABLE;
    179             $subscriber_row = $wpdb->get_row($wpdb->prepare("select * from $subscriber_table where subscriber_email = %s", $email));
     190            $subscriber_row = $wpdb->get_row($wpdb->prepare("select * from $subscriber_table where subscriber_email = %s and subscriber_form_alias = %s", $email, 'stdl'));
    180191            return $subscriber_row;
    181192        }
    … …  
    189200         */
    190201        function get_default_from_email() {
    191             $site_url = site_url();
    192             $find_h = '#^http(s)?://#';
    193             $find_w = '/^www\./';
    194             $replace = '';
    195             $output = preg_replace($find_h, $replace, $site_url);
    196             $output = preg_replace($find_w, $replace, $output);
    197             return 'noreply@' . $output;
     202            $host = wp_parse_url(home_url('/'), PHP_URL_HOST);
     203            $address = 'noreply@' . preg_replace('/^www\./i', '', (string) $host);
     204            return is_email($address) ? $address : get_option('admin_email');
    198205        }
    199206
    … …  
    206213         */
    207214        function generate_encryption_key() {
    208             $current_date_time = date('Y-m-d H:i:s');
    209             $encryption_key = md5($current_date_time);
    210             return $encryption_key;
     215            return bin2hex(random_bytes(16));
    211216        }
    212217
    … …  
    222227        function get_download_path($encryption_key) {
    223228            $form_details = get_option('stdl_settings');
    224             if (empty($form_details['general']['download_file_id'])) {
     229            $general = $form_details['general'];
     230            if (empty($general['download_file']) || empty($general['download_file_id'])) {
    225231                // If download file is not available in the settings
    226232                return false;
    227233            }
    228             $attachment_path = get_attached_file(intval($form_details['general']['download_file_id']));
    229             return $attachment_path;
     234            $file_id = absint($general['download_file_id']);
     235            $attachment_url = wp_get_attachment_url($file_id);
     236            if (!$attachment_url || set_url_scheme($attachment_url) !== set_url_scheme($general['download_file'])) {
     237                return false;
     238            }
     239            return get_attached_file($file_id);
    230240        }
    231241
    … …  
    249259            global $wpdb;
    250260            $subscriber_table = STDL_SUBSCRIBERS_TABLE;
    251             $subscriber_count = $wpdb->get_var("SELECT COUNT(*) FROM $subscriber_table WHERE subscriber_encryption_key like '$encryption_key'");
     261            $subscriber_count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $subscriber_table WHERE subscriber_encryption_key = %s AND subscriber_form_alias = %s", $encryption_key, 'stdl'));
    252262            if ($subscriber_count == 0) {
    253263                return false;
  • subscribe-to-download-lite/tags/1.3.1/inc/cores/subscription-process.php

    r2341208 r3841745  
    33defined('ABSPATH') or die('No script kiddies please!!');
    44
    5 if ($this->ajax_nonce_verify()) {
    6     /**
    7      * Triggers just before processing the subscription form
    8      *
    9      * @since 1.0.0
    10      */
    11     do_action('stdl_before_form_process');
    12     $form_data = $_POST['form_data'];
    13     $form_data = stripslashes_deep($form_data);
    14     parse_str($form_data, $form_data);
    15     $form_data = $this->sanitize_array($form_data);
    16     $form_alias = sanitize_text_field($_POST['form_alias']);
    17     $form_details = get_option('stdl_settings');
    18     $subscriber_email = sanitize_email($form_data['stdl_email']);
    19     $subscriber_name = (!empty($form_data['stdl_name'])) ? sanitize_text_field($form_data['stdl_name']) : '';
    20     if (empty($form_data['stdl_email']) || (!empty($form_details['form']['terms_agreement']['show']) && empty($form_data['stdl_terms_agreement'])) || (!empty($form_details['form']['name']['show']) && !empty($form_details['form']['name']['required']) && empty($form_data['stdl_name']))) {
    21         $response['status'] = 403;
    22         $response['message'] = esc_attr($form_details['general']['required_error_message']);
    23     } else {
    24         //It is okay to process the form now
    25         $subscriber_row = $this->get_subscriber_row_by_email($form_data['stdl_email']);
    26         $from_email = (!empty($form_details['email']['from_email'])) ? $form_details['email']['from_email'] : $this->get_default_from_email();
    27         $from_name = (!empty($form_details['email']['from_name'])) ? $form_details['email']['from_name'] : esc_html__('No Reply', 'subscribe-to-download-lite');
    28         $subject = (!empty($form_details['email']['subject'])) ? $form_details['email']['subject'] : esc_html__('Subscription Successful', 'subscribe-to-download-lite');
    29         $email_message = (!empty($form_details['email']['email_message'])) ? $form_details['email']['email_message'] : $this->get_default_email_message();
     5if (!$this->ajax_nonce_verify()) {
     6    $this->permission_denied();
     7    return;
     8}
    309
    31         $charset = get_option('blog_charset');
    32         $headers[] = 'Content-Type: text/html; charset=' . $charset;
    33         $headers[] = "From: $from_name < $from_email >";
     10do_action('stdl_before_form_process');
    3411
    35         if (empty($subscriber_row)) {
    36             //if subscriber isn't already subscribed
    37             $encryption_key = $this->generate_encryption_key();
    38             if (!empty($form_details['general']['encrypt_link'])) {
     12parse_str(isset($_POST['form_data']) && is_string($_POST['form_data']) ? wp_unslash($_POST['form_data']) : '', $form_data);
     13$form_data = $this->sanitize_array($form_data);
     14$form_details = get_option('stdl_settings');
     15$general = $form_details['general'];
     16$terms = isset($form_details['form']['terms_agreement']) ? $form_details['form']['terms_agreement'] : array();
     17$email = !empty($form_data['stdl_email']) && is_string($form_data['stdl_email']) ? $form_data['stdl_email'] : '';
     18$name = !empty($form_data['stdl_name']) && is_string($form_data['stdl_name']) ? $form_data['stdl_name'] : '';
     19$requires_terms = !empty($terms['show']) && !empty($terms['agreement_text']) && trim(wp_strip_all_tags($terms['agreement_text'])) !== '';
     20$requires_name = !empty($form_details['form']['name']['show']) && !empty($form_details['form']['name']['required']);
    3921
    40                 $download_url = site_url() . '?stdl_encryption_key=' . $encryption_key;
    41             } else {
    42                 $download_url = esc_url($form_details['general']['download_file']);
    43             }
    44             if (!empty($download_url)) {
    45                 $email_message = str_replace('#download_link', '<a href="' . $download_url . '">' . $download_url . '</a>', $email_message);
     22if (!is_email($email) || ($requires_terms && empty($form_data['stdl_terms_agreement'])) || ($requires_name && $name === '')) {
     23    wp_send_json(array('status' => 403, 'message' => esc_html($general['required_error_message'])));
     24}
    4625
    47                 $email_check = wp_mail($form_data['stdl_email'], $subject, $email_message, $headers);
    48                 if ($email_check) {
    49                     setcookie("stdl_encryption_key", $encryption_key, time() + 3600 * 24 * 365, '/');
    50                     global $wpdb;
    51                     $wpdb->insert(STDL_SUBSCRIBERS_TABLE, array('subscriber_name' => $subscriber_name,
    52                         'subscriber_email' => $subscriber_email,
    53                         'subscriber_form_alias' => $form_alias,
    54                         'subscriber_encryption_key' => $encryption_key), array('%s', '%s', '%s', '%s'));
    55                     $response['status'] = 200;
    56                     $response['message'] = esc_attr($form_details['general']['success_message']);
    57                 } else {
    58                     $response['status'] = 403;
    59                     $response['message'] = esc_attr($form_details['general']['error_message']);
    60                 }
    61             } else {
    62                 $response['status'] = 200;
    63                 $response['type'] = esc_html__('Default subscription', 'subscribe-to-download-lite');
    64                 $response['message'] = esc_attr($form_details['general']['success_message']);
    65             }
    66         } else {
    67             //if subscriber is already subscribed
    68             $encryption_key = $subscriber_row->subscriber_encryption_key;
    69             if (!empty($form_details['general']['encrypt_link'])) {
     26$subscriber = $this->get_subscriber_row_by_email($email);
     27$key = $subscriber ? $subscriber->subscriber_encryption_key : $this->generate_encryption_key();
     28$file_url = !empty($general['download_file']) ? esc_url_raw($general['download_file'], array('http', 'https')) : '';
     29if (!$subscriber) {
     30    global $wpdb;
     31    $data = array(
     32        'subscriber_name' => $name,
     33        'subscriber_email' => $email,
     34        'subscriber_form_alias' => 'stdl',
     35        'subscriber_encryption_key' => $key,
     36    );
     37    // Pro can have previously extended this shared table with additional fields.
     38    $table = STDL_SUBSCRIBERS_TABLE;
     39    $columns = $wpdb->get_col("SHOW COLUMNS FROM $table");
     40    foreach (array('subscriber_custom_fields', 'subscribed_user_ip') as $column) {
     41        if (in_array($column, $columns, true)) {
     42            $data[$column] = '';
     43        }
     44    }
     45    $saved = $wpdb->insert($table, $data, array_fill(0, count($data), '%s'));
     46    if (!$saved) {
     47        wp_send_json(array('status' => 403, 'message' => esc_html__('Could not save your subscription. Please try again.', 'subscribe-to-download-lite')));
     48    }
     49}
    7050
    71                 $download_url = site_url() . '?stdl_encryption_key=' . $encryption_key;
    72             } else {
    73                 $download_url = esc_url($form_details['general']['download_file']);
    74             }
    75             if (!empty($download_url)) {
    76 
    77                 $email_message = str_replace('#download_link', '<a href="' . $download_url . '">' . $download_url . '</a>', $email_message);
    78                 /**
    79                  * Filters email message
    80                  *
    81                  * @param string $email_message
    82                  * @param array $form_data
    83                  *
    84                  * @since 1.0.0
    85                  */
    86                 $email_message = apply_filters('stdl_email_message', $email_message, $form_data);
    87                 $email_check = wp_mail($form_data['stdl_email'], $subject, $email_message, $headers);
    88                 if ($email_check) {
    89                     setcookie("stdl_encryption_key", $encryption_key, time() + 3600 * 24 * 365, '/');
    90                     global $wpdb;
    91                     $wpdb->update(STDL_SUBSCRIBERS_TABLE, array('subscriber_form_alias' => $form_alias), array('subscriber_email' => $form_data['stdl_email']), array('%s'), array('%s'));
    92                     $response['status'] = 200;
    93                     $response['message'] = esc_attr($form_details['general']['success_message']);
    94                 } else {
    95                     $response['status'] = 403;
    96                     $response['message'] = esc_attr($form_details['general']['error_message']);
    97                 }
    98             } else {
    99                 $response['status'] = 200;
    100                 $response['type'] = esc_html__('Default subscription', 'subscribe-to-download-lite');
    101                 $response['message'] = esc_attr($form_details['general']['success_message']);
    102             }
    103         }
    104         /**
    105          * Triggers at the end of processing the subscription form successfully
    106          *
    107          * @param array $form_data
    108          *
    109          * @since 1.0.0
    110          */
    111         do_action('stdl_end_form_process', $form_data, $form_details);
     51if ($file_url) {
     52    $download_url = !empty($general['encrypt_link']) ? add_query_arg('stdl_encryption_key', $key, home_url('/')) : $file_url;
     53    $email_settings = $form_details['email'];
     54    $from_email = !empty($email_settings['from_email']) ? $email_settings['from_email'] : $this->get_default_from_email();
     55    $from_name = !empty($email_settings['from_name']) ? $email_settings['from_name'] : esc_html__('No Reply', 'subscribe-to-download-lite');
     56    $subject = !empty($email_settings['subject']) ? $email_settings['subject'] : esc_html__('Subscription Successful', 'subscribe-to-download-lite');
     57    $message = !empty($email_settings['email_message']) ? $email_settings['email_message'] : $this->get_default_email_message();
     58    $link = '<a href="' . esc_url($download_url) . '">' . esc_html($download_url) . '</a>';
     59    $message = strpos($message, '#download_link') === false ? $message . '<br>' . $link : str_replace('#download_link', $link, $message);
     60    if ($subscriber) {
     61        $message = apply_filters('stdl_email_message', $message, $form_data);
     62    }
     63    $headers = array('Content-Type: text/html; charset=' . get_option('blog_charset'), "From: $from_name <$from_email>");
     64    if (!wp_mail($email, $subject, $message, $headers)) {
     65        wp_send_json(array('status' => 403, 'message' => esc_html($general['error_message'])));
    11266    }
    11367
    114     die(json_encode($response));
     68    setcookie('stdl_encryption_key', $key, time() + YEAR_IN_SECONDS, '/', '', is_ssl(), true);
     69    $response = array('status' => 200, 'message' => esc_html($general['success_message']));
    11570} else {
    116     $this->permission_denied();
     71    $response = array(
     72        'status' => 200,
     73        'type' => esc_html__('Default subscription', 'subscribe-to-download-lite'),
     74        'message' => esc_html__('Subscription successful.', 'subscribe-to-download-lite'),
     75    );
    11776}
     77
     78/** Fires after a successful Lite signup and any required download email handoff. */
     79do_action('stdl_end_form_process', $form_data, $form_details);
     80wp_send_json($response);
  • subscribe-to-download-lite/tags/1.3.1/inc/views/backend/form-sections/stdl-upgrade-to-pro.php

    r3216457 r3841745  
    1010            <p>You can create <strong>unlimited subscription forms</strong>, choose a stunning layout from our
    1111                <strong>20 beautifully pre designed templates</strong>, connect the forms directly to popular third
    12                 party subscription services such as <strong>Mailchimp, Constant Contact, Mailerlite, ConvertKit and
     12                party subscription services such as <strong>Mailchimp, Constant Contact, MailerLite Classic and
    1313                    Brevo/Sendinblue</strong>, <strong>export subscribers</strong> and what not. With this plugin you
    1414                are just few seconds away from collecting the subscribers from your WordPress site because creating and
    … …  
    4545            <div class="stdl-feat-block">
    4646                <div class="stdl-feat-img">
    47                     <a href="https://demo.wpshuffle.com/subscribe-to-unlock/all-templates-demo/" class=""> <img
     47                    <a href="https://demo.wpshuffle.com/subscribe-to-download/all-templates-demo/" class=""> <img
    4848                            loading="lazy" src="https://wpshuffle.com/wp-content/uploads/2025/01/std-feat-3.png"></a>
    4949                </div>
  • subscribe-to-download-lite/tags/1.3.1/inc/views/backend/stdl-pro-vs-free.php

    r3216457 r3841745  
    168168        <div class="stdl-compare-row stdl--flex stdl--flex-w">
    169169            <div class="stdl-feat-col">
    170                 <p>Mailerlite Integration</p>
     170                <p>MailerLite Classic Integration</p>
    171171            </div>
    172172            <div class="stdl-feat-col">
    … …  
    180180            <div class="stdl-feat-col">
    181181                <p>Brevo/Sendinblue Integration</p>
    182             </div>
    183             <div class="stdl-feat-col">
    184                 <p class="no"><i class="fa fa-times" aria-hidden="true"></i></p>
    185             </div>
    186             <div class="stdl-feat-col">
    187                 <p class="yes"><i class="fa fa-check" aria-hidden="true"></i></p>
    188             </div>
    189         </div>
    190         <div class="stdl-compare-row stdl--flex stdl--flex-w">
    191             <div class="stdl-feat-col">
    192                 <p>ConvertKit Integration</p>
    193182            </div>
    194183            <div class="stdl-feat-col">
    … …  
    253242            <div class="stdl-feat-col">
    254243                <div class="stdl-add-wrap stdl-btn-cntr">
    255                     <a href="https://1.envato.market/PNaY6" class="stdl-button-orange stdl-btn-margin stdl-hov" target="_blank"><?php esc_html_e('Upgrade now', 'subscribe-to-unlock-lite'); ?></a>
     244                    <a href="<?php echo esc_url(STDL_UPGRADE_LINK); ?>" class="stdl-button-orange stdl-btn-margin stdl-hov" target="_blank"><?php esc_html_e('Upgrade now', 'subscribe-to-download-lite'); ?></a>
    256245                </div>
    257246
  • subscribe-to-download-lite/tags/1.3.1/inc/views/backend/stdl-upgrade.php

    r3216457 r3841745  
    2727            <p>You can create <strong>unlimited subscription forms</strong>, choose a stunning layout from our
    2828                <strong>20 beautifully pre designed templates</strong>, connect the forms directly to popular third
    29                 party subscription services such as <strong>Mailchimp, Constant Contact, Mailerlite, ConvertKit and
     29                party subscription services such as <strong>Mailchimp, Constant Contact, MailerLite Classic and
    3030                    Brevo/Sendinblue</strong>, <strong>export subscribers</strong> and what not. With this plugin you
    3131                are just few seconds away from collecting the subscribers from your WordPress site because creating and
    … …  
    6262            <div class="stdl-feat-block">
    6363                <div class="stdl-feat-img">
    64                     <a href="https://demo.wpshuffle.com/subscribe-to-unlock/all-templates-demo/" class=""> <img
     64                    <a href="https://demo.wpshuffle.com/subscribe-to-download/all-templates-demo/" class=""> <img
    6565                            loading="lazy" src="https://wpshuffle.com/wp-content/uploads/2025/01/std-feat-3.png"></a>
    6666                </div>
  • subscribe-to-download-lite/tags/1.3.1/inc/views/backend/subscribers/list-subscribers.php

    r3216457 r3841745  
    3939                $subscriber_table = STDL_SUBSCRIBERS_TABLE;
    4040
    41                 $subscriber_query = "select * from $subscriber_table";
     41                $subscriber_query = $wpdb->prepare("SELECT * FROM $subscriber_table WHERE subscriber_form_alias = %s", 'stdl');
    4242
    4343                $subscriber_rows = $wpdb->get_results($subscriber_query);
    … …  
    4848                            <td><?php echo esc_attr($subscriber_row->subscriber_name); ?></td>
    4949                            <td><?php echo esc_attr($subscriber_row->subscriber_email); ?></td>
    50                             <td><?php echo (!empty($subscriber_row->subscriber_download_status)) ? esc_html__('Yes', 'subscribe-to-download-lite') : esc_html__('No', 'subscribe-to-download-lite'); ?></td>
     50                            <td><?php echo esc_html($this->get_download_status_label($subscriber_row->subscriber_download_status)); ?></td>
    5151                            <td>
    5252                                <a class="stdl-delete stdl-subscriber-delete" href="javascript:void(0)" data-subscriber-id="<?php echo intval($subscriber_row->subscriber_id); ?>" title="<?php esc_html_e('Delete Subscriber', 'subscribe-to-download-lite'); ?>"><?php esc_html_e('Delete', 'subscribe-to-download-lite'); ?></a>
  • subscribe-to-download-lite/tags/1.3.1/inc/views/backend/upgrade.php

    r2920291 r3841745  
    11 <div class="stdl-go-pro">
    2     <a href="https://1.envato.market/Q3KGo" target="_blank"><img src="<?php echo STDL_URL . 'images/UpgradeBanner.png' ?>" /></a>
    3     <a href="https://1.envato.market/Q3KGo" class="stdl-button-orange" target="_blank"><?php esc_html_e('Upgrade now', 'subscribe-to-download-lite'); ?></a>
     2    <a href="<?php echo esc_url(STDL_UPGRADE_LINK); ?>" target="_blank"><img src="<?php echo STDL_URL . 'images/UpgradeBanner.png' ?>" /></a>
     3    <a href="<?php echo esc_url(STDL_UPGRADE_LINK); ?>" class="stdl-button-orange" target="_blank"><?php esc_html_e('Upgrade now', 'subscribe-to-download-lite'); ?></a>
    44</div>
  • subscribe-to-download-lite/tags/1.3.1/inc/views/frontend/download-button.php

    r2341208 r3841745  
    1 <a href="<?php echo site_url() . '/?stdl_encryption_key=' . sanitize_text_field( $_COOKIE['stdl_encryption_key'] ); ?>" class="stdl-download-button stdl-button-<?php echo esc_attr( $form_template ); ?>"><i class="fa fa-download" aria-hidden="true"></i>
     1<?php
     2$download_url = $form_details['general']['download_file'];
     3if (!empty($form_details['general']['encrypt_link'])) {
     4    $download_url = add_query_arg('stdl_encryption_key', sanitize_text_field($_COOKIE['stdl_encryption_key']), home_url('/'));
     5}
     6?>
     7<a href="<?php echo esc_url($download_url); ?>" class="stdl-download-button stdl-button-<?php echo esc_attr( $form_template ); ?>"><i class="fa fa-download" aria-hidden="true"></i>
    28    <?php echo esc_attr( $form_details['general']['download_button_text'] ); ?></a>
    39
  • subscribe-to-download-lite/tags/1.3.1/inc/views/frontend/stdl-shortcode.php

    r2341208 r3841745  
    22$form_details = get_option('stdl_settings');
    33$form_template = (!empty($atts['template'])) ? $atts['template'] : $form_details['layout']['template'];
    4 if (isset($_COOKIE['stdl_encryption_key']) && $this->check_if_already_subscribed($_COOKIE['stdl_encryption_key']) && empty($form_details['general']['always_show'])) {
     4if (!empty($form_details['general']['download_file']) && isset($_COOKIE['stdl_encryption_key']) && is_string($_COOKIE['stdl_encryption_key']) && $this->check_if_already_subscribed($_COOKIE['stdl_encryption_key']) && empty($form_details['general']['always_show'])) {
    55    /**
    66     * Triggers just before displaying the download button
  • subscribe-to-download-lite/tags/1.3.1/js/stdl-frontend.js

    r2341208 r3841745  
    1313        $.ajax({
    1414            type: 'post',
     15            dataType: 'json',
    1516            url: stdl_frontend_obj.ajax_url,
    1617            data: {
    … …  
    2122            },
    2223            beforeSend: function (xhr) {
     24                selector.find(':submit').prop('disabled', true);
    2325                selector.find('.stdl-form-message').slideUp(500);
    2426                selector.find('.stdl-form-loader-wraper').show();
    2527            },
    2628            success: function (res) {
    27                 selector.find('.stdl-form-loader-wraper').hide();
    28                 res = $.parseJSON(res);
    2929                if (res.status == 200) {
    3030                    selector[0].reset();
    … …  
    3333                    selector.find('.stdl-form-message').removeClass('stdl-success').addClass('stdl-error').html(res.message).slideDown(500);
    3434                }
     35            },
     36            error: function () {
     37                selector.find('.stdl-form-message').removeClass('stdl-success').addClass('stdl-error').text(stdl_frontend_obj.request_error).slideDown(500);
     38            },
     39            complete: function () {
     40                selector.find('.stdl-form-loader-wraper').hide();
     41                selector.find(':submit').prop('disabled', false);
    3542            }
    3643        });
  • subscribe-to-download-lite/tags/1.3.1/readme.txt

    r3716347 r3841745  
    66Tested up to: 7.1
    77Requires PHP: 7.0.0
    8 Stable tag: 1.3.0
     8Stable tag: 1.3.1
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
    … …  
    5757* Show popup form with delay on individual page
    5858* Custom Form Styler Available
    59 * Mailchimp, Constant Contact, MailerLite and other marketing integrations
     59* Mailchimp, Constant Contact, MailerLite Classic and other marketing integrations
    6060* Track Download Status
    6161* And many more ...
    6262
    63 Check all premium features [here](https://1.envato.market/Q3KGo)
     63Check all premium features [here](https://codecanyon.net/item/subscribe-to-download-an-advanced-subscription-plugin-for-wordpress/24020447)
    6464
    6565= Upgrade to PRO =
    6666
    67 * To upgrade to pro, please go [here](https://1.envato.market/Q3KGo)
     67* To upgrade to pro, please go [here](https://codecanyon.net/item/subscribe-to-download-an-advanced-subscription-plugin-for-wordpress/24020447)
    6868* To check demo, please go [here](http://demo.wpshuffle.com/subscribe-to-download)
    6969
    … …  
    116116
    117117== Changelog ==
     118= 1.3.1 =
     119* Fixed signup-only forms so subscribers are saved when no download file is configured.
     120* Improved signup and email error handling so visitors can retry without creating another subscriber record.
     121* Fixed download links for returning subscribers and for files changed to an external URL.
     122* Added a settings check for blank agreement text and scoped the subscriber list and CSV to the Lite form.
     123* Clarified which downloads were tracked or redirected, and corrected the Pro purchase and template demo links.
     124
    118125= 1.3.0 =
    119126* Fixed security issues
  • subscribe-to-download-lite/tags/1.3.1/subscribe-to-download-lite.php

    r3260547 r3841745  
    66  Plugin URI:  https://wpshuffle.com/subscribe-to-download-lite
    77  Description: A plugin to collect email using an email subscribing form by providing the free downloadable items
    8   Version:     1.3.0
     8  Version:     1.3.1
    99  Author:      WP Shuffle
    1010  Author URI:  http://wpshuffle.com
    … …  
    3333
    3434            global $wpdb;
    35             defined('STDL_VERSION') or define('STDL_VERSION', '1.3.0'); // Plugin's active version
     35            defined('STDL_VERSION') or define('STDL_VERSION', '1.3.1'); // Plugin's active version
    3636            defined('STDL_PATH') or define('STDL_PATH', plugin_dir_path(__FILE__)); // plugin's absolute path
    3737            defined('STDL_URL') or define('STDL_URL', plugin_dir_url(__FILE__)); // plugin's absolute URL
    … …  
    4242            defined('STDL_SUBSCRIBERS_TABLE') or define('STDL_SUBSCRIBERS_TABLE', $wpdb->prefix . 'std_subscribers'); //plugin's subscriber table
    4343            defined('STDL_TOTAL_TEMPLATES') or define('STDL_TOTAL_TEMPLATES', 5); //Total number of templates available
    44             defined('STDL_UPGRADE_LINK') or define('STDL_UPGRADE_LINK', 'https://1.envato.market/Q3KGo');
     44            defined('STDL_UPGRADE_LINK') or define('STDL_UPGRADE_LINK', 'https://codecanyon.net/item/subscribe-to-download-an-advanced-subscription-plugin-for-wordpress/24020447');
    4545        }
    4646
  • subscribe-to-download-lite/trunk/inc/classes/class-stdl-admin.php

    r3216457 r3841745  
    3232
    3333        function export_to_csv() {
    34             if (!empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'stdl_export_csv_nonce')) {
     34            if (current_user_can('manage_options') && !empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'stdl_export_csv_nonce')) {
    3535                $filename = "subscribers-list.csv";
    3636                header('Content-type: application/csv');
    … …  
    7171            $subscriber_table = STDL_SUBSCRIBERS_TABLE;
    7272
    73             $subscriber_query = "select * from $subscriber_table";
     73            $subscriber_query = $wpdb->prepare("SELECT * FROM $subscriber_table WHERE subscriber_form_alias = %s", 'stdl');
    7474
    7575            $subscriber_rows = $wpdb->get_results($subscriber_query);
    … …  
    7878            if (!empty($subscriber_rows)) {
    7979                foreach ($subscriber_rows as $subscriber_row) {
    80                     $download_status = (!empty($subscriber_row->subscriber_download_status)) ? esc_html__('Yes', 'subscribe-to-download-lite') : esc_html__('No', 'subscribe-to-download-lite');
     80                    $download_status = esc_html($this->get_download_status_label($subscriber_row->subscriber_download_status));
    8181                    $csv_row = array($subscriber_row->subscriber_name, $subscriber_row->subscriber_email, $download_status);
    8282                    $csv_rows[] = $csv_row;
  • subscribe-to-download-lite/trunk/inc/classes/class-stdl-ajax-admin.php

    r2341208 r3841745  
    3434                $form_data = $this->sanitize_array($form_data, $sanitize_rule);
    3535                $stdl_settings = $form_data['form_details'];
     36                $terms = isset($stdl_settings['form']['terms_agreement']) ? $stdl_settings['form']['terms_agreement'] : array();
     37                if (!empty($terms['show']) && (empty($terms['agreement_text']) || trim(wp_strip_all_tags($terms['agreement_text'])) === '')) {
     38                    die(wp_json_encode(array('status' => 403, 'message' => esc_html__('Enter agreement text or disable the agreement field.', 'subscribe-to-download-lite'))));
     39                }
     40                $general = &$stdl_settings['general'];
     41                $file_url = !empty($general['download_file']) ? esc_url_raw($general['download_file'], array('http', 'https')) : '';
     42                $file_id = !empty($general['download_file_id']) ? absint($general['download_file_id']) : 0;
     43                $attachment_url = $file_id ? wp_get_attachment_url($file_id) : false;
     44                if (!$file_url || !$attachment_url || set_url_scheme($file_url) !== set_url_scheme($attachment_url)) {
     45                    $general['download_file_id'] = '';
     46                }
     47                $general['download_file'] = $file_url;
    3648                update_option('stdl_settings', $stdl_settings);
    3749                $response['status'] = 200;
    … …  
    4860                $subscriber_id = intval($_POST['subscriber_id']);
    4961                global $wpdb;
    50                 $delete_check = $wpdb->delete(STDL_SUBSCRIBERS_TABLE, array('subscriber_id' => $subscriber_id), array('%d'));
     62                $delete_check = $wpdb->delete(STDL_SUBSCRIBERS_TABLE, array('subscriber_id' => $subscriber_id, 'subscriber_form_alias' => 'stdl'), array('%d', '%s'));
    5163                if ($delete_check) {
    5264                    $response['status'] = 200;
  • subscribe-to-download-lite/trunk/inc/classes/class-stdl-downloader.php

    r2341208 r3841745  
    1111
    1212        function initialize_downloader() {
    13             if (!empty($_REQUEST['stdl_encryption_key'])) {
    14                 $encryption_key = sanitize_text_field($_REQUEST['stdl_encryption_key']);
    15                 if (isset($_COOKIE['stdl_encryption_key']) && $encryption_key == $_COOKIE['stdl_encryption_key']) {
    16                     $encryption_key = sanitize_text_field($_COOKIE['stdl_encryption_key']);
     13            if (!empty($_GET['stdl_encryption_key']) && is_string($_GET['stdl_encryption_key'])) {
     14                nocache_headers();
     15                $encryption_key = sanitize_text_field(wp_unslash($_GET['stdl_encryption_key']));
     16                if (isset($_COOKIE['stdl_encryption_key']) && is_string($_COOKIE['stdl_encryption_key']) && hash_equals($encryption_key, $_COOKIE['stdl_encryption_key']) && $this->check_if_already_subscribed($encryption_key)) {
    1717                    $download_path = $this->get_download_path($encryption_key);
    1818
    … …  
    2626                     */
    2727                    $download_path = apply_filters('stdl_download_path', $download_path, $encryption_key);
    28                     if (file_exists($download_path)) {
     28                    if (!$download_path) {
     29                        $form_details = get_option('stdl_settings');
     30                        $url = !empty($form_details['general']['download_file']) ? esc_url_raw($form_details['general']['download_file'], array('http', 'https')) : '';
     31                        if ($url && wp_redirect($url)) {
     32                            $this->update_download_status($encryption_key, 2);
     33                            exit;
     34                        }
     35                    } elseif (is_file($download_path) && is_readable($download_path)) {
    2936                        header('Content-Description: File Transfer');
    3037                        header('Content-Type: application/octet-stream');
    31                         header('Content-Disposition: attachment; filename="' . basename($download_path) . '"');
    32                         header('Expires: 0');
    33                         header('Cache-Control: must-revalidate');
    34                         header('Pragma: public');
     38                        header('Content-Disposition: attachment; filename="' . sanitize_file_name(basename($download_path)) . '"');
    3539                        header('Content-Length: ' . filesize($download_path));
    36                         readfile($download_path);
    37                         $this->update_download_status($encryption_key);
     40                        if (readfile($download_path) !== false) {
     41                            $this->update_download_status($encryption_key);
     42                        }
    3843                        exit;
    3944                    }
    … …  
    4247        }
    4348
    44         function update_download_status($encryption_key) {
     49        function update_download_status($encryption_key, $status = 1) {
    4550            global $wpdb;
    46             $wpdb->update(STDL_SUBSCRIBERS_TABLE, array('subscriber_download_status' => 1), array('subscriber_encryption_key' => $encryption_key), array('%d'), array('%s'));
     51            if ($status === 2) {
     52                $table = STDL_SUBSCRIBERS_TABLE;
     53                $wpdb->query($wpdb->prepare("UPDATE $table SET subscriber_download_status = 2 WHERE subscriber_encryption_key = %s AND subscriber_form_alias = %s AND subscriber_download_status = 0", $encryption_key, 'stdl'));
     54                return;
     55            }
     56            $wpdb->update(STDL_SUBSCRIBERS_TABLE, array('subscriber_download_status' => $status), array('subscriber_encryption_key' => $encryption_key, 'subscriber_form_alias' => 'stdl'), array('%d'), array('%s', '%s'));
    4757        }
    4858
  • subscribe-to-download-lite/trunk/inc/classes/class-stdl-enqueue.php

    r2341208 r3841745  
    1212
    1313        function register_frontend_assets() {
    14             $stdl_frontend_obj = array('ajax_url' => admin_url('admin-ajax.php'), 'ajax_nonce' => wp_create_nonce('stdl_frontend_ajax_nonce'));
     14            $stdl_frontend_obj = array(
     15                'ajax_url' => admin_url('admin-ajax.php'),
     16                'ajax_nonce' => wp_create_nonce('stdl_frontend_ajax_nonce'),
     17                'request_error' => __('Could not submit the form. Please try again.', 'subscribe-to-download-lite'),
     18            );
    1519            wp_enqueue_style('fontawesome', STDL_URL . 'fontawesome/css/all.min.css', array(), STDL_VERSION);
    1620            wp_enqueue_script('stdl-frontend-script', STDL_JS_DIR . '/stdl-frontend.js', array('jquery'), STDL_VERSION);
  • subscribe-to-download-lite/trunk/inc/classes/class-stdl-library.php

    r3260547 r3841745  
    1313        function permission_denied() {
    1414            die('No script kiddies please!!');
     15        }
     16
     17        function get_download_status_label($status) {
     18            switch ((int) $status) {
     19                case 1:
     20                    return __('Downloaded', 'subscribe-to-download-lite');
     21                case 2:
     22                    return __('Redirected', 'subscribe-to-download-lite');
     23                default:
     24                    return __('Untracked', 'subscribe-to-download-lite');
     25            }
    1526        }
    1627
    … …  
    177188            global $wpdb;
    178189            $subscriber_table = STDL_SUBSCRIBERS_TABLE;
    179             $subscriber_row = $wpdb->get_row($wpdb->prepare("select * from $subscriber_table where subscriber_email = %s", $email));
     190            $subscriber_row = $wpdb->get_row($wpdb->prepare("select * from $subscriber_table where subscriber_email = %s and subscriber_form_alias = %s", $email, 'stdl'));
    180191            return $subscriber_row;
    181192        }
    … …  
    189200         */
    190201        function get_default_from_email() {
    191             $site_url = site_url();
    192             $find_h = '#^http(s)?://#';
    193             $find_w = '/^www\./';
    194             $replace = '';
    195             $output = preg_replace($find_h, $replace, $site_url);
    196             $output = preg_replace($find_w, $replace, $output);
    197             return 'noreply@' . $output;
     202            $host = wp_parse_url(home_url('/'), PHP_URL_HOST);
     203            $address = 'noreply@' . preg_replace('/^www\./i', '', (string) $host);
     204            return is_email($address) ? $address : get_option('admin_email');
    198205        }
    199206
    … …  
    206213         */
    207214        function generate_encryption_key() {
    208             $current_date_time = date('Y-m-d H:i:s');
    209             $encryption_key = md5($current_date_time);
    210             return $encryption_key;
     215            return bin2hex(random_bytes(16));
    211216        }
    212217
    … …  
    222227        function get_download_path($encryption_key) {
    223228            $form_details = get_option('stdl_settings');
    224             if (empty($form_details['general']['download_file_id'])) {
     229            $general = $form_details['general'];
     230            if (empty($general['download_file']) || empty($general['download_file_id'])) {
    225231                // If download file is not available in the settings
    226232                return false;
    227233            }
    228             $attachment_path = get_attached_file(intval($form_details['general']['download_file_id']));
    229             return $attachment_path;
     234            $file_id = absint($general['download_file_id']);
     235            $attachment_url = wp_get_attachment_url($file_id);
     236            if (!$attachment_url || set_url_scheme($attachment_url) !== set_url_scheme($general['download_file'])) {
     237                return false;
     238            }
     239            return get_attached_file($file_id);
    230240        }
    231241
    … …  
    249259            global $wpdb;
    250260            $subscriber_table = STDL_SUBSCRIBERS_TABLE;
    251             $subscriber_count = $wpdb->get_var("SELECT COUNT(*) FROM $subscriber_table WHERE subscriber_encryption_key like '$encryption_key'");
     261            $subscriber_count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $subscriber_table WHERE subscriber_encryption_key = %s AND subscriber_form_alias = %s", $encryption_key, 'stdl'));
    252262            if ($subscriber_count == 0) {
    253263                return false;
  • subscribe-to-download-lite/trunk/inc/cores/subscription-process.php

    r2341208 r3841745  
    33defined('ABSPATH') or die('No script kiddies please!!');
    44
    5 if ($this->ajax_nonce_verify()) {
    6     /**
    7      * Triggers just before processing the subscription form
    8      *
    9      * @since 1.0.0
    10      */
    11     do_action('stdl_before_form_process');
    12     $form_data = $_POST['form_data'];
    13     $form_data = stripslashes_deep($form_data);
    14     parse_str($form_data, $form_data);
    15     $form_data = $this->sanitize_array($form_data);
    16     $form_alias = sanitize_text_field($_POST['form_alias']);
    17     $form_details = get_option('stdl_settings');
    18     $subscriber_email = sanitize_email($form_data['stdl_email']);
    19     $subscriber_name = (!empty($form_data['stdl_name'])) ? sanitize_text_field($form_data['stdl_name']) : '';
    20     if (empty($form_data['stdl_email']) || (!empty($form_details['form']['terms_agreement']['show']) && empty($form_data['stdl_terms_agreement'])) || (!empty($form_details['form']['name']['show']) && !empty($form_details['form']['name']['required']) && empty($form_data['stdl_name']))) {
    21         $response['status'] = 403;
    22         $response['message'] = esc_attr($form_details['general']['required_error_message']);
    23     } else {
    24         //It is okay to process the form now
    25         $subscriber_row = $this->get_subscriber_row_by_email($form_data['stdl_email']);
    26         $from_email = (!empty($form_details['email']['from_email'])) ? $form_details['email']['from_email'] : $this->get_default_from_email();
    27         $from_name = (!empty($form_details['email']['from_name'])) ? $form_details['email']['from_name'] : esc_html__('No Reply', 'subscribe-to-download-lite');
    28         $subject = (!empty($form_details['email']['subject'])) ? $form_details['email']['subject'] : esc_html__('Subscription Successful', 'subscribe-to-download-lite');
    29         $email_message = (!empty($form_details['email']['email_message'])) ? $form_details['email']['email_message'] : $this->get_default_email_message();
     5if (!$this->ajax_nonce_verify()) {
     6    $this->permission_denied();
     7    return;
     8}
    309
    31         $charset = get_option('blog_charset');
    32         $headers[] = 'Content-Type: text/html; charset=' . $charset;
    33         $headers[] = "From: $from_name < $from_email >";
     10do_action('stdl_before_form_process');
    3411
    35         if (empty($subscriber_row)) {
    36             //if subscriber isn't already subscribed
    37             $encryption_key = $this->generate_encryption_key();
    38             if (!empty($form_details['general']['encrypt_link'])) {
     12parse_str(isset($_POST['form_data']) && is_string($_POST['form_data']) ? wp_unslash($_POST['form_data']) : '', $form_data);
     13$form_data = $this->sanitize_array($form_data);
     14$form_details = get_option('stdl_settings');
     15$general = $form_details['general'];
     16$terms = isset($form_details['form']['terms_agreement']) ? $form_details['form']['terms_agreement'] : array();
     17$email = !empty($form_data['stdl_email']) && is_string($form_data['stdl_email']) ? $form_data['stdl_email'] : '';
     18$name = !empty($form_data['stdl_name']) && is_string($form_data['stdl_name']) ? $form_data['stdl_name'] : '';
     19$requires_terms = !empty($terms['show']) && !empty($terms['agreement_text']) && trim(wp_strip_all_tags($terms['agreement_text'])) !== '';
     20$requires_name = !empty($form_details['form']['name']['show']) && !empty($form_details['form']['name']['required']);
    3921
    40                 $download_url = site_url() . '?stdl_encryption_key=' . $encryption_key;
    41             } else {
    42                 $download_url = esc_url($form_details['general']['download_file']);
    43             }
    44             if (!empty($download_url)) {
    45                 $email_message = str_replace('#download_link', '<a href="' . $download_url . '">' . $download_url . '</a>', $email_message);
     22if (!is_email($email) || ($requires_terms && empty($form_data['stdl_terms_agreement'])) || ($requires_name && $name === '')) {
     23    wp_send_json(array('status' => 403, 'message' => esc_html($general['required_error_message'])));
     24}
    4625
    47                 $email_check = wp_mail($form_data['stdl_email'], $subject, $email_message, $headers);
    48                 if ($email_check) {
    49                     setcookie("stdl_encryption_key", $encryption_key, time() + 3600 * 24 * 365, '/');
    50                     global $wpdb;
    51                     $wpdb->insert(STDL_SUBSCRIBERS_TABLE, array('subscriber_name' => $subscriber_name,
    52                         'subscriber_email' => $subscriber_email,
    53                         'subscriber_form_alias' => $form_alias,
    54                         'subscriber_encryption_key' => $encryption_key), array('%s', '%s', '%s', '%s'));
    55                     $response['status'] = 200;
    56                     $response['message'] = esc_attr($form_details['general']['success_message']);
    57                 } else {
    58                     $response['status'] = 403;
    59                     $response['message'] = esc_attr($form_details['general']['error_message']);
    60                 }
    61             } else {
    62                 $response['status'] = 200;
    63                 $response['type'] = esc_html__('Default subscription', 'subscribe-to-download-lite');
    64                 $response['message'] = esc_attr($form_details['general']['success_message']);
    65             }
    66         } else {
    67             //if subscriber is already subscribed
    68             $encryption_key = $subscriber_row->subscriber_encryption_key;
    69             if (!empty($form_details['general']['encrypt_link'])) {
     26$subscriber = $this->get_subscriber_row_by_email($email);
     27$key = $subscriber ? $subscriber->subscriber_encryption_key : $this->generate_encryption_key();
     28$file_url = !empty($general['download_file']) ? esc_url_raw($general['download_file'], array('http', 'https')) : '';
     29if (!$subscriber) {
     30    global $wpdb;
     31    $data = array(
     32        'subscriber_name' => $name,
     33        'subscriber_email' => $email,
     34        'subscriber_form_alias' => 'stdl',
     35        'subscriber_encryption_key' => $key,
     36    );
     37    // Pro can have previously extended this shared table with additional fields.
     38    $table = STDL_SUBSCRIBERS_TABLE;
     39    $columns = $wpdb->get_col("SHOW COLUMNS FROM $table");
     40    foreach (array('subscriber_custom_fields', 'subscribed_user_ip') as $column) {
     41        if (in_array($column, $columns, true)) {
     42            $data[$column] = '';
     43        }
     44    }
     45    $saved = $wpdb->insert($table, $data, array_fill(0, count($data), '%s'));
     46    if (!$saved) {
     47        wp_send_json(array('status' => 403, 'message' => esc_html__('Could not save your subscription. Please try again.', 'subscribe-to-download-lite')));
     48    }
     49}
    7050
    71                 $download_url = site_url() . '?stdl_encryption_key=' . $encryption_key;
    72             } else {
    73                 $download_url = esc_url($form_details['general']['download_file']);
    74             }
    75             if (!empty($download_url)) {
    76 
    77                 $email_message = str_replace('#download_link', '<a href="' . $download_url . '">' . $download_url . '</a>', $email_message);
    78                 /**
    79                  * Filters email message
    80                  *
    81                  * @param string $email_message
    82                  * @param array $form_data
    83                  *
    84                  * @since 1.0.0
    85                  */
    86                 $email_message = apply_filters('stdl_email_message', $email_message, $form_data);
    87                 $email_check = wp_mail($form_data['stdl_email'], $subject, $email_message, $headers);
    88                 if ($email_check) {
    89                     setcookie("stdl_encryption_key", $encryption_key, time() + 3600 * 24 * 365, '/');
    90                     global $wpdb;
    91                     $wpdb->update(STDL_SUBSCRIBERS_TABLE, array('subscriber_form_alias' => $form_alias), array('subscriber_email' => $form_data['stdl_email']), array('%s'), array('%s'));
    92                     $response['status'] = 200;
    93                     $response['message'] = esc_attr($form_details['general']['success_message']);
    94                 } else {
    95                     $response['status'] = 403;
    96                     $response['message'] = esc_attr($form_details['general']['error_message']);
    97                 }
    98             } else {
    99                 $response['status'] = 200;
    100                 $response['type'] = esc_html__('Default subscription', 'subscribe-to-download-lite');
    101                 $response['message'] = esc_attr($form_details['general']['success_message']);
    102             }
    103         }
    104         /**
    105          * Triggers at the end of processing the subscription form successfully
    106          *
    107          * @param array $form_data
    108          *
    109          * @since 1.0.0
    110          */
    111         do_action('stdl_end_form_process', $form_data, $form_details);
     51if ($file_url) {
     52    $download_url = !empty($general['encrypt_link']) ? add_query_arg('stdl_encryption_key', $key, home_url('/')) : $file_url;
     53    $email_settings = $form_details['email'];
     54    $from_email = !empty($email_settings['from_email']) ? $email_settings['from_email'] : $this->get_default_from_email();
     55    $from_name = !empty($email_settings['from_name']) ? $email_settings['from_name'] : esc_html__('No Reply', 'subscribe-to-download-lite');
     56    $subject = !empty($email_settings['subject']) ? $email_settings['subject'] : esc_html__('Subscription Successful', 'subscribe-to-download-lite');
     57    $message = !empty($email_settings['email_message']) ? $email_settings['email_message'] : $this->get_default_email_message();
     58    $link = '<a href="' . esc_url($download_url) . '">' . esc_html($download_url) . '</a>';
     59    $message = strpos($message, '#download_link') === false ? $message . '<br>' . $link : str_replace('#download_link', $link, $message);
     60    if ($subscriber) {
     61        $message = apply_filters('stdl_email_message', $message, $form_data);
     62    }
     63    $headers = array('Content-Type: text/html; charset=' . get_option('blog_charset'), "From: $from_name <$from_email>");
     64    if (!wp_mail($email, $subject, $message, $headers)) {
     65        wp_send_json(array('status' => 403, 'message' => esc_html($general['error_message'])));
    11266    }
    11367
    114     die(json_encode($response));
     68    setcookie('stdl_encryption_key', $key, time() + YEAR_IN_SECONDS, '/', '', is_ssl(), true);
     69    $response = array('status' => 200, 'message' => esc_html($general['success_message']));
    11570} else {
    116     $this->permission_denied();
     71    $response = array(
     72        'status' => 200,
     73        'type' => esc_html__('Default subscription', 'subscribe-to-download-lite'),
     74        'message' => esc_html__('Subscription successful.', 'subscribe-to-download-lite'),
     75    );
    11776}
     77
     78/** Fires after a successful Lite signup and any required download email handoff. */
     79do_action('stdl_end_form_process', $form_data, $form_details);
     80wp_send_json($response);
  • subscribe-to-download-lite/trunk/inc/views/backend/form-sections/stdl-upgrade-to-pro.php

    r3216457 r3841745  
    1010            <p>You can create <strong>unlimited subscription forms</strong>, choose a stunning layout from our
    1111                <strong>20 beautifully pre designed templates</strong>, connect the forms directly to popular third
    12                 party subscription services such as <strong>Mailchimp, Constant Contact, Mailerlite, ConvertKit and
     12                party subscription services such as <strong>Mailchimp, Constant Contact, MailerLite Classic and
    1313                    Brevo/Sendinblue</strong>, <strong>export subscribers</strong> and what not. With this plugin you
    1414                are just few seconds away from collecting the subscribers from your WordPress site because creating and
    … …  
    4545            <div class="stdl-feat-block">
    4646                <div class="stdl-feat-img">
    47                     <a href="https://demo.wpshuffle.com/subscribe-to-unlock/all-templates-demo/" class=""> <img
     47                    <a href="https://demo.wpshuffle.com/subscribe-to-download/all-templates-demo/" class=""> <img
    4848                            loading="lazy" src="https://wpshuffle.com/wp-content/uploads/2025/01/std-feat-3.png"></a>
    4949                </div>
  • subscribe-to-download-lite/trunk/inc/views/backend/stdl-pro-vs-free.php

    r3216457 r3841745  
    168168        <div class="stdl-compare-row stdl--flex stdl--flex-w">
    169169            <div class="stdl-feat-col">
    170                 <p>Mailerlite Integration</p>
     170                <p>MailerLite Classic Integration</p>
    171171            </div>
    172172            <div class="stdl-feat-col">
    … …  
    180180            <div class="stdl-feat-col">
    181181                <p>Brevo/Sendinblue Integration</p>
    182             </div>
    183             <div class="stdl-feat-col">
    184                 <p class="no"><i class="fa fa-times" aria-hidden="true"></i></p>
    185             </div>
    186             <div class="stdl-feat-col">
    187                 <p class="yes"><i class="fa fa-check" aria-hidden="true"></i></p>
    188             </div>
    189         </div>
    190         <div class="stdl-compare-row stdl--flex stdl--flex-w">
    191             <div class="stdl-feat-col">
    192                 <p>ConvertKit Integration</p>
    193182            </div>
    194183            <div class="stdl-feat-col">
    … …  
    253242            <div class="stdl-feat-col">
    254243                <div class="stdl-add-wrap stdl-btn-cntr">
    255                     <a href="https://1.envato.market/PNaY6" class="stdl-button-orange stdl-btn-margin stdl-hov" target="_blank"><?php esc_html_e('Upgrade now', 'subscribe-to-unlock-lite'); ?></a>
     244                    <a href="<?php echo esc_url(STDL_UPGRADE_LINK); ?>" class="stdl-button-orange stdl-btn-margin stdl-hov" target="_blank"><?php esc_html_e('Upgrade now', 'subscribe-to-download-lite'); ?></a>
    256245                </div>
    257246
  • subscribe-to-download-lite/trunk/inc/views/backend/stdl-upgrade.php

    r3216457 r3841745  
    2727            <p>You can create <strong>unlimited subscription forms</strong>, choose a stunning layout from our
    2828                <strong>20 beautifully pre designed templates</strong>, connect the forms directly to popular third
    29                 party subscription services such as <strong>Mailchimp, Constant Contact, Mailerlite, ConvertKit and
     29                party subscription services such as <strong>Mailchimp, Constant Contact, MailerLite Classic and
    3030                    Brevo/Sendinblue</strong>, <strong>export subscribers</strong> and what not. With this plugin you
    3131                are just few seconds away from collecting the subscribers from your WordPress site because creating and
    … …  
    6262            <div class="stdl-feat-block">
    6363                <div class="stdl-feat-img">
    64                     <a href="https://demo.wpshuffle.com/subscribe-to-unlock/all-templates-demo/" class=""> <img
     64                    <a href="https://demo.wpshuffle.com/subscribe-to-download/all-templates-demo/" class=""> <img
    6565                            loading="lazy" src="https://wpshuffle.com/wp-content/uploads/2025/01/std-feat-3.png"></a>
    6666                </div>
  • subscribe-to-download-lite/trunk/inc/views/backend/subscribers/list-subscribers.php

    r3216457 r3841745  
    3939                $subscriber_table = STDL_SUBSCRIBERS_TABLE;
    4040
    41                 $subscriber_query = "select * from $subscriber_table";
     41                $subscriber_query = $wpdb->prepare("SELECT * FROM $subscriber_table WHERE subscriber_form_alias = %s", 'stdl');
    4242
    4343                $subscriber_rows = $wpdb->get_results($subscriber_query);
    … …  
    4848                            <td><?php echo esc_attr($subscriber_row->subscriber_name); ?></td>
    4949                            <td><?php echo esc_attr($subscriber_row->subscriber_email); ?></td>
    50                             <td><?php echo (!empty($subscriber_row->subscriber_download_status)) ? esc_html__('Yes', 'subscribe-to-download-lite') : esc_html__('No', 'subscribe-to-download-lite'); ?></td>
     50                            <td><?php echo esc_html($this->get_download_status_label($subscriber_row->subscriber_download_status)); ?></td>
    5151                            <td>
    5252                                <a class="stdl-delete stdl-subscriber-delete" href="javascript:void(0)" data-subscriber-id="<?php echo intval($subscriber_row->subscriber_id); ?>" title="<?php esc_html_e('Delete Subscriber', 'subscribe-to-download-lite'); ?>"><?php esc_html_e('Delete', 'subscribe-to-download-lite'); ?></a>
  • subscribe-to-download-lite/trunk/inc/views/backend/upgrade.php

    r2920291 r3841745  
    11 <div class="stdl-go-pro">
    2     <a href="https://1.envato.market/Q3KGo" target="_blank"><img src="<?php echo STDL_URL . 'images/UpgradeBanner.png' ?>" /></a>
    3     <a href="https://1.envato.market/Q3KGo" class="stdl-button-orange" target="_blank"><?php esc_html_e('Upgrade now', 'subscribe-to-download-lite'); ?></a>
     2    <a href="<?php echo esc_url(STDL_UPGRADE_LINK); ?>" target="_blank"><img src="<?php echo STDL_URL . 'images/UpgradeBanner.png' ?>" /></a>
     3    <a href="<?php echo esc_url(STDL_UPGRADE_LINK); ?>" class="stdl-button-orange" target="_blank"><?php esc_html_e('Upgrade now', 'subscribe-to-download-lite'); ?></a>
    44</div>
  • subscribe-to-download-lite/trunk/inc/views/frontend/download-button.php

    r2341208 r3841745  
    1 <a href="<?php echo site_url() . '/?stdl_encryption_key=' . sanitize_text_field( $_COOKIE['stdl_encryption_key'] ); ?>" class="stdl-download-button stdl-button-<?php echo esc_attr( $form_template ); ?>"><i class="fa fa-download" aria-hidden="true"></i>
     1<?php
     2$download_url = $form_details['general']['download_file'];
     3if (!empty($form_details['general']['encrypt_link'])) {
     4    $download_url = add_query_arg('stdl_encryption_key', sanitize_text_field($_COOKIE['stdl_encryption_key']), home_url('/'));
     5}
     6?>
     7<a href="<?php echo esc_url($download_url); ?>" class="stdl-download-button stdl-button-<?php echo esc_attr( $form_template ); ?>"><i class="fa fa-download" aria-hidden="true"></i>
    28    <?php echo esc_attr( $form_details['general']['download_button_text'] ); ?></a>
    39
  • subscribe-to-download-lite/trunk/inc/views/frontend/stdl-shortcode.php

    r2341208 r3841745  
    22$form_details = get_option('stdl_settings');
    33$form_template = (!empty($atts['template'])) ? $atts['template'] : $form_details['layout']['template'];
    4 if (isset($_COOKIE['stdl_encryption_key']) && $this->check_if_already_subscribed($_COOKIE['stdl_encryption_key']) && empty($form_details['general']['always_show'])) {
     4if (!empty($form_details['general']['download_file']) && isset($_COOKIE['stdl_encryption_key']) && is_string($_COOKIE['stdl_encryption_key']) && $this->check_if_already_subscribed($_COOKIE['stdl_encryption_key']) && empty($form_details['general']['always_show'])) {
    55    /**
    66     * Triggers just before displaying the download button
  • subscribe-to-download-lite/trunk/js/stdl-frontend.js

    r2341208 r3841745  
    1313        $.ajax({
    1414            type: 'post',
     15            dataType: 'json',
    1516            url: stdl_frontend_obj.ajax_url,
    1617            data: {
    … …  
    2122            },
    2223            beforeSend: function (xhr) {
     24                selector.find(':submit').prop('disabled', true);
    2325                selector.find('.stdl-form-message').slideUp(500);
    2426                selector.find('.stdl-form-loader-wraper').show();
    2527            },
    2628            success: function (res) {
    27                 selector.find('.stdl-form-loader-wraper').hide();
    28                 res = $.parseJSON(res);
    2929                if (res.status == 200) {
    3030                    selector[0].reset();
    … …  
    3333                    selector.find('.stdl-form-message').removeClass('stdl-success').addClass('stdl-error').html(res.message).slideDown(500);
    3434                }
     35            },
     36            error: function () {
     37                selector.find('.stdl-form-message').removeClass('stdl-success').addClass('stdl-error').text(stdl_frontend_obj.request_error).slideDown(500);
     38            },
     39            complete: function () {
     40                selector.find('.stdl-form-loader-wraper').hide();
     41                selector.find(':submit').prop('disabled', false);
    3542            }
    3643        });
  • subscribe-to-download-lite/trunk/readme.txt

    r3716347 r3841745  
    66Tested up to: 7.1
    77Requires PHP: 7.0.0
    8 Stable tag: 1.3.0
     8Stable tag: 1.3.1
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
    … …  
    5757* Show popup form with delay on individual page
    5858* Custom Form Styler Available
    59 * Mailchimp, Constant Contact, MailerLite and other marketing integrations
     59* Mailchimp, Constant Contact, MailerLite Classic and other marketing integrations
    6060* Track Download Status
    6161* And many more ...
    6262
    63 Check all premium features [here](https://1.envato.market/Q3KGo)
     63Check all premium features [here](https://codecanyon.net/item/subscribe-to-download-an-advanced-subscription-plugin-for-wordpress/24020447)
    6464
    6565= Upgrade to PRO =
    6666
    67 * To upgrade to pro, please go [here](https://1.envato.market/Q3KGo)
     67* To upgrade to pro, please go [here](https://codecanyon.net/item/subscribe-to-download-an-advanced-subscription-plugin-for-wordpress/24020447)
    6868* To check demo, please go [here](http://demo.wpshuffle.com/subscribe-to-download)
    6969
    … …  
    116116
    117117== Changelog ==
     118= 1.3.1 =
     119* Fixed signup-only forms so subscribers are saved when no download file is configured.
     120* Improved signup and email error handling so visitors can retry without creating another subscriber record.
     121* Fixed download links for returning subscribers and for files changed to an external URL.
     122* Added a settings check for blank agreement text and scoped the subscriber list and CSV to the Lite form.
     123* Clarified which downloads were tracked or redirected, and corrected the Pro purchase and template demo links.
     124
    118125= 1.3.0 =
    119126* Fixed security issues
  • subscribe-to-download-lite/trunk/subscribe-to-download-lite.php

    r3260547 r3841745  
    66  Plugin URI:  https://wpshuffle.com/subscribe-to-download-lite
    77  Description: A plugin to collect email using an email subscribing form by providing the free downloadable items
    8   Version:     1.3.0
     8  Version:     1.3.1
    99  Author:      WP Shuffle
    1010  Author URI:  http://wpshuffle.com
    … …  
    3333
    3434            global $wpdb;
    35             defined('STDL_VERSION') or define('STDL_VERSION', '1.3.0'); // Plugin's active version
     35            defined('STDL_VERSION') or define('STDL_VERSION', '1.3.1'); // Plugin's active version
    3636            defined('STDL_PATH') or define('STDL_PATH', plugin_dir_path(__FILE__)); // plugin's absolute path
    3737            defined('STDL_URL') or define('STDL_URL', plugin_dir_url(__FILE__)); // plugin's absolute URL
    … …  
    4242            defined('STDL_SUBSCRIBERS_TABLE') or define('STDL_SUBSCRIBERS_TABLE', $wpdb->prefix . 'std_subscribers'); //plugin's subscriber table
    4343            defined('STDL_TOTAL_TEMPLATES') or define('STDL_TOTAL_TEMPLATES', 5); //Total number of templates available
    44             defined('STDL_UPGRADE_LINK') or define('STDL_UPGRADE_LINK', 'https://1.envato.market/Q3KGo');
     44            defined('STDL_UPGRADE_LINK') or define('STDL_UPGRADE_LINK', 'https://codecanyon.net/item/subscribe-to-download-an-advanced-subscription-plugin-for-wordpress/24020447');
    4545        }
    4646
Note: See TracChangeset for help on using the changeset viewer.