Changeset 882944
- Timestamp:
- 03/27/2014 01:36:52 PM (12 years ago)
- Location:
- marketo-lead-tracking/trunk
- Files:
-
- 3 edited
-
fieldmap.js (modified) (2 diffs)
-
marketotracking.php (modified) (3 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
marketo-lead-tracking/trunk/fieldmap.js
r882442 r882944 3 3 jQuery('#wmi-btn-add').click(function( event ) { 4 4 event.preventDefault(); 5 var output = '<tr valign="top">'; 6 output = output + '<th id="mktocell" scope="row"><input type="text" id="" value="" placeholder="Marketo Field Name" /></th>'; 7 output = output + '<td id="fieldcell"><input type="text" id="" value="" placeholder="Local Field Name" /><a href="#" id="wmi-btn-del" class="button" style="margin-left: 10px;">Delete</a></td>'; 8 output = output + '</tr>'; 9 jQuery('#wmi-field-mapping').append(output); 5 addField(); 10 6 }); 11 7 jQuery('#wmi-btn-del').live('click', function( event ) { … … 27 23 //event.preventDefault(); 28 24 }); 25 jQuery('#wmi-btn-detect').click(function( event ) { 26 event.preventDefault(); 27 jQuery(this).attr('disabled',true); 28 var url = jQuery('#detectpages').val(); 29 detectFields(url, jQuery(this)); 30 }); 29 31 }); 32 33 function addField(val) { 34 if (!val) val = ''; 35 var output = '<tr valign="top">'; 36 output = output + '<th id="mktocell" scope="row"><input type="text" id="" value="" placeholder="Marketo Field Name" /></th>'; 37 output = output + '<td id="fieldcell"><input type="text" id="" value="' + val + '" placeholder="Local Field Name" /><a href="#" id="wmi-btn-del" class="button" style="margin-left: 10px;">Delete</a></td>'; 38 output = output + '</tr>'; 39 jQuery('#wmi-field-mapping').append(output); 40 } 41 42 function detectFields(url, hobj) { 43 jQuery.get(url, function(data) { 44 var obj = jQuery(data); 45 if (obj.find('form').attr('method') != 'POST') { 46 alert('There is a form on this page, but it does not POST.'); 47 } else { 48 var fields = false; 49 jQuery.each(obj.find('input'), function() { 50 var a = jQuery(this).attr('name'); 51 if (a != 's' && a != '' && a) { 52 addField(a); 53 fields = true; 54 } 55 }); 56 jQuery.each(obj.find('select'), function() { 57 var a = jQuery(this).attr('name'); 58 if (a != 's' && a != '' && a) { 59 addField(a); 60 fields = true; 61 } 62 }); 63 jQuery.each(obj.find('textarea'), function() { 64 var a = jQuery(this).attr('name'); 65 if (a != 's' && a != '' && a) { 66 addField(a); 67 fields = true; 68 } 69 }); 70 if (!fields) { 71 alert('No compatible form fields were found on that page.'); 72 } 73 } 74 hobj.attr('disabled',false); 75 }); 76 } 77 30 78 /*} else { 31 79 alert('The Wordpress Marketo Lead Tracking plugin requires JQuery. Please include JQuery in your theme.'); -
marketo-lead-tracking/trunk/marketotracking.php
r882464 r882944 4 4 * Plugin URI: http://www.rmlsoftwaresolutions.com/wordpress-plugins 5 5 * Description: Attaches Marketo tracking code to website. Lets you map any form field to a specific field in marketo, including custom fields. NOTE: This is not a forms plugin. You use it in conjunction with your existing forms solution, or you can also use it with custom forms. 6 * Version: 0. 16 * Version: 0.2 7 7 * Author: Robert Lester 8 8 * Author URI: http://www.rmlsoftwaresolutions.com … … 27 27 function wmi_scripts() { 28 28 wp_enqueue_script( 'fieldmap.js', plugins_url() . '/marketo-lead-tracking/fieldmap.js', array(), '1.0.0', false ); 29 } 30 31 function detect_fields($page) { 32 $dom = new DOMDocument(); 33 $html = file_get_contents('example.html'); 34 35 $names = array(); 36 37 @$dom->loadHTML($html); 38 39 $in = $dom->getElementsByTagName('input'); 40 $sel = $dom->getElementsByTagName('select'); 41 $ta = $dom->getElementsByTagName('textarea'); 42 43 for ($i; $i < $in->length; $i++) { 44 $attr = $in->item($i)->getAttribute('name'); 45 $names[] = $attr; 46 } 47 for ($i; $i < $sel->length; $i++) { 48 $attr = $sel->item($i)->getAttribute('name'); 49 $names[] = $attr; 50 } 51 for ($i; $i < $ta->length; $i++) { 52 $attr = $ta->item($i)->getAttribute('name'); 53 $names[] = $attr; 54 } 55 56 return json_encode($names); 29 57 } 30 58 … … 136 164 <td colspan="2"><a href="#" id="wmi-btn-add" class="button button-primary">Add</a></td> 137 165 </tr> 166 <tr valign="top"> 167 <th scope="row">Autodetect fields on page:</th> 168 <td> 169 <select id="detectpages"> 170 <?php 171 $posts = get_posts(array( 'posts_per_page'=>10000, 'post_status'=>'publish', 'post_type'=>'any' )); 172 foreach ($posts as $post) { 173 echo '<option value="' . get_permalink($post->ID) . '">' . $post->post_title . '</option>'; 174 } 175 ?> 176 </select> 177 <a href="#" id="wmi-btn-detect" class="button">Detect</a></td> 178 </tr> 138 179 <tr> 139 180 <td colspan="2">For the "Local Field Name" you must enter the actual "name" attribute of the text box in the form from which you want to send the data to Marketo. Also, for this plugin to work, your forms must post.</td> -
marketo-lead-tracking/trunk/readme.txt
r882461 r882944 16 16 including custom fields. NOTE: This is not a forms plugin. 17 17 You use it in conjunction with your existing forms solution, or you can also use it with custom forms. 18 19 Now it will help you identify form fields on a page! 18 20 19 21 == Installation == … … 36 38 0.1 Initial Build 37 39 40 0.2 Added form detection in admin panel. Select the page or post from the list, select detect, and it will find the form fields for you. 41 38 42 == Upgrade Notice == 39 43
Note: See TracChangeset
for help on using the changeset viewer.