Plugin Directory

Changeset 3450297


Ignore:
Timestamp:
01/30/2026 09:47:55 AM (2 months ago)
Author:
pranshtech
Message:

Release version 1.0.1 with security fixes and improvements

Location:
integration-cf7-textdrip/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • integration-cf7-textdrip/trunk/form-capture-plugin.php

    r3015322 r3450297  
    33 * Plugin Name: Integration for CF7 to Textdrip
    44 * Description: Capture Contact Form 7 submissions and send to Textdrip
    5  * Version: 1.0
    6  * Requires at least: 5.7
    7  * Requires PHP: 7.0
     5 * Version: 1.0.1
     6 * Requires at least: 6.5
     7 * Requires PHP: 7.4
     8 * Requires Plugins: contact-form-7
    89 * License: GPLv2 or later
    910 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
     11 * Text Domain: integration-cf7-textdrip
    1012 */
    11 
    1213
    1314if (!defined('ABSPATH')) {
     
    1617
    1718// Add admin menu
    18 add_action('admin_menu', 'textdrip_add_admin_menu');
    19 function textdrip_add_admin_menu() {
     19add_action('admin_menu', 'intefocf_textdrip_add_admin_menu');
     20function intefocf_textdrip_add_admin_menu() {
    2021    add_menu_page(
    2122        'Textdrip Contact Form 7',
    2223        'Textdrip CF7',
    2324        'manage_options',
    24         'textdrip',
    25         'textdrip_settings_page',
    26         'https://imagedelivery.net/ykKK3unAFWyIbSlrQrfCRg/eb1ab807-f7e0-42db-38bc-02f845950700/public' // URL of your custom icon image
     25        'intefocf-textdrip-settings',
     26        'intefocf_textdrip_settings_page',
     27        'https://imagedelivery.net/ykKK3unAFWyIbSlrQrfCRg/eb1ab807-f7e0-42db-38bc-02f845950700/public'
    2728    );
    2829}
    2930
    3031// Display settings page
    31 function textdrip_settings_page() {
     32function intefocf_textdrip_settings_page() {
    3233    ?>
    3334    <div class="wrap">
     
    3536        <form method="post" action="options.php">
    3637            <?php
    37             settings_fields('textdrip_options');
    38             do_settings_sections('textdrip');
     38            settings_fields('intefocf_textdrip_options');
     39            do_settings_sections('intefocf-textdrip');
    3940            ?>
    40             <label for="textdrip_api_key">API Key:</label>
    41             <input type="text" id="textdrip_api_key" name="textdrip_api_key" value="<?php echo esc_attr(get_option('textdrip_api_key')); ?>" placeholder="Enter API Key" />
    42             <button type="button" id="fetch-textdrip-campaigns">Fetch Textdrip Campaigns</button>
     41            <label for="intefocf_textdrip_api_key">API Key:</label>
     42            <input type="text" id="intefocf_textdrip_api_key" name="intefocf_textdrip_api_key" value="<?php echo esc_attr(get_option('intefocf_textdrip_api_key')); ?>" placeholder="Enter API Key" />
     43            <button type="button" id="intefocf-fetch-textdrip-campaigns">Fetch Textdrip Campaigns</button>
    4344            <br>
    44             <div id="debugger"></div>
     45            <div id="intefocf-debugger"></div>
    4546            <br>
    4647            <?php
     
    5253            $cf7Forms = get_posts($args);
    5354            foreach ($cf7Forms as $form) {
    54                 $currentCampaign = get_option('cf7form_campaign_' . $form->ID);
    55                 echo '<label for="cf7form_' . esc_attr($form->ID) . '">';
    56                 echo '<input type="checkbox" id="cf7form_' . esc_attr($form->ID) . '" name="cf7form_' . esc_attr($form->ID) . '" value="1" ' . checked(1, get_option('cf7form_' . $form->ID), false) . ' />';
     55                $currentCampaign = get_option('intefocf_cf7form_campaign_' . $form->ID);
     56                echo '<label for="intefocf_cf7form_' . esc_attr($form->ID) . '">';
     57                echo '<input type="checkbox" id="intefocf_cf7form_' . esc_attr($form->ID) . '" name="intefocf_cf7form_' . esc_attr($form->ID) . '" value="1" ' . checked(1, get_option('intefocf_cf7form_' . $form->ID), false) . ' />';
    5758                echo esc_attr($form->post_title);
    5859                echo '</label>';
    59                 echo '<select id="cf7form_campaign_' . esc_attr($form->ID) . '" class="textdrip-campaign-select" name="cf7form_campaign_' . esc_attr($form->ID) . '">';
     60                echo '<select id="intefocf_cf7form_campaign_' . esc_attr($form->ID) . '" class="intefocf-textdrip-campaign-select" name="intefocf_cf7form_campaign_' . esc_attr($form->ID) . '">';
    6061                echo '<option value="">Select Campaign</option>';
    61                 // Pre-select the current campaign if it exists
    6262                if ($currentCampaign) {
    6363                    echo '<option value="' . esc_attr($currentCampaign) . '" selected="selected">' . esc_html($currentCampaign) . '</option>';
     
    7474
    7575// Register settings
    76 add_action('admin_init', 'textdrip_settings_init');
    77 function textdrip_settings_init() {
    78     register_setting('textdrip_options', 'textdrip_api_key');
     76add_action('admin_init', 'intefocf_textdrip_settings_init');
     77function intefocf_textdrip_settings_init() {
     78    register_setting(
     79        'intefocf_textdrip_options',
     80        'intefocf_textdrip_api_key',
     81        array(
     82            'type' => 'string',
     83            'sanitize_callback' => 'sanitize_text_field',
     84            'default' => ''
     85        )
     86    );
    7987}
    8088
    8189// Capture CF7 form data and send to API
    82 add_action('wpcf7_before_send_mail', 'textdrip_capture_form_data');
    83 function textdrip_capture_form_data($contact_form) {
     90add_action('wpcf7_before_send_mail', 'intefocf_capture_form_data');
     91function intefocf_capture_form_data($contact_form) {
    8492    $submission = WPCF7_Submission::get_instance();
    8593
     
    92100
    93101        $form_id = $contact_form->id();
    94         $api_key = get_option('textdrip_api_key');
    95         $campaign = get_option('cf7form_campaign_' . $form_id);
     102        $api_key = get_option('intefocf_textdrip_api_key');
     103        $campaign = get_option('intefocf_cf7form_campaign_' . $form_id);
    96104
    97         if (get_option('cf7form_' . $form_id)) {
     105        if (get_option('intefocf_cf7form_' . $form_id)) {
    98106            $api_url = "https://api.textdrip.com/api/create-contact";
    99107
     
    115123            // Send to Textdrip API
    116124            $response = wp_safe_remote_post($api_url, $args);
    117 
    118             // Handle the API response here (e.g., log errors)
     125           
     126            // Log errors for debugging
     127            if (is_wp_error($response)) {
     128                error_log('Textdrip API Error: ' . $response->get_error_message());
     129            }
    119130        }
    120131    }
    121132}
    122133
    123 // Enqueue JavaScript
    124 function textdrip_enqueue_custom_admin_script() {
    125     wp_enqueue_script('my-custom-script', plugins_url('/textdrip-admin.js', __FILE__), array('jquery'));
     134// Enqueue JavaScript only on our plugin page
     135add_action('admin_enqueue_scripts', 'intefocf_enqueue_admin_scripts');
     136function intefocf_enqueue_admin_scripts($hook) {
     137    // Only load on our plugin's settings page
     138    if ('toplevel_page_intefocf-textdrip-settings' !== $hook) {
     139        return;
     140    }
     141   
     142    wp_enqueue_script(
     143        'intefocf-admin-script',
     144        plugins_url('/textdrip-admin.js', __FILE__),
     145        array('jquery'),
     146        '1.0.1',
     147        true
     148    );
    126149}
    127 add_action('admin_enqueue_scripts', 'textdrip_enqueue_custom_admin_script');
    128150?>
  • integration-cf7-textdrip/trunk/readme.txt

    r3015322 r3450297  
    11=== Integration for CF7 to Textdrip ===
    22Contributors: Textdrip
    3 Tags: contact form for textdrip
    4 Requires at least: 5.7
    5 Tested up to: 6.3
    6 Stable tag: 1.0
    7 Requires PHP: 7.0
     3Tags: contact form, textdrip, contact form 7, cf7, integration
     4Requires at least: 6.5
     5Tested up to: 6.6
     6Stable tag: 1.0.1
     7Requires PHP: 7.4
     8Requires Plugins: contact-form-7
    89License: GPLv2 or later
    910License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    1314== Description ==
    1415
    15 Capture Contact Form 7 submissions and send to Textdrip
     16Integration for CF7 to Textdrip seamlessly connects your Contact Form 7 forms with Textdrip CRM. Capture form submissions and automatically send contact data to your Textdrip campaigns.
     17
     18= Key Features =
     19* Connect Contact Form 7 forms to Textdrip CRM
     20* Map form fields to Textdrip contact fields
     21* Assign submissions to specific Textdrip campaigns
     22* Easy setup with API key integration
     23* Fetch campaigns directly from Textdrip
     24* Secure data transmission
     25
     26= How it works =
     271. Enter your Textdrip API key
     282. Select which Contact Form 7 forms to integrate
     293. Choose a Textdrip campaign for each form
     304. Form submissions are automatically sent to Textdrip
    1631
    1732== Installation ==
     
    19341. Install Textdrip CF7 Connector either via the WordPress.org plugin directory, or by uploading the files to your
    2035   server.
    21 2. Activate the plugin through the 'Plugins' menu in WordPress
    22 3. You will see the Textdrip CF7 icon in your sidebar, below the Plugins section in the wp-admin area of your site.
     362. **Important:** This plugin requires Contact Form 7 to be installed and activated first.
     373. Activate the plugin through the 'Plugins' menu in WordPress
     384. You will see the Textdrip CF7 icon in your sidebar, below the Plugins section in the wp-admin area of your site.
    2339   Click on it.
    24 4. Add API Key, boarding Form and Contact Form Detail from textdrip site.
    25 5. That's it! Really, it is that simple!
     405. Add your Textdrip API Key, select forms, and assign campaigns
     416. That's it! Form submissions will now be sent to Textdrip
    2642
    2743= Privacy notices =
    2844
    29 In this plugin, the contact form submitter's personal data, may be sent to the service provider. Thus, confirming the provider's privacy policy is recommended.
     45In this plugin, the contact form submitter's personal data may be sent to the service provider. Thus, confirming the provider's privacy policy is recommended.
    3046
    3147* Privacy Policy ([Textdrip](https://textdrip.com/privacy-policy))
    3248* Terms & Conditions ([Textdrip](https://textdrip.com/term-condition))
    3349
     50= Requirements =
     51* WordPress 6.5 or higher
     52* PHP 7.4 or higher
     53* Contact Form 7 plugin (required)
    3454
    3555== Frequently Asked Questions ==
    3656
    3757= What exactly does Integration for CF7 to Textdrip do? =
    38 Integration for CF7 to Textdrip can be used to get contact detail from textdrip site.
     58Integration for CF7 to Textdrip captures submissions from your Contact Form 7 forms and sends the contact data to your Textdrip CRM account, where you can manage leads and campaigns.
     59
     60= Where do I get my Textdrip API key? =
     61You can find your API key in your Textdrip account settings under API or Developer settings.
     62
     63= Can I use multiple campaigns? =
     64Yes, you can assign different campaigns to different Contact Form 7 forms.
     65
     66= What data is sent to Textdrip? =
     67The plugin sends name, email, phone number, and assigns the contact to your selected campaign.
     68
     69= Is my data secure? =
     70Yes, all communication with Textdrip's API is done over secure HTTPS connections.
    3971
    4072== Screenshots ==
    4173
    42 1. screenshot-1.png
     741. screenshot-1.png - Plugin settings page with API key field and form selection
    4375
    4476== Changelog ==
     77
     78= 1.0.1 =
     79* Added proper plugin dependency declaration
     80* Improved code security with proper sanitization
     81* Fixed admin assets loading only on plugin pages
     82* Updated unique prefixes to prevent conflicts
     83* Updated minimum WordPress version to 6.5
     84* Enhanced code quality and performance
    4585
    4686= 1.0 =
     
    4989== Upgrade Notice ==
    5090
     91= 1.0.1 =
     92**Important:** This update includes security improvements and requires WordPress 6.5 or higher. After updating, you may need to re-enter your API key and form settings due to improved security measures.
     93
    5194= 1.0 =
    52 Just released into the wild.
     95Initial release. Make sure you have Contact Form 7 installed and activated before using this plugin.
  • integration-cf7-textdrip/trunk/textdrip-admin.js

    r3015322 r3450297  
    11jQuery(document).ready(function($) {
    2     $("#fetch-textdrip-campaigns").click(function() {
    3         const apiKey = $("#textdrip_api_key").val();
     2    $('#intefocf-fetch-textdrip-campaigns').on('click', function() {
     3        var apiKey = $('#intefocf_textdrip_api_key').val();
    44       
     5        if (!apiKey) {
     6            alert('Please enter your API Key first');
     7            return;
     8        }
     9
    510        // Make API call to fetch campaigns
    611        $.ajax({
    7             url: "https://api.textdrip.com/api/get-campaign",
    8             type: "POST",
     12            url: 'https://api.textdrip.com/api/campaigns',
     13            method: 'GET',
    914            headers: {
    10                 'Authorization': `Bearer ${apiKey}`,
    11                 'Accept': 'application/json',
     15                'Authorization': 'Bearer ' + apiKey,
    1216                'Content-Type': 'application/json'
    1317            },
    1418            success: function(response) {
    15                 $("#debugger").html(`Response received: ${JSON.stringify(response)}`);
    16                
    17                 // Populate dropdowns with fetched campaigns
    18                 $('.textdrip-campaign-select').empty();
    19                 $('.textdrip-campaign-select').append('<option value="">Select Campaign</option>');
    20                
    21                 // Store fetched campaigns to transient via an AJAX call to the server
    22                 $.post(ajaxurl, {
    23                     'action': 'store_campaigns_to_transient',
    24                     'campaigns': response.data
    25                 }, function(response) {
    26                     if (response.success) {
    27                         console.log('Campaigns stored successfully');
    28                     } else {
    29                         console.log('Failed to store campaigns');
    30                     }
     19                // Clear all select options except the first one
     20                $('.intefocf-textdrip-campaign-select').each(function() {
     21                    $(this).find('option:not(:first)').remove();
    3122                });
    3223
    33                 for (const campaign of response.data) {
    34                     $('.textdrip-campaign-select').append(`<option value="${campaign.id}">${campaign.title}</option>`);
     24                // Add new campaign options
     25                if (response && response.length > 0) {
     26                    response.forEach(function(campaign) {
     27                        var option = $('<option>').val(campaign.id).text(campaign.name);
     28                        $('.intefocf-textdrip-campaign-select').append(option);
     29                    });
     30                   
     31                    $('#intefocf-debugger').html('<p style="color: green;">Campaigns loaded successfully!</p>');
     32                } else {
     33                    $('#intefocf-debugger').html('<p style="color: orange;">No campaigns found or API returned empty.</p>');
    3534                }
    3635            },
    3736            error: function(xhr, status, error) {
    38                 $("#debugger").html(`Error: ${error}`);
     37                $('#intefocf-debugger').html('<p style="color: red;">Error fetching campaigns: ' + error + '</p>');
    3938            }
    4039        });
Note: See TracChangeset for help on using the changeset viewer.