Changeset 3450297
- Timestamp:
- 01/30/2026 09:47:55 AM (2 months ago)
- Location:
- integration-cf7-textdrip/trunk
- Files:
-
- 3 edited
-
form-capture-plugin.php (modified) (7 diffs)
-
readme.txt (modified) (4 diffs)
-
textdrip-admin.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
integration-cf7-textdrip/trunk/form-capture-plugin.php
r3015322 r3450297 3 3 * Plugin Name: Integration for CF7 to Textdrip 4 4 * 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 8 9 * License: GPLv2 or later 9 10 * License URI: https://www.gnu.org/licenses/gpl-2.0.html 11 * Text Domain: integration-cf7-textdrip 10 12 */ 11 12 13 13 14 if (!defined('ABSPATH')) { … … 16 17 17 18 // Add admin menu 18 add_action('admin_menu', ' textdrip_add_admin_menu');19 function textdrip_add_admin_menu() {19 add_action('admin_menu', 'intefocf_textdrip_add_admin_menu'); 20 function intefocf_textdrip_add_admin_menu() { 20 21 add_menu_page( 21 22 'Textdrip Contact Form 7', 22 23 'Textdrip CF7', 23 24 'manage_options', 24 ' textdrip',25 ' textdrip_settings_page',26 'https://imagedelivery.net/ykKK3unAFWyIbSlrQrfCRg/eb1ab807-f7e0-42db-38bc-02f845950700/public' // URL of your custom icon image25 'intefocf-textdrip-settings', 26 'intefocf_textdrip_settings_page', 27 'https://imagedelivery.net/ykKK3unAFWyIbSlrQrfCRg/eb1ab807-f7e0-42db-38bc-02f845950700/public' 27 28 ); 28 29 } 29 30 30 31 // Display settings page 31 function textdrip_settings_page() {32 function intefocf_textdrip_settings_page() { 32 33 ?> 33 34 <div class="wrap"> … … 35 36 <form method="post" action="options.php"> 36 37 <?php 37 settings_fields(' textdrip_options');38 do_settings_sections(' textdrip');38 settings_fields('intefocf_textdrip_options'); 39 do_settings_sections('intefocf-textdrip'); 39 40 ?> 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> 43 44 <br> 44 <div id=" debugger"></div>45 <div id="intefocf-debugger"></div> 45 46 <br> 46 47 <?php … … 52 53 $cf7Forms = get_posts($args); 53 54 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) . ' />'; 57 58 echo esc_attr($form->post_title); 58 59 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) . '">'; 60 61 echo '<option value="">Select Campaign</option>'; 61 // Pre-select the current campaign if it exists62 62 if ($currentCampaign) { 63 63 echo '<option value="' . esc_attr($currentCampaign) . '" selected="selected">' . esc_html($currentCampaign) . '</option>'; … … 74 74 75 75 // Register settings 76 add_action('admin_init', 'textdrip_settings_init'); 77 function textdrip_settings_init() { 78 register_setting('textdrip_options', 'textdrip_api_key'); 76 add_action('admin_init', 'intefocf_textdrip_settings_init'); 77 function 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 ); 79 87 } 80 88 81 89 // 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) {90 add_action('wpcf7_before_send_mail', 'intefocf_capture_form_data'); 91 function intefocf_capture_form_data($contact_form) { 84 92 $submission = WPCF7_Submission::get_instance(); 85 93 … … 92 100 93 101 $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); 96 104 97 if (get_option(' cf7form_' . $form_id)) {105 if (get_option('intefocf_cf7form_' . $form_id)) { 98 106 $api_url = "https://api.textdrip.com/api/create-contact"; 99 107 … … 115 123 // Send to Textdrip API 116 124 $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 } 119 130 } 120 131 } 121 132 } 122 133 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 135 add_action('admin_enqueue_scripts', 'intefocf_enqueue_admin_scripts'); 136 function 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 ); 126 149 } 127 add_action('admin_enqueue_scripts', 'textdrip_enqueue_custom_admin_script');128 150 ?> -
integration-cf7-textdrip/trunk/readme.txt
r3015322 r3450297 1 1 === Integration for CF7 to Textdrip === 2 2 Contributors: 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 3 Tags: contact form, textdrip, contact form 7, cf7, integration 4 Requires at least: 6.5 5 Tested up to: 6.6 6 Stable tag: 1.0.1 7 Requires PHP: 7.4 8 Requires Plugins: contact-form-7 8 9 License: GPLv2 or later 9 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 13 14 == Description == 14 15 15 Capture Contact Form 7 submissions and send to Textdrip 16 Integration 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 = 27 1. Enter your Textdrip API key 28 2. Select which Contact Form 7 forms to integrate 29 3. Choose a Textdrip campaign for each form 30 4. Form submissions are automatically sent to Textdrip 16 31 17 32 == Installation == … … 19 34 1. Install Textdrip CF7 Connector either via the WordPress.org plugin directory, or by uploading the files to your 20 35 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. 36 2. **Important:** This plugin requires Contact Form 7 to be installed and activated first. 37 3. Activate the plugin through the 'Plugins' menu in WordPress 38 4. You will see the Textdrip CF7 icon in your sidebar, below the Plugins section in the wp-admin area of your site. 23 39 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! 40 5. Add your Textdrip API Key, select forms, and assign campaigns 41 6. That's it! Form submissions will now be sent to Textdrip 26 42 27 43 = Privacy notices = 28 44 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.45 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. 30 46 31 47 * Privacy Policy ([Textdrip](https://textdrip.com/privacy-policy)) 32 48 * Terms & Conditions ([Textdrip](https://textdrip.com/term-condition)) 33 49 50 = Requirements = 51 * WordPress 6.5 or higher 52 * PHP 7.4 or higher 53 * Contact Form 7 plugin (required) 34 54 35 55 == Frequently Asked Questions == 36 56 37 57 = 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. 58 Integration 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? = 61 You can find your API key in your Textdrip account settings under API or Developer settings. 62 63 = Can I use multiple campaigns? = 64 Yes, you can assign different campaigns to different Contact Form 7 forms. 65 66 = What data is sent to Textdrip? = 67 The plugin sends name, email, phone number, and assigns the contact to your selected campaign. 68 69 = Is my data secure? = 70 Yes, all communication with Textdrip's API is done over secure HTTPS connections. 39 71 40 72 == Screenshots == 41 73 42 1. screenshot-1.png 74 1. screenshot-1.png - Plugin settings page with API key field and form selection 43 75 44 76 == 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 45 85 46 86 = 1.0 = … … 49 89 == Upgrade Notice == 50 90 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 51 94 = 1.0 = 52 Just released into the wild.95 Initial release. Make sure you have Contact Form 7 installed and activated before using this plugin. -
integration-cf7-textdrip/trunk/textdrip-admin.js
r3015322 r3450297 1 1 jQuery(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(); 4 4 5 if (!apiKey) { 6 alert('Please enter your API Key first'); 7 return; 8 } 9 5 10 // Make API call to fetch campaigns 6 11 $.ajax({ 7 url: "https://api.textdrip.com/api/get-campaign",8 type: "POST",12 url: 'https://api.textdrip.com/api/campaigns', 13 method: 'GET', 9 14 headers: { 10 'Authorization': `Bearer ${apiKey}`, 11 'Accept': 'application/json', 15 'Authorization': 'Bearer ' + apiKey, 12 16 'Content-Type': 'application/json' 13 17 }, 14 18 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(); 31 22 }); 32 23 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>'); 35 34 } 36 35 }, 37 36 error: function(xhr, status, error) { 38 $( "#debugger").html(`Error: ${error}`);37 $('#intefocf-debugger').html('<p style="color: red;">Error fetching campaigns: ' + error + '</p>'); 39 38 } 40 39 });
Note: See TracChangeset
for help on using the changeset viewer.