Changeset 3065401
- Timestamp:
- 04/05/2024 11:27:07 AM (23 months ago)
- Location:
- pinpointe-form-integration/trunk
- Files:
-
- 9 edited
-
assets/css/style-admin.css (modified) (1 diff)
-
assets/js/pinpointe-admin.js (modified) (8 diffs)
-
includes/pinpointe-form.inc.php (modified) (2 diffs)
-
includes/pinpointe-plugin-structure.inc.php (modified) (32 diffs)
-
includes/pinpointe-prepare-form.inc.php (modified) (3 diffs)
-
includes/pinpointe-service.class.php (modified) (9 diffs)
-
includes/pinpointe-widget.class.php (modified) (4 diffs)
-
pinpointe-signup-form.php (modified) (59 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
pinpointe-form-integration/trunk/assets/css/style-admin.css
r2547924 r3065401 70 70 width: 70px; 71 71 min-width: 70px; 72 } 73 74 .pinpointe_forms_confirmation_email_tr td{ 75 padding-left: 0px; 72 76 } 73 77 -
pinpointe-form-integration/trunk/assets/js/pinpointe-admin.js
r2547924 r3065401 10 10 */ 11 11 jQuery('form').each(function(){ 12 //show/hide confirmation_email depending on overide_confirmation value 13 jQuery(this).find('.pinpointe_forms_send_confirmation').each(function(){ 14 pinpointe_hide_confirmation_email_trs(this); 15 pinpointe_hide_confirmation_email_tr(jQuery(this).parent().parent().parent().find('.pinpointe_forms_overide_confirmation')); 16 }); 17 jQuery(this).find('.pinpointe_forms_overide_confirmation').each(function(){ 18 pinpointe_hide_confirmation_email_tr(this); 19 }); 20 //add hints 12 21 jQuery(this).find(':input').each(function(){ 13 22 if (typeof pinpointe_hints !== 'undefined' && typeof pinpointe_hints[jQuery(this).prop('id')] !== 'undefined') { … … 38 47 }); 39 48 jQuery('.pinpointe_tip').tooltip(); 49 50 /** 51 * show/hide confirmation_email depending on overide_confirmation value 52 */ 53 function pinpointe_hide_confirmation_email_tr(overide_obj) { 54 var confirmation_email = jQuery(overide_obj).parent().parent().parent().find('.pinpointe_forms_confirmation_email_tr'); 55 if (jQuery(overide_obj).is(':checked')) { 56 confirmation_email.show(); 57 } else { 58 confirmation_email.hide(); 59 } 60 } 61 62 jQuery('.pinpointe_forms_overide_confirmation').click(function() { 63 pinpointe_hide_confirmation_email_tr(this); 64 }); 65 66 function pinpointe_hide_confirmation_email_trs(send_confirmation_obj) { 67 var confirmation_overide = jQuery(send_confirmation_obj).parent().parent().parent().find('.pinpointe_forms_confirmation_email_trs'); 68 if (jQuery(send_confirmation_obj).is(':checked')) { 69 confirmation_overide.show(); 70 } else { 71 confirmation_overide.hide(); 72 } 73 } 74 75 jQuery('.pinpointe_forms_send_confirmation').click(function() { 76 if (!jQuery(this).is(':checked')) { 77 jQuery(this).parent().parent().next().find('.pinpointe_forms_overide_confirmation').prop("checked", false); 78 } 79 pinpointe_hide_confirmation_email_trs(this); 80 pinpointe_hide_confirmation_email_tr(jQuery(this).parent().parent().parent().find('.pinpointe_forms_overide_confirmation')); 81 }); 40 82 41 83 /** … … 120 162 }); 121 163 164 function activateWPEditors(id) { 165 wp.editor.initialize(id, { 166 tinymce: { 167 height: 500, 168 toolbar1: 169 "bold italic underline strikethrough | bullist numlist | blockquote hr | alignleft aligncenter alignright | link unlink", 170 }, 171 quicktags: true, 172 mediaButtons: false, 173 }); 174 } 175 122 176 /** 123 177 * Set up accordion (form management) 124 178 */ 125 179 jQuery('#pinpointe_forms_list').accordion({ 126 header: '> div > h4', 127 heightStyle: 'content', 128 create: function(event, ui) { FormEditorChanged(); } // SDL 180 header: "> div > h4", 181 heightStyle: "content", 182 create: function (event, ui) { 183 FormEditorChanged(); 184 }, // SDL 185 activate: function (event, ui) { 186 var oldEditor = jQuery(ui.oldPanel).find("textarea.pinpointe-field.pinpointe_forms_html_confirmation_email").attr("id"); 187 188 if (tinyMCE.get(oldEditor) !== null || tinyMCE.get(oldEditor) !== undefined) { 189 wp.editor.remove(oldEditor); 190 } 191 192 var newEditor = jQuery(ui.newPanel).find("textarea.pinpointe-field.pinpointe_forms_html_confirmation_email").attr("id"); 193 194 if (tinyMCE.get(newEditor)) { 195 return; 196 } else { 197 activateWPEditors(newEditor); 198 } 199 // activate chosen on all mailing lists when we click on a form 200 jQuery('.pinpointe-field.pinpointe_forms_mailing_tag').each(function () { 201 jQuery(this).chosen({ 202 no_results_text: pinpointe_label_no_results_match_tag, 203 width: '366px' 204 }); 205 }); 206 }, 129 207 }).sortable({ 130 handle: 'h4', 131 stop: function(event, ui) { 132 regenerate_accordion_handle_titles(); 133 } 134 }); 135 208 handle: "h4", 209 stop: function (event, ui) { 210 regenerate_accordion_handle_titles(); 211 }, 212 }); 213 214 function activate_editors() { 215 jQuery( 216 "textarea.pinpointe-field.pinpointe_forms_html_confirmation_email", 217 ).each(function (index, editor) { 218 activateWPEditors(editor.id); 219 }); 220 } 221 222 activate_editors(); 136 223 /** 137 224 * Make pages, posts and post_categories fields chosen on form setup … … 182 269 }); 183 270 271 var selected_options = []; 184 272 /** 185 273 * Forms page - lists and groups … … 214 302 215 303 jQuery('.pinpointe_forms_field_tag_groups').each(function() { 216 304 //we are increment here cause on new forms i.e, how new forms are added by PHP (saved forms) 217 305 current_field_id++; 218 219 var current_selected_tag = (typeof pinpointe_selected_tags[current_field_id] !== 'undefined' && typeof pinpointe_selected_tags[current_field_id]['tag'] !== 'undefined' ? pinpointe_selected_tags[current_field_id]['tag'] : null); 306 307 var current_mailing_list_id = 1; 308 309 let selectedTags = (typeof pinpointe_selected_tags[current_field_id] !== "undefined" && 310 typeof pinpointe_selected_tags[current_field_id].tags !== "undefined") 311 ? pinpointe_selected_tags[current_field_id].tags 312 : null; 220 313 221 314 // List selection 222 315 if (typeof result['message']['tags'] === 'object') { 223 // var fields = ''; 224 var fields = '<option value=""> </option>'; // SDL 225 for (var prop in result['message']['tags']) { 226 fields += '<option value="' + prop + '" ' + (current_selected_tag !== null && current_selected_tag === prop ? 'selected="selected"' : '') + '>' + result['message']['tags'][prop] + '</option>'; 316 317 var pinpointe_label_mailing_list_name = 'Mailing List Name'; 318 var pinpointe_label_selected_list = 'Selected List'; 319 var pinpointe_label_add_new_mailing_list = 'Add Mailing List'; 320 321 var mailing_list_html = '<table id="pinpointe_mailing_list_table_' + current_field_id + '" class="pinpointe_fields_table" style="width: 98%; text-align: left;"><thead><tr><th>' + pinpointe_label_mailing_list_name + '</th><th>' + pinpointe_label_selected_list + '</th><th></th></tr></thead><tbody>'; 322 323 if (selectedTags && Array.isArray(selectedTags)) { 324 for (var i = 1; i <= selectedTags.length; i++) { 325 let currentSelectedTag = selectedTags[i - 1]; 326 selected_options.push(currentSelectedTag); 327 328 let fields = '<option value=""> </option>'; // SDL 329 330 for (var prop in result['message']['tags']) { 331 var tag = result['message']['tags'][prop]; 332 var isSelected = currentSelectedTag === prop ? 'selected="selected"' : ''; 333 fields += '<option value="' + prop + '" ' + isSelected + ' data-tag-description="' + tag.description + '">' + tag.name; 334 fields += '</option>'; 335 } 336 337 var fieldField = '<select data-placeholder="' + pinpointe_label_select_mailing_tag + '" id="pinpointe_forms_tag_field_' + current_field_id + '_' + i + '" name="pinpointe_options[forms][' + current_field_id + '][tag_field][]" class="pinpointe-field pinpointe_forms_mailing_tag" data-current-mail-list="' + current_field_id + '_' + i + '">' + fields + '</select>'; 338 339 mailing_list_html += '<tr class="pinpointe_fields_table" id="pinpointe_mailing_list_' + current_field_id + '_' + i + '"><td>' + fieldField + '</td><td style="font-size: 12px !important; word-wrap: break-word;"><p id="selected_name_' + current_field_id + '_' + i + '"></p><p style="margin-top: -6px; font-size: 10px; color: #7d7e80" id="selected_description_' + current_field_id + '_' + i + '"></p></td><td><button type="button" class="pinpointe_remove_mailing_list" data-row-id="'+ current_field_id +'_'+ i +'"><i class="fa fa-times"></i></button></td></tr>'; 340 341 // Wrap the loop in a fn to create scope for `i` and for the setTimeout is because we are dynamiccally adding html 342 (function (i, currentElementId) { 343 344 setTimeout(function () { 345 var current_id = currentElementId.replace("pinpointe_forms_tag_", ""); 346 347 var select = jQuery('#pinpointe_forms_tag_field_' + current_id + '_' + i); 348 349 jQuery('#selected_name_' + current_id + '_' + i).text(select.find('option:selected').text()); 350 jQuery('#selected_description_' + current_id + '_' + i).text(select.find('option:selected').data('tag-description')); 351 }, 200); 352 })(i, jQuery(this).prop("id")); 353 354 } 355 } else { 356 357 var fields = '<option value=""> </option>'; // SDL 358 359 for (var prop in result['message']['tags']) { 360 var tag = result['message']['tags'][prop]; 361 fields += '<option value="' + prop + '" data-tag-description="' + tag.description +'">' + tag.name; 362 fields += '</option>'; 363 } 364 365 var field_field = '<select data-placeholder="' + pinpointe_label_select_mailing_tag + '" id="pinpointe_forms_tag_field_' + current_field_id + '_' + current_mailing_list_id + '" name="pinpointe_options[forms][' + current_field_id + '][tag_field][]" class="pinpointe-field pinpointe_forms_mailing_tag" data-current-mail-list="' + current_field_id + '_' + current_mailing_list_id +'">' + fields + '</select>'; 366 367 mailing_list_html += '<tr class="pinpointe_fields_table" id="pinpointe_mailing_list_' + current_field_id + '_' + current_mailing_list_id + '"><td>' + field_field + '</td><td style="font-size: 12px !important; word-wrap: break-word;"><p id="selected_name_' + current_field_id + '_' + current_mailing_list_id + '"></p><p style="margin-top: -6px; font-size: 10px; color: #7d7e80" id="selected_description_' + current_field_id + '_' + current_mailing_list_id + '"></p></td><td><button type="button" class="pinpointe_remove_mailing_list"><i class="fa fa-times"></i></button></td></tr>'; 227 368 } 228 369 229 var field_field = '<select id="pinpointe_forms_tag_field_' + current_field_id + '" name="pinpointe_options[forms][' + current_field_id + '][tag_field]" class="pinpointe-field pinpointe_forms_mailing_tag">' + fields + '</select>'; 230 var field_html = '<table class="form-table" style="margin-bottom: 0px;"><tbody><tr valign="top"><th scope="row">' + pinpointe_label_mailing_tag + '</th><td>' + field_field + '</td></tr></tbody></table>'; 231 232 jQuery(this).replaceWith(field_html); 233 234 // Make it chosen! 235 jQuery('#pinpointe_forms_tag_field_' + current_field_id).chosen({ 236 no_results_text: pinpointe_label_no_results_match_tag, 237 placeholder_text_single: pinpointe_label_select_mailing_tag, 238 width: '400px' 370 // End table 371 mailing_list_html += '</tbody><tfoot><tr><td><button type="button" name="pinpointe_add_mailing_list" id="pinpointe_add_mailing_list" class="button button-primary" data-row-id="' + current_field_id + '_' + current_mailing_list_id +'" value="' + pinpointe_label_add_new_mailing_list + '"><i class="fa fa-plus"> ' + pinpointe_label_add_new_mailing_list + '</i></button></td><td></td><td></td><td></td></tr></tfoot></table></div>'; 372 373 jQuery(this).replaceWith(mailing_list_html); 374 375 // Make all select fields chosen 376 jQuery('.pinpointe-field.pinpointe_forms_mailing_tag').each(function () { 377 var selectElement = jQuery(this); 378 379 selectElement.chosen({ 380 no_results_text: pinpointe_label_no_results_match_tag, 381 width: '366px' 382 }).change(function (evt, params) { 383 // Find corresponding <p> tags based on the data-current-mail-list attribute 384 var currentMailList = selectElement.data('current-mail-list'); 385 jQuery('#selected_name_' + currentMailList).text(selectElement.find('option:selected').text()); 386 jQuery('#selected_description_' + currentMailList).text(selectElement.find('option:selected').data('tag-description')); 387 }); 239 388 }); 240 241 } 242 389 } 243 390 pinpointe_forms_page_hints(); 244 391 … … 347 494 }); 348 495 } 496 /** 497 * Disable the selcted options in all selects in a form 498 * 499 */ 500 function hide_selected_options() { 501 jQuery('.pinpointe-field.pinpointe_forms_mailing_tag').each(function (index) { 502 var prevSelect = jQuery(this); 503 504 for (var i = 0; i < selected_options.length; i++) { 505 var optionValue = selected_options[i]; 506 var optionToDisable = prevSelect.find('option[value="' + optionValue + '"]'); 507 508 if (optionToDisable.length) { 509 optionToDisable.hide(); 510 } 511 } 512 }); 513 } 514 515 /** 516 * Enable option for the deleted select 517 */ 518 function show_deleted_option(selected_value) { 519 jQuery('.pinpointe-field.pinpointe_forms_mailing_tag').each(function (index) { 520 var optionToEnable = jQuery(this).find('option[value="' + selected_value + '"]'); 521 522 if (optionToEnable.length) { 523 optionToEnable.show(); 524 525 const indexToRemove = selected_options.indexOf(selected_value); 526 527 // Remove the element at the specified index 528 selected_options.splice(indexToRemove, 1); 529 } 530 }); 531 } 532 533 jQuery(document).on('click', '#pinpointe_add_mailing_list', function () { 534 535 // Get the current mailing list table 536 var mailingListTable = jQuery(this).parent().parent().parent().parent(); 537 538 var current_id = parseInt(mailingListTable.attr('id').split('_').pop(), 10); 539 540 // Get the last row ID 541 var last_mailing_list = parseInt(mailingListTable.find('tbody>tr:last').attr('id').split('_').pop(), 10); 542 543 var last_select = jQuery('#pinpointe_forms_tag_field_' + current_id + '_' + last_mailing_list); 544 545 var last_selected_value = last_select.find('option:selected').val(); 546 if (last_selected_value === '') { 547 return; 548 } 549 if (!selected_options.includes(last_selected_value)) { 550 selected_options.push(last_selected_value); 551 } 552 553 hide_selected_options('#pinpointe_forms_tag_field_' + current_id + '_' + last_mailing_list); 554 555 last_select.chosen('destroy'); 556 557 var next_id = last_mailing_list + 1; 558 559 // Clone the last row and insert after the last one 560 var newRow = mailingListTable.find('tbody>tr:last').clone(true); 561 newRow.attr('id', 'pinpointe_mailing_list_' + current_id + '_' + next_id); 562 563 // Update IDs and clear values as needed 564 newRow.find('select').val(''); 565 newRow.find('select').attr('id', 'pinpointe_forms_tag_field_' + current_id + '_' + next_id) 566 newRow.find('select').attr('data-current-mail-list', current_id + '_' + next_id); 567 568 newRow.find('#selected_name_' + current_id + '_' + last_mailing_list).attr('id', 'selected_name_' + current_id + '_' + next_id); 569 newRow.find('#selected_description_' + current_id + '_' + last_mailing_list).attr('id', 'selected_description_' + current_id + '_' + next_id); 570 571 newRow.find('.pinpointe_remove_mailing_list').attr('data-row-id', + current_id + '_' + next_id); 572 573 // Re-activate Chosen on the cloned select element 574 newRow.find('#pinpointe_forms_tag_field_' + current_id + '_' + next_id).chosen({ 575 no_results_text: pinpointe_label_no_results_match_tags, 576 placeholder_text_single: pinpointe_label_select_tag, 577 width: '366px' 578 }).change(function () { 579 var selectElement = jQuery('#pinpointe_forms_tag_field_' + current_id + '_' + next_id); 580 581 jQuery('#selected_name_' + current_id + '_' + next_id).text(selectElement.find('option:selected').text()); 582 jQuery('#selected_description_' + current_id + '_' + next_id).text(selectElement.find('option:selected').data('tag-description')); 583 }); 584 // Add the new row to the table 585 mailingListTable.find('tbody').append(newRow); 586 587 jQuery('#selected_name_' + current_id + '_' + next_id).text(''); 588 jQuery('#selected_description_' + current_id + '_' + next_id).text(''); 589 590 last_select.chosen(); 591 592 }); 593 594 // Listen for the click event on the remove mailing list button 595 jQuery(document).on('click', '.pinpointe_remove_mailing_list', function () { 596 var selectElement = jQuery(this).parent().parent().find('.pinpointe-field.pinpointe_forms_mailing_tag')[0]; 597 598 // check if its the last element. 599 if (jQuery(this).parent().parent().parent().children().length === 1) { 600 jQuery(this).parent().parent().find('.pinpointe-field.pinpointe_forms_mailing_tag').each(function() { 601 var row_id = jQuery(this).prop("id").replace("pinpointe_forms_tag_field_", ""); 602 603 jQuery(this).val(''); 604 jQuery(this).trigger('chosen:updated'); 605 jQuery('#selected_name_' + row_id).text(''); 606 jQuery('#selected_description_' + row_id).text(''); 607 608 show_deleted_option(jQuery(this).find('option:selected').val()); 609 }); 610 } 611 else { 612 jQuery(this).parent().parent().remove(); 613 } 614 615 show_deleted_option(jQuery(selectElement).find('option:selected').val()); 616 617 }); 618 619 349 620 350 621 /** … … 818 1089 jQuery('#pinpointe_forms_redirect_url_' + next_id).val(''); 819 1090 1091 //Change id and name of the following fields and clear their values, except for confirmation email which we will delete 1092 1093 // 1.Send confirmation email 1094 jQuery(this).find('#pinpointe_forms_send_confirmation_' + current_id).attr('id', 'pinpointe_forms_send_confirmation_' + next_id); 1095 jQuery('#pinpointe_forms_send_confirmation_' + next_id).attr('name', 'pinpointe_options[forms][' + next_id + '][send_confirmation]'); 1096 jQuery('#pinpointe_forms_send_confirmation_' + next_id).prop("checked", false); 1097 1098 1099 // 2.Override default confirmation email 1100 jQuery(this).find('#pinpointe_forms_overide_confirmation_' + current_id).attr('id', 'pinpointe_forms_overide_confirmation_' + next_id); 1101 jQuery('#pinpointe_forms_overide_confirmation_' + next_id).attr('name', 'pinpointe_options[forms][' + next_id + '][overide_confirmation]'); 1102 jQuery('#pinpointe_forms_overide_confirmation_' + next_id).prop("checked", false); 1103 1104 pinpointe_hide_confirmation_email_trs(jQuery('#pinpointe_forms_send_confirmation_' + next_id)); 1105 pinpointe_hide_confirmation_email_tr(jQuery('#pinpointe_forms_overide_confirmation_' + next_id)); 1106 1107 // 3.Confirmation email 1108 1109 //rename the td housing the email so that we can locate it 1110 jQuery(this).find('#forms_confirmation_email_td_' + current_id).attr('id', 'forms_confirmation_email_td_' + next_id); 1111 1112 //take the content from the last form 1113 var content = jQuery('#pinpointe_forms_html_confirmation_email_' + current_id).val(); 1114 1115 //remove the full email well the cloned one... 1116 jQuery(this).find('#wp-pinpointe_forms_html_confirmation_email_' + current_id + '-wrap').remove(); 1117 1118 // Create a new textarea element 1119 var newTextarea = jQuery('<textarea>'); 1120 1121 newTextarea.addClass('pinpointe-field pinpointe_forms_html_confirmation_email'); 1122 newTextarea.attr('name', 'pinpointe_options[forms][' + next_id + '][html_confirmation_email]'); 1123 newTextarea.attr('id', 'pinpointe_forms_html_confirmation_email_' + next_id); 1124 newTextarea.attr('rows', '25'); 1125 newTextarea.attr("style", "width:100%"); 1126 newTextarea.text(content); 1127 1128 // Append the new textarea element to the specified td element 1129 jQuery('#forms_confirmation_email_td_'+ next_id).append(newTextarea); 1130 1131 activate_editors(); 1132 1133 //reset the selected options with the selected tags from the new form 1134 selected_options = []; 1135 1136 let selectedTagsForNewForm = (typeof pinpointe_selected_tags[next_id] !== "undefined" && 1137 typeof pinpointe_selected_tags[next_id].tags !== "undefined") 1138 ? pinpointe_selected_tags[next_id].tags 1139 : null; 1140 1141 //preselect the save opts fro this 'new' form 1142 if (selectedTagsForNewForm && Array.isArray(selectedTagsForNewForm)) { 1143 for (let i = 0; i < selectedTagsForNewForm.length; i++) { 1144 let currentSelectedTag = selectedTagsForNewForm[i - 1]; 1145 selected_options.push(currentSelectedTag); 1146 } 1147 } 1148 820 1149 // Change ids and names of mailing list and groups fields 1150 //id="pinpointe_mailing_list_table_' + current_id + '_' + current_mailing_list_id + '" 1151 jQuery(this).find('#pinpointe_mailing_list_table_' + current_id).attr('id', 'pinpointe_mailing_list_table_' + next_id); 1152 jQuery('#pinpointe_mailing_list_table_' + next_id + ' tbody tr:not(:first-child)').remove(); 1153 1154 //pinpointe_forms_tag_field_1_1_chosen 1155 jQuery(this).find('.chosen-single span').text(""); 1156 1157 var trElement = jQuery(this).find('#pinpointe_mailing_list_table_' + next_id + ' tbody tr:first-child'); 1158 trElement.attr('id', 'pinpointe_mailing_list_' + next_id + '_1'); 1159 1160 var selectElement = trElement.find('td select.pinpointe_forms_mailing_tag'); 1161 1162 // Destroy the chosen instance before making changes (this must happen this way) 1163 selectElement.chosen('destroy'); 1164 1165 // hide the select and force select the empty opt so that chosen can take over 1166 selectElement.find('option:selected').prop('selected', false); 1167 selectElement.css('display', 'none'); 1168 selectElement.find('option[value=""]').attr('selected', true); 1169 1170 // force clear the prevous opt from the old form 1171 trElement.find('td div#pinpointe_forms_tag_field_'+ current_id +'_1_chosen.chosen-container.chosen-container-single a.chosen-single span').text(''); 1172 1173 // update attrs 1174 selectElement.val(''); 1175 selectElement.attr('id', 'pinpointe_forms_tag_field_' + next_id + '_1'); 1176 selectElement.attr('name', 'pinpointe_options[forms][' + next_id + '][tag_field][]'); 1177 selectElement.attr('data-current-mail-list', next_id + '_1'); 1178 1179 // Reinitialize chosen after updating attributes 1180 selectElement.chosen({ 1181 no_results_text: pinpointe_label_no_results_match_tag, 1182 width: '366px' 1183 }).change(function (evt, params) { 1184 var selectElement = jQuery('#pinpointe_forms_tag_field_' + next_id + '_1'); 1185 1186 jQuery('#selected_name_' + next_id + '_1').text(selectElement.find('option:selected').text()); 1187 jQuery('#selected_description_' + next_id + '_1').text(selectElement.find('option:selected').data('tag-description')); 1188 }); 1189 1190 // Now, we can find the p elements inside the first tr and update their attributes 1191 var nameParagraph = trElement.find('p[id^="selected_name_"]'); 1192 var descriptionParagraph = trElement.find('p[id^="selected_description_"]'); 1193 1194 // Update attributes for name paragraph & clear the text so that we can start afresh again 1195 nameParagraph.attr('id', 'selected_name_' + next_id + '_1'); 1196 descriptionParagraph.attr('id', 'selected_description_' + next_id + '_1'); 1197 1198 nameParagraph.text(''); 1199 descriptionParagraph.text(''); 1200 1201 // Update the data-row-id attribute for the button in the last td 1202 var removeButton = trElement.find('td button.pinpointe_remove_mailing_list'); 1203 removeButton.attr('data-row-id', next_id + '_1'); 1204 821 1205 jQuery(this).find('#pinpointe_forms_list_field_' + current_id).attr('id', 'pinpointe_forms_list_field_' + next_id); 822 1206 jQuery('#pinpointe_forms_list_field_' + next_id).attr('name', 'pinpointe_options[forms][' + next_id + '][list_field]'); … … 1096 1480 if(jQuery(this).find('option[value="email"]:selected').length != 1) { 1097 1481 enabled = false; 1482 } else { 1483 enabled = true; 1098 1484 } 1099 1485 -
pinpointe-form-integration/trunk/includes/pinpointe-form.inc.php
r1340221 r3065401 8 8 function pinpointe_form($allowed_forms = array()) 9 9 { 10 $opt = get_option('pinpointe_options', $results );10 $opt = get_option('pinpointe_options', $results = false); 11 11 12 12 // Check if integration is enabled … … 26 26 $html = pinpointe_prepare_form($form, $opt, 'shortcode'); 27 27 28 echo $html;28 echo esc_html($html); 29 29 } 30 30 } -
pinpointe-form-integration/trunk/includes/pinpointe-plugin-structure.inc.php
r2093592 r3065401 31 31 'empty' => true, 32 32 ), 33 'hint' => __('<p>Enter the URL to the Pinpointe XML API that was provided to you.</p>', 'pinpointe'),33 'hint' => esc_html__('<p>Enter the URL to the Pinpointe XML API that was provided to you.</p>', 'pinpointe'), 34 34 ), 35 35 … … 42 42 'empty' => true, 43 43 ), 44 'hint' => __('<p>Enter your Pinpointe username.</p>', 'pinpointe'),44 'hint' => esc_html__('<p>Enter your Pinpointe username.</p>', 'pinpointe'), 45 45 ), 46 46 … … 53 53 'empty' => true, 54 54 ), 55 'hint' => __('<p>API key is required for this plugin to communicate with the Pinpointe servers.</p> <p>To get an API key, send an email to <a href=\'mailto:[email protected]\'>[email protected]</a>.</p>', 'pinpointe'),55 'hint' => esc_html__('<p>API key is required for this plugin to communicate with the Pinpointe servers.</p> <p>To get an API key, send an email to <a href=\'mailto:[email protected]\'>[email protected]</a>.</p>', 'pinpointe'), 56 56 ), 57 57 ), … … 68 68 'empty' => false 69 69 ), 70 'hint' => __('<p>Controls whether a double opt-in confirmation message is sent before user is actually subscribed.</p>', 'pinpointe'),70 'hint' => esc_html__('<p>Controls whether a double opt-in confirmation message is sent before user is actually subscribed.</p>', 'pinpointe'), 71 71 ), 72 72 'send_welcome' => array( … … 78 78 'empty' => false 79 79 ), 80 'hint' => __('<p>If double opt-in is disabled and this setting is enabled, MailChimp will send your lists Welcome Email on user subscription. This has no effect if double opt-in is enabled.</p>', 'pinpointe'),80 'hint' => esc_html__('<p>If double opt-in is disabled and this setting is enabled, MailChimp will send your lists Welcome Email on user subscription. This has no effect if double opt-in is enabled.</p>', 'pinpointe'), 81 81 ), 82 82 'replace_groups' => array( … … 88 88 'empty' => false 89 89 ), 90 'hint' => __('<p>Setting is used by MailChimp to determine whether interest groups are added to a set of existing interest groups of particular user or they are completely replaced with new interest groups. This is applicable when user is already subscribed to the list and profile is being updated.</p>', 'pinpointe'),90 'hint' => esc_html__('<p>Setting is used by MailChimp to determine whether interest groups are added to a set of existing interest groups of particular user or they are completely replaced with new interest groups. This is applicable when user is already subscribed to the list and profile is being updated.</p>', 'pinpointe'), 91 91 ),*/ 92 92 'add_to_autoresponders' => array( … … 98 98 'empty' => false 99 99 ), 100 'hint' => __('<p>Control whether newly subscribed members will be added to autoresponders.</p>', 'pinpointe'),100 'hint' => esc_html__('<p>Control whether newly subscribed members will be added to autoresponders.</p>', 'pinpointe'), 101 101 ), 102 102 'update_existing' => array( … … 108 108 'empty' => false 109 109 ), 110 'hint' => __('<p>Control whether existing subscribers are updated when they fill out the signup form again or error is displayed. This has no effect for Sync functionality.</p>', 'pinpointe'),110 'hint' => esc_html__('<p>Control whether existing subscribers are updated when they fill out the signup form again or error is displayed. This has no effect for Sync functionality.</p>', 'pinpointe'), 111 111 ), 112 112 ), … … 123 123 'empty' => false 124 124 ), 125 'hint' => __('<p>Controls whether signup form field labels are displayed inside fields as value placeholders (inline) or above fields.</p>', 'pinpointe'),125 'hint' => esc_html__('<p>Controls whether signup form field labels are displayed inside fields as value placeholders (inline) or above fields.</p>', 'pinpointe'), 126 126 ), 127 127 /*'groups_hidden' => array( … … 133 133 'empty' => false 134 134 ), 135 'hint' => __('<p>Interest groups can take significant amount of space. If this option is enabled, interest group fields will be hidden until user starts filling in the form (clicks anywhere on the form).</p>', 'pinpointe'),135 'hint' => esc_html__('<p>Interest groups can take significant amount of space. If this option is enabled, interest group fields will be hidden until user starts filling in the form (clicks anywhere on the form).</p>', 'pinpointe'), 136 136 ),*/ 137 137 'width_limit' => array( … … 143 143 'empty' => true, 144 144 ), 145 'hint' => __('<p>If your website features a wide layout, you may wish to set the max width for the form to look better. This has no effect for forms displayed as popup.</p>', 'pinpointe'),145 'hint' => esc_html__('<p>If your website features a wide layout, you may wish to set the max width for the form to look better. This has no effect for forms displayed as popup.</p>', 'pinpointe'), 146 146 ), 147 147 'css_override' => array( … … 153 153 'empty' => true 154 154 ), 155 'hint' => __('<p>You can further customize the appearance of your signup forms by adding custom CSS to this field. To make changes to the style, simply use CSS class pinpointe_custom_css as a basis.</p>', 'pinpointe'),155 'hint' => esc_html__('<p>You can further customize the appearance of your signup forms by adding custom CSS to this field. To make changes to the style, simply use CSS class pinpointe_custom_css as a basis.</p>', 'pinpointe'), 156 156 ), 157 157 ), … … 185 185 'empty' => false 186 186 ), 187 'hint' => __('<p>Displays popup with mailing database signup form as configured. You can use form conditions for more granual control.</p>', 'pinpointe'),187 'hint' => esc_html__('<p>Displays popup with mailing database signup form as configured. You can use form conditions for more granual control.</p>', 'pinpointe'), 188 188 ), 189 189 'popup_form' => array( … … 196 196 ), 197 197 'values' => PinpointeSignupForm::get_list_of_forms(), 198 'hint' => __('<p>Select one of the forms created under tab Forms to display as a popup.</p>', 'pinpointe'),198 'hint' => esc_html__('<p>Select one of the forms created under tab Forms to display as a popup.</p>', 'pinpointe'), 199 199 ), 200 200 'popup_delay' => array( … … 206 206 'empty' => true, 207 207 ), 208 'hint' => __('<p>If set, form will be opened after a specified number of seconds counting from the complete page load.</p>', 'pinpointe'),208 'hint' => esc_html__('<p>If set, form will be opened after a specified number of seconds counting from the complete page load.</p>', 'pinpointe'), 209 209 ), 210 210 'popup_display_on' => array( … … 222 222 '4' => __('Everywhere else', 'pinpointe'), 223 223 ), 224 'hint' => __('<p>Page types where you want the popup to be fired.</p>', 'pinpointe'), 224 'hint' => esc_html__('<p>Page types where you want the popup to be fired.</p>', 225 'pinpointe'), 225 226 ), 226 227 ), … … 237 238 'empty' => true, 238 239 ), 239 'hint' => __('<p>Popup will be displayed once in every X pages opened. Leaving blank or setting value to 1 will have the same effect.</p>', 'pinpointe'),240 'hint' => esc_html__('<p>Popup will be displayed once in every X pages opened. Leaving blank or setting value to 1 will have the same effect.</p>', 'pinpointe'), 240 241 ), 241 242 'popup_time_limit' => array( … … 247 248 'empty' => true, 248 249 ), 249 'hint' => __('<p>Popup will be displayed once in every X minutes.</p>', 'pinpointe'), 250 'hint' => esc_html__('<p>Popup will be displayed once in every X minutes.</p>', 251 'pinpointe'), 250 252 ), 251 253 'popup_allow_dismissing' => array( … … 257 259 'empty' => false 258 260 ), 259 'hint' => __('<p>If enabled, users will be provided with an option (a link to click) to hide the popup forever without filling in the form.</p>', 'pinpointe'),261 'hint' => esc_html__('<p>If enabled, users will be provided with an option (a link to click) to hide the popup forever without filling in the form.</p>', 'pinpointe'), 260 262 ), 261 263 'label_dismiss_popup' => array( … … 267 269 'empty' => true 268 270 ), 269 'hint' => __('<p>If popup dismissing is enabled, this will be the text of the dismiss link.</p>', 'pinpointe'),271 'hint' => esc_html__('<p>If popup dismissing is enabled, this will be the text of the dismiss link.</p>', 'pinpointe'), 270 272 ), 271 273 ), … … 292 294 '2' => __('Pages', 'pinpointe'), 293 295 ), 294 'hint' => __('<p>Page types where you want the form to be displayed below the main content. You can use form conditions for more granular control.</p>', 'pinpointe'),296 'hint' => esc_html__('<p>Page types where you want the form to be displayed below the main content. You can use form conditions for more granular control.</p>', 'pinpointe'), 295 297 ), 296 298 'after_posts_allowed_forms' => array( … … 303 305 ), 304 306 'values' => PinpointeSignupForm::get_list_of_forms(false), 305 'hint' => __('<p>If a list of form IDs is specified, only those forms will be eligible to be displayed. The forms will be filtered based on their display conditions, then the first remaining form will be displayed.</p>', 'pinpointe'),307 'hint' => esc_html__('<p>If a list of form IDs is specified, only those forms will be eligible to be displayed. The forms will be filtered based on their display conditions, then the first remaining form will be displayed.</p>', 'pinpointe'), 306 308 ), 307 309 ), … … 324 326 'empty' => false 325 327 ), 326 'hint' => __('<p>If enabled, posts or pages that match form display conditions will be locked. Only subscribers will be able to access that content. This functionality uses cookies for tracking. If subscriber clears browser cookies, content will be locked again.</p> <p>Use form conditions to control which pages will be locked.</p>', 'pinpointe'),328 'hint' => esc_html__('<p>If enabled, posts or pages that match form display conditions will be locked. Only subscribers will be able to access that content. This functionality uses cookies for tracking. If subscriber clears browser cookies, content will be locked again.</p> <p>Use form conditions to control which pages will be locked.</p>', 'pinpointe'), 327 329 ), 328 330 'lock_form' => array( … … 335 337 ), 336 338 'values' => PinpointeSignupForm::get_list_of_forms(), 337 'hint' => __('<p>Select one of the forms created under tab Forms to display instead of locked content.</p>', 'pinpointe'),339 'hint' => esc_html__('<p>Select one of the forms created under tab Forms to display instead of locked content.</p>', 'pinpointe'), 338 340 ), 339 341 'lock_title' => array( … … 345 347 'empty' => true 346 348 ), 347 'hint' => __('<p>Title to display above signup form.</p>', 'pinpointe'),349 'hint' => esc_html__('<p>Title to display above signup form.</p>', 'pinpointe'), 348 350 ), 349 351 'lock_message' => array( … … 355 357 'empty' => true 356 358 ), 357 'hint' => __('<p>Message to display above signup form.</p>', 'pinpointe'),359 'hint' => esc_html__('<p>Message to display above signup form.</p>', 'pinpointe'), 358 360 ), 359 361 ), … … 380 382 '2' => __('Comments Form', 'pinpointe'), 381 383 ), 382 'hint' => __('<p>Select WordPress forms where you would like mailing database opt-in checkbox to appear.</p>', 'pinpointe'),384 'hint' => esc_html__('<p>Select WordPress forms where you would like mailing database opt-in checkbox to appear.</p>', 'pinpointe'), 383 385 ), 384 386 'checkbox_label' => array( … … 390 392 'empty' => true 391 393 ), 392 'hint' => __('<p>Label to display next to the checkbox.</p>', 'pinpointe'),394 'hint' => esc_html__('<p>Label to display next to the checkbox.</p>', 'pinpointe'), 393 395 ), 394 396 'checkbox_state' => array( … … 404 406 '1' => __('Checked', 'pinpointe'), 405 407 ), 406 'hint' => __('<p>Default checkbox state.</p>', 'pinpointe'),408 'hint' => esc_html__('<p>Default checkbox state.</p>', 'pinpointe'), 407 409 ), 408 410 'checkbox_list' => array( … … 414 416 'empty' => true 415 417 ), 416 'hint' => __('<p>Select one of your Pinpointe mailing databases to subscribe visitors to.</p>', 'pinpointe'),418 'hint' => esc_html__('<p>Select one of your Pinpointe mailing databases to subscribe visitors to.</p>', 'pinpointe'), 417 419 ), 418 420 ), … … 436 438 ), 437 439 'values' => PinpointeSignupForm::get_all_user_roles(), 438 'hint' => __('<p>Select user roles that you would like to synchronize with Pinpointe.</p> <p>This feature sends data to Pinpointe when one of the following actions occur - user is created, user is updated and user is deleted.</p>', 'pinpointe'),440 'hint' => esc_html__('<p>Select user roles that you would like to synchronize with Pinpointe.</p> <p>This feature sends data to Pinpointe when one of the following actions occur - user is created, user is updated and user is deleted.</p>', 'pinpointe'), 439 441 ), 440 442 'sync_list' => array( … … 446 448 'empty' => true 447 449 ), 448 'hint' => __('<p>Select one of your Pinpointe mailing databases to sync user data with.</p>', 'pinpointe'),450 'hint' => esc_html__('<p>Select one of your Pinpointe mailing databases to sync user data with.</p>', 'pinpointe'), 449 451 ), 450 452 ), -
pinpointe-form-integration/trunk/includes/pinpointe-prepare-form.inc.php
r1558838 r3065401 17 17 $global_form_id = $pinpointe->get_next_rendered_form_id(); 18 18 19 //get mailing lists 20 $mailing_lists = $pinpointe->get_tag_metadata(); 21 22 $mailing_list_settings = []; 23 19 24 // Extract form id and form settings 20 25 reset($form); … … 22 27 $form = array_pop($form); 23 28 29 //loop over to check if show_mailing_lists is on & form_id is same as global_for_id 30 foreach ($mailing_lists as $mailing_list) { 31 if ($mailing_list['form_id'] === $form_key && $mailing_list['show_mailing_list'] === 'on') { 32 $mailing_list_settings = json_decode($mailing_list['tags'], true); 33 } 34 } 35 24 36 // Title 25 37 $title = ($context == 'widget') ? apply_filters('widget_title', $form['title']) : $form['title']; … … 415 427 } 416 428 429 //Mailing list settings 430 if (!empty($mailing_list_settings)) { 431 $html .= "<p class='label'>Please select the mailing list(s) you would like to receive updates from.</p>"; 432 433 foreach ($mailing_list_settings as $tag_id => $tag) { 434 $input_id = "pinpointe_tags_" . $context . "_" . $tag_id; 435 $input_name = "pinpointe_".$context .'_subscribe[custom][selected_tags][]'; 436 437 $html .= '<label for="'.$input_id .'" style="width: 100%;display: flex; justify-content: space-between;align-items: center; margin-bottom: 5px; width: 100%;">'; 438 $html .= '<input type="checkbox" id="'.$input_id .'" name="'.$input_name.'" value="' . $tag_id . '" style="margin-right: 5px;" checked>'; 439 $html .= '<div style="flex: 1; text-align: left;">'; 440 $html .= '<div style="font-weight: bold; font-size: smaller;">' . $tag['name'] . '</div>'; 441 $html .= '<div style="font-size: x-small; color: #777;">' . (empty($tag['description']) ? 'No description' : $tag['description']) . '</div>'; 442 $html .= '</div>'; 443 $html .= '</label>'; 444 } 445 } 446 417 447 // Text below form 418 448 if (isset($form['below']) && $form['below'] != '') { -
pinpointe-form-integration/trunk/includes/pinpointe-service.class.php
r2547924 r3065401 95 95 ); 96 96 97 $xml = $this->arrayToXml($request, '<xmlrequest />');98 99 // We have to use DOMDocument now to prevent self closing XML tags since the100 // Pinpointe API doesn't accept them.101 $dom_sxe = dom_import_simplexml($xml);102 103 $dom_output = new DOMDocument('1.0');104 $dom_output->formatOutput = true;105 $dom_sxe = $dom_output->importNode($dom_sxe, true);106 $dom_sxe = $dom_output->appendChild($dom_sxe);107 108 $xmlStr = $dom_output->saveXML($dom_output, LIBXML_NOEMPTYTAG);109 110 $file = WP_PLUGIN_DIR."/pinpointe-form-integration/test.xml";111 $dom_output->save($file);112 113 97 curl_setopt($this->curl, CURLOPT_URL, $this->apiUrl); 114 curl_setopt($this->curl, CURLOPT_HTTPHEADER, array('Content-Type: application/xml')); 115 curl_setopt($this->curl, CURLOPT_POSTFIELDS, $xmlStr); 116 98 $is_json = true; 99 if(strpos($this->apiUrl, 'json') === false){ 100 $is_json = false; 101 $xml = $this->arrayToXml($request, '<xmlrequest />'); 102 // We have to use DOMDocument now to prevent self closing XML tags since the 103 // Pinpointe API doesn't accept them. 104 $dom_sxe = dom_import_simplexml($xml); 105 106 $dom_output = new DOMDocument('1.0'); 107 $dom_output->formatOutput = true; 108 $dom_sxe = $dom_output->importNode($dom_sxe, true); 109 $dom_sxe = $dom_output->appendChild($dom_sxe); 110 111 $post_data = $dom_output->saveXML($dom_output, LIBXML_NOEMPTYTAG); 112 113 $file = WP_PLUGIN_DIR."/pinpointe-form-integration/test.xml"; 114 $dom_output->save($file); 115 116 curl_setopt($this->curl, CURLOPT_HTTPHEADER, array('Content-Type: application/xml')); 117 } else { 118 $post_data = json_encode($request); 119 curl_setopt($this->curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); 120 } 121 122 curl_setopt($this->curl, CURLOPT_POSTFIELDS, $post_data); 117 123 $responseBody = @curl_exec($this->curl); 118 124 … … 121 127 } 122 128 123 $responseXml = simplexml_load_string($responseBody); 124 125 if ($responseXml->status == 'SUCCESS') { 126 if($data['id'] == '-999') return true; 127 return $this->xmlToArray($responseXml->data); 129 $response = $is_json ? json_decode($responseBody) : simplexml_load_string($responseBody); 130 131 if ($response->status == 'SUCCESS') { 132 if (isset($data['id']) && $data['id'] == '-999') { 133 return true; 134 } 135 return $this->xmlToArray($response->data); 128 136 } 129 137 else { … … 148 156 if (is_array($value)) { 149 157 if ($key != 'value') { 150 $child = $root->addChild($key); 151 152 $this->arrayToXml($value, $child); 158 if ($key == 'tags') { 159 foreach ($value as $tag) { 160 $child = $root->addChild('tag', $tag); 161 } 162 } else { 163 $child = $root->addChild($key); 164 $this->arrayToXml($value, $child); 165 } 153 166 } else { 154 167 foreach ($value as $k => $v) { … … 237 250 238 251 foreach($id as $i) { 239 $mergeVarForList = $this->call('lists', 'GetCustomFields', [ 240 'listids' => $i 241 ])['item']; 252 $response = $this->call('lists', 'GetCustomFields', ['listids' => $i]); 253 254 // for xml item exists, for json item doesnot exist 255 $mergeVarForList = isset($response['item']) ? $response['item']: $response; 242 256 243 257 $mergeVars = [ … … 250 264 251 265 foreach($mergeVarForList as $mergeVar) { 252 $settings = $this->mb_unserialize($mergeVar['fieldsettings']); 266 $settings = $mergeVar['fieldsettings']; 267 268 // Check if $settings is a serialized string, and unserialize if needed 269 if (is_string($settings) && ($unserialized = $this->mb_unserialize($settings)) !== false) { 270 $settings = $unserialized; 271 } 253 272 254 273 $mergeVars[$mergeVar['fieldid']] = [ … … 260 279 if($mergeVar['fieldtype'] == 'dropdown' || $mergeVar['fieldtype'] == 'checkbox' || $mergeVar['fieldtype'] == 'radiobutton') { 261 280 $choices = []; 262 foreach($settings['Key'] as $index => $key) { 263 $choices[$key] = $settings['Value'][$index]; 281 if (isset($settings['fieldsettings']) && is_array($settings['fieldsettings'])) { 282 foreach ($settings['fieldsettings'] as $key => $value) { 283 $choices[$key] = $value; 284 } 264 285 } 265 286 … … 284 305 */ 285 306 function mb_unserialize($string) { 286 $string = preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $string); 307 if (is_array($string)) { 308 return $string; 309 } 310 if (@unserialize($string) === false) { 311 return $string; 312 } 313 314 $string = preg_replace_callback( 315 '/s:(\d+):"(.*?)";/', 316 function ($matches) { 317 return 's:' . strlen($matches[2]) . ':"' . $matches[2] . '";'; 318 }, 319 $string 320 ); 321 287 322 return unserialize($string); 288 323 } … … 298 333 */ 299 334 public function lists_subscribe($id, $email, $merge_vars = array(), $email_type = 'html', 300 $add_to_autoresponders = false, $update_existing = false, $tag id, $send_confirmation) {335 $add_to_autoresponders = false, $update_existing = false, $tag_ids, $send_confirmation = false, $custom_data = []) { 301 336 if(!is_string($email)) { 302 337 $email = $email['email']; … … 310 345 ); 311 346 312 if (!empty($tag id))313 $data['tag '] = $tagid;347 if (!empty($tag_ids)) 348 $data['tags'] = $tag_ids; 314 349 315 350 if ($send_confirmation) { 316 351 $data['confirmed'] = 'no'; 317 352 $data['send_confirmation'] = 'true'; 353 } 354 355 if(!empty($custom_data['html_confirmation_email'])){ 356 $data['html_confirmation_email'] = $custom_data['html_confirmation_email']; 318 357 } 319 358 -
pinpointe-form-integration/trunk/includes/pinpointe-widget.class.php
r1340221 r3065401 11 11 class Pinpointe_Widget extends WP_Widget 12 12 { 13 public $opt; 14 public $settings; 15 13 16 /** 14 17 * Widget constructor (registering widget with WP) … … 89 92 $form_html = pinpointe_prepare_form($form, $this->opt, 'widget', $args); 90 93 91 echo $form_html;94 echo wp_kses_post($form_html); 92 95 } 93 96 … … 107 110 108 111 <p> 109 <?php printf( __('This widget renders a Pinpointe signup form.<br />You can edit signup forms <a href="%s">here</a>.', 'pinpointe'), site_url('/wp-admin/admin.php?page=pinpointe')); ?>112 <?php printf(esc_html__('This widget renders a Pinpointe signup form.<br />You can edit signup forms <a href="%s">here</a>.', 'pinpointe'), esc_url(site_url('/wp-admin/admin.php?page=pinpointe'))); ?> 110 113 </p> 111 114 <p> 112 <label for="<?php echo $this->get_field_id('allowed_forms'); ?>"><?php_e('Allow only these forms (comma-separated IDs):', 'pinpointe'); ?></label>113 <input class="widefat" id="<?php echo $this->get_field_id('allowed_forms'); ?>" name="<?php echo $this->get_field_name('allowed_forms'); ?>" type="text" value="<?php echo esc_attr($allowed_forms); ?>" />115 <label for="<?php echo esc_attr($this->get_field_id('allowed_forms')); ?>"><?php esc_html_e('Allow only these forms (comma-separated IDs):', 'pinpointe'); ?></label> 116 <input class="widefat" id="<?php echo esc_attr($this->get_field_id('allowed_forms')); ?>" name="<?php echo esc_attr($this->get_field_name('allowed_forms')); ?>" type="text" value="<?php echo esc_attr($allowed_forms); ?>" /> 114 117 </p> 115 118 … … 130 133 131 134 // Get allowed forms 132 $instance['allowed_forms'] = (!empty($new_instance['allowed_forms'])) ? strip_tags($new_instance['allowed_forms']) : '';135 $instance['allowed_forms'] = (!empty($new_instance['allowed_forms'])) ? wp_strip_all_tags($new_instance['allowed_forms']) : ''; 133 136 134 137 if ($instance['allowed_forms'] != '' && preg_match('/^([0-9]+,?)+$/', $instance['allowed_forms'])) { -
pinpointe-form-integration/trunk/pinpointe-signup-form.php
r2547924 r3065401 5 5 * Plugin URI: https://help.pinpointe.com/support/solutions/articles/5000664320-wordpress-plugin-download 6 6 * Description: Add Pinpointe forms to your WordPress site 7 * Version: 1. 57 * Version: 1.6 8 8 * Author: Pinpointe 9 9 * Author URI: http://www.pinpointe.com/ 10 10 * Requires at least: 3.5 11 * Tested up to: 5.7.211 * Tested up to: 6.4.2 12 12 * 13 13 * Text Domain: pinpointe … … 27 27 define('PINPOINTE_PLUGIN_PATH', untrailingslashit(plugin_dir_path(__FILE__))); 28 28 define('PINPOINTE_PLUGIN_URL', plugins_url(basename(plugin_dir_path(__FILE__)), basename(__FILE__))); 29 define('PINPOINTE_VERSION', '2.2. 0'); // Increment this to force cached JS to reload29 define('PINPOINTE_VERSION', '2.2.1'); // Increment this to force cached JS to reload 30 30 31 31 if (!class_exists('PinpointeSignupForm')) { … … 43 43 private $popup_page_capping_in_effect = false; 44 44 45 46 //define dynamically assigned vars 47 public $settings; 48 public $hints; 49 public $validation; 50 public $titles; 51 public $options; 52 public $section_info; 53 public $default_tabs; 54 public $opt; 55 public $pinpointe; 56 45 57 /** 46 58 * Singleton control … … 88 100 89 101 // Load scripts/styles conditionally 90 if ( preg_match('/page=pinpointe/i', $_SERVER['QUERY_STRING']) && !preg_match('/page=pinpointe_lite/i', $_SERVER['QUERY_STRING'])) {102 if (isset($_SERVER['QUERY_STRING']) && preg_match('/page=pinpointe/i', $_SERVER['QUERY_STRING']) && !preg_match('/page=pinpointe_lite/i', $_SERVER['QUERY_STRING'])) { 91 103 add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts_and_styles')); 92 }104 } 93 105 } 94 106 … … 133 145 * For all 134 146 */ 135 add_action('widgets_init', create_function('', 'return register_widget("Pinpointe_Widget");')); 147 148 // Start session on init hook. 149 add_action('init',[$this,'init_session']); 150 151 add_action('widgets_init', function () { 152 return register_widget("Pinpointe_Widget"); 153 }); 154 136 155 add_shortcode('pinpointe_form', array($this, 'subscription_shortcode')); 156 add_shortcode('pinpointe_powered_by', array($this, 'powered_by_shortcode')); 157 add_shortcode('pinpointe_email_sent_to', array($this, 'email_sent_to_shortcode')); 158 add_shortcode('pinpointe_confirm_link', array($this, 'confirm_link_shortcode')); 159 add_shortcode('pinpointe_confirm_link_href', array($this, 'confirm_link_href_shortcode')); 137 160 register_uninstall_hook(__FILE__, array('PinpointeSignupForm', 'uninstall')); 161 162 // validate the short codes before we do anything else 163 $this->validate_all_shortcodes(); 138 164 139 165 /** … … 150 176 add_action('wp_ajax_nopriv_pinpointe_subscribe', array($this, 'ajax_subscribe')); 151 177 178 } 179 function init_session() { 180 if (!session_id()) { 181 session_start(); 182 } 183 } 184 185 /** 186 * Validate all shortcodes and display warnings for missing ones. 187 * 188 * @return void 189 */ 190 public function validate_all_shortcodes() 191 { 192 /** 193 * Shortcodes to check for existence. 194 * 195 * @var string[] 196 */ 197 $shortcodes_to_check = array( 198 'pinpointe_form', 199 'pinpointe_powered_by', 200 'pinpointe_email_sent_to', 201 'pinpointe_confirm_link', 202 'pinpointe_confirm_link_href', 203 ); 204 205 foreach ($shortcodes_to_check as $shortcode){ 206 if (!shortcode_exists($shortcode)){ 207 $warning_message = sprintf( 208 __('Warning: Missing %s shortcode!', 'pinpointe'), 209 $shortcode 210 ); 211 212 add_action('admin_notices', function () use ($warning_message) { 213 echo '<div class="notice notice-error"><p>' . esc_html($warning_message) . '</p></div>'; 214 }); 215 } 216 } 152 217 } 153 218 … … 417 482 foreach ($page_value['children'] as $subpage => $subpage_value) { 418 483 $class = ($subpage == $current_tab) ? ' nav-tab-active' : ''; 419 echo '<a class="nav-tab'.$class.'" href="?page='.preg_replace('/_/', '-', $page).'&tab='.$subpage.'">'.((isset($subpage_value['icon']) && !empty($subpage_value['icon'])) ? $subpage_value['icon'] . ($subpage_value['title'] != '' ? ' ' : '') : '').$subpage_value['title'].'</a>'; 484 $href = "?page=" . preg_replace('/_/', '-', $page)."&tab=".$subpage; 485 $link_value = ((isset($subpage_value['icon']) && !empty($subpage_value['icon'])) 486 ? $subpage_value['icon'] . ($subpage_value['title'] != '' ? ' ' : '') 487 : '') .$subpage_value['title']; 488 echo '<a class="nav-tab'.esc_attr($class).'" href="'. esc_url($href).'">'.wp_kses_post($link_value) 489 .'</a>'; 420 490 } 421 491 } … … 497 567 <div class="pinpointe-left"> 498 568 <form method="post" action="options.php" enctype="multipart/form-data"> 499 <input type="hidden" name="current_tab" value="<?php echo $current_tab; ?>" />569 <input type="hidden" name="current_tab" value="<?php echo esc_attr($current_tab); ?>" /> 500 570 501 571 … … 507 577 508 578 if ($current_tab == 'forms') { 509 echo '<div style="width:100%;text-align:center;border-top:1px solid #dfdfdf;padding:18px;"><a href="' . admin_url('/options-general.php?page=pinpointe&tab=help') . '">' .__('How do I display my forms?', 'pinpointe') . '</a></div>';579 echo '<div style="width:100%;text-align:center;border-top:1px solid #dfdfdf;padding:18px;"><a href="' . esc_url(admin_url('/options-general.php?page=pinpointe&tab=help')) . '">' . esc_html__('How do I display my forms?', 'pinpointe') . '</a></div>'; 510 580 } 511 581 else if ($current_tab == 'help') { … … 541 611 542 612 $pinpointe_selected_tags[$form_key] = array( 543 'tag ' => $form['tag']613 'tags' => $form['tags'] 544 614 ); 545 615 } … … 554 624 */ 555 625 $forms_page_hints = array( 556 'pinpointe_forms_title_field' => __('<p>Title of the form - will be displayed in a signup form header.</p>', 'pinpointe'),557 'pinpointe_forms_above_field' => __('<p>Message to display above form fields.</p>', 'pinpointe'),558 'pinpointe_forms_below_field' => __('<p>Message to display below form fields.</p>', 'pinpointe'),559 'pinpointe_forms_button_field' => __('<p>Form submit button label.</p>', 'pinpointe'),560 'pinpointe_forms_color_scheme' => __('<p>Select one of the predefined color schemes. You can further customize the look & feel of your forms by adding custom CSS rules to Settings > Override CSS.</p>', 'pinpointe'),561 'pinpointe_forms_redirect_url' => __('<p>Optionaly provide an URL where subscribers should be redirected to after successful signup.</p> <p>Leave this field empty to simply display a thank you message.</p>', 'pinpointe'),562 'pinpointe_forms_mailing_list' => __('<p>Select one of your Pinpointe mailing databases for users to be subscribed to.</p>', 'pinpointe'),563 'pinpointe_forms_mailing_tag' => __('<p>Select one of your Pinpointe lists for users to be added to.</p>', 'pinpointe'),564 'pinpointe_forms_groups' => __('<p>Select interest groups that you want to add automatically or allow users to choose in the form.</p> <p>If no interest groups are available, either mailing list has not been selected yet in the field above or you have no interest groups created for this list.</p>', 'pinpointe'),565 'pinpointe_form_group_method' => __('<p>Select how you would like interest groups to work with this form - you can either add all selected interest groups to subscribers profile by default or allow your visitors to manually select some.</p>', 'pinpointe'),566 'form_condition_key' => __('<p>Controls on which parts of the website this form will appear (or not appear).</p>', 'pinpointe'),567 'form_condition_value_pages' => __('<p>List of pages to check current page against.</p>', 'pinpointe'),568 'form_condition_value_posts' => __('<p>List of posts to check current post against.</p>', 'pinpointe'),569 'form_condition_value_post_categories' => __('<p>List of post categories to check current post against.</p>', 'pinpointe'),570 'form_condition_value_url' => __('<p>URL fragment to search in the URL of the page.</p>', 'pinpointe'),571 'pinpointe_forms_send_confirmation' => __('<p>Whether or not to send a confirmation email to subscribers when they submit a subscription form. If selected, subscriptions will be recorded, but subscribers will be marked as Unconfirmed until they receive and choose to confirm their subscription via email.</p>', 'pinpointe'),626 'pinpointe_forms_title_field' => esc_html__('<p>Title of the form - will be displayed in a signup form header.</p>', 'pinpointe'), 627 'pinpointe_forms_above_field' => esc_html__('<p>Message to display above form fields.</p>', 'pinpointe'), 628 'pinpointe_forms_below_field' => esc_html__('<p>Message to display below form fields.</p>', 'pinpointe'), 629 'pinpointe_forms_button_field' => esc_html__('<p>Form submit button label.</p>', 'pinpointe'), 630 'pinpointe_forms_color_scheme' => esc_html__('<p>Select one of the predefined color schemes. You can further customize the look & feel of your forms by adding custom CSS rules to Settings > Override CSS.</p>', 'pinpointe'), 631 'pinpointe_forms_redirect_url' => esc_html__('<p>Optionaly provide an URL where subscribers should be redirected to after successful signup.</p> <p>Leave this field empty to simply display a thank you message.</p>', 'pinpointe'), 632 'pinpointe_forms_mailing_list' => esc_html__('<p>Select one of your Pinpointe mailing databases for users to be subscribed to.</p>', 'pinpointe'), 633 'pinpointe_forms_mailing_tag' => esc_html__('<p>Select one of your Pinpointe lists for users to be added to.</p>', 'pinpointe'), 634 'pinpointe_forms_groups' => esc_html__('<p>Select interest groups that you want to add automatically or allow users to choose in the form.</p> <p>If no interest groups are available, either mailing list has not been selected yet in the field above or you have no interest groups created for this list.</p>', 'pinpointe'), 635 'pinpointe_form_group_method' => esc_html__('<p>Select how you would like interest groups to work with this form - you can either add all selected interest groups to subscribers profile by default or allow your visitors to manually select some.</p>', 'pinpointe'), 636 'form_condition_key' => esc_html__('<p>Controls on which parts of the website this form will appear (or not appear).</p>', 'pinpointe'), 637 'form_condition_value_pages' => esc_html__('<p>List of pages to check current page against.</p>', 'pinpointe'), 638 'form_condition_value_posts' => esc_html__('<p>List of posts to check current post against.</p>', 'pinpointe'), 639 'form_condition_value_post_categories' => esc_html__('<p>List of post categories to check current post against.</p>', 'pinpointe'), 640 'form_condition_value_url' => esc_html__('<p>URL fragment to search in the URL of the page.</p>', 'pinpointe'), 641 'pinpointe_forms_send_confirmation' => esc_html__('<p>Whether or not to send a confirmation email to subscribers when they submit a subscription form. If selected, subscriptions will be recorded, but subscribers will be marked as Unconfirmed until they receive and choose to confirm their subscription via email.</p>', 'pinpointe'), 572 642 ); 573 643 … … 577 647 var pinpointe_hints = <?php echo json_encode($this->hints); ?>; 578 648 var pinpointe_forms_hints = <?php echo json_encode($forms_page_hints); ?>; 579 var pinpointe_home_url = '<?php echo site_url(); ?>'; 580 var pinpointe_label_still_connecting_to_pinpointe = '<?php _e('Still connecting to Pinpointe...', 'pinpointe'); ?>'; 581 var pinpointe_label_mailing_list = '<?php _e('Mailing database', 'pinpointe'); ?>'; 582 var pinpointe_label_mailing_tag = '<?php _e('Mailing list', 'pinpointe'); ?>'; 583 var pinpointe_label_no_results_match_list = '<?php _e('There are no databases named', 'pinpointe'); ?>'; 584 var pinpointe_label_no_results_match_tag = '<?php _e('There are no lists named', 'pinpointe'); ?>'; 585 var pinpointe_label_select_mailing_list = '<?php _e('Select a mailing database', 'pinpointe'); ?>'; 586 var pinpointe_label_select_mailing_tag = '<?php _e('Select a mailing list', 'pinpointe'); ?>'; 587 var pinpointe_label_no_results_match_groups = '<?php _e('Selected database does not have groups named', 'pinpointe'); ?>'; 588 var pinpointe_label_select_some_groups = '<?php _e('Select some groups (optional)', 'pinpointe'); ?>'; 589 var pinpointe_label_groups = '<?php _e('Interest groups', 'pinpointe'); ?>'; 590 var pinpointe_label_fields_name = '<?php _e('Field Label', 'pinpointe'); ?>'; 591 var pinpointe_label_fields_tag = '<?php _e('Pinpointe Field', 'pinpointe'); ?>'; // Changed from 'Pinpointe Tag' 592 var pinpointe_label_fields_icon = '<?php _e('Icon', 'pinpointe'); ?>'; 593 var pinpointe_label_add_new = '<?php _e('Add Field', 'pinpointe'); ?>'; // Changed from 'Add Tag' 594 var pinpointe_label_no_results_match_tags = '<?php _e('Selected database does not have fields named', 'pinpointe'); ?>'; 595 var pinpointe_label_select_tag = '<?php _e('Select a field', 'pinpointe'); ?>'; // Changed from 'Select a tag' 596 var pinpointe_label_connecting_to_pinpointe = '<?php _e('Connecting to Pinpointe...', 'pinpointe'); ?>'; 597 var pinpointe_label_no_results_match_pages = '<?php _e('No pages named', 'pinpointe'); ?>'; 598 var pinpointe_label_select_some_pages = '<?php _e('Select some pages', 'pinpointe'); ?>'; 599 var pinpointe_label_no_results_match_posts = '<?php _e('No posts named', 'pinpointe'); ?>'; 600 var pinpointe_label_select_some_posts = '<?php _e('Select some posts', 'pinpointe'); ?>'; 601 var pinpointe_label_no_results_match_post_categories = '<?php _e('No post categories named', 'pinpointe'); ?>'; 602 var pinpointe_label_select_some_post_categories = '<?php _e('Select some post categories', 'pinpointe'); ?>'; 603 var pinpointe_label_no_results_match_forms = '<?php _e('No forms named', 'pinpointe'); ?>'; 604 var pinpointe_label_select_some_forms = '<?php _e('Select forms here', 'pinpointe'); ?>'; 605 var pinpointe_label_signup_form_no = '<?php _e('Signup Form #', 'pinpointe'); ?>'; 606 var pinpointe_label_email = '<?php _e('Email', 'pinpointe'); ?>'; 607 var pinpointe_label_button = '<?php _e('Submit', 'pinpointe'); ?>'; 649 var pinpointe_home_url = '<?php echo esc_url(site_url()); ?>'; 650 var pinpointe_label_still_connecting_to_pinpointe = '<?php esc_html_e('Still connecting to Pinpointe...', 'pinpointe'); ?>'; 651 var pinpointe_label_mailing_list = '<?php esc_html_e('Mailing database', 'pinpointe'); ?>'; 652 var pinpointe_label_mailing_tag = '<?php esc_html_e('Mailing list', 'pinpointe'); ?>'; 653 var pinpointe_label_no_results_match_list = '<?php esc_html_e('There are no databases named', 'pinpointe'); ?>'; 654 var pinpointe_label_no_results_match_tag = '<?php esc_html_e('There are no lists named', 'pinpointe'); ?>'; 655 var pinpointe_label_select_mailing_list = '<?php esc_html_e('Select a mailing database', 'pinpointe'); ?>'; 656 var pinpointe_label_select_mailing_tag = '<?php esc_html_e('Select a mailing list', 'pinpointe'); 657 ?>'; 658 var pinpointe_label_no_results_match_groups = '<?php esc_html_e('Selected database does not have groups named', 'pinpointe'); ?>'; 659 var pinpointe_label_select_some_groups = '<?php esc_html_e('Select some groups (optional)', 'pinpointe'); ?>'; 660 var pinpointe_label_groups = '<?php esc_html_e('Interest groups', 'pinpointe'); ?>'; 661 var pinpointe_label_fields_name = '<?php esc_html_e('Field Label', 'pinpointe'); ?>'; 662 var pinpointe_label_fields_tag = '<?php esc_html_e('Pinpointe Field', 'pinpointe'); ?>'; // 663 // Changed from 'Pinpointe Tag' 664 var pinpointe_label_fields_icon = '<?php esc_html_e('Icon', 'pinpointe'); ?>'; 665 var pinpointe_label_add_new = '<?php esc_html_e('Add Field', 'pinpointe'); ?>'; // Changed from 666 // 'Add Tag' 667 var pinpointe_label_no_results_match_tags = '<?php esc_html_e('Selected database does not have fields named', 'pinpointe'); ?>'; 668 var pinpointe_label_select_tag = '<?php esc_html_e('Select a field', 'pinpointe'); ?>'; // 669 // Changed from 'Select a tag' 670 var pinpointe_label_connecting_to_pinpointe = '<?php esc_html_e('Connecting to Pinpointe...', 'pinpointe'); ?>'; 671 var pinpointe_label_no_results_match_pages = '<?php esc_html_e('No pages named', 'pinpointe'); ?>'; 672 var pinpointe_label_select_some_pages = '<?php esc_html_e('Select some pages', 'pinpointe'); ?>'; 673 var pinpointe_label_no_results_match_posts = '<?php esc_html_e('No posts named', 'pinpointe'); ?>'; 674 var pinpointe_label_select_some_posts = '<?php esc_html_e('Select some posts', 'pinpointe'); ?>'; 675 var pinpointe_label_no_results_match_post_categories = '<?php esc_html_e('No post categories named', 'pinpointe'); ?>'; 676 var pinpointe_label_select_some_post_categories = '<?php esc_html_e('Select some post categories', 'pinpointe'); ?>'; 677 var pinpointe_label_no_results_match_forms = '<?php esc_html_e('No forms named', 'pinpointe'); ?>'; 678 var pinpointe_label_select_some_forms = '<?php esc_html_e('Select forms here', 'pinpointe'); ?>'; 679 var pinpointe_label_signup_form_no = '<?php esc_html_e('Signup Form #', 'pinpointe'); ?>'; 680 var pinpointe_label_email = '<?php esc_html_e('Email', 'pinpointe'); ?>'; 681 var pinpointe_label_button = '<?php esc_html_e('Submit', 'pinpointe'); ?>'; 608 682 var pinpointe_font_awesome_icons = <?php echo json_encode($this->get_font_awesome_icons()); ?>; 609 var pinpointe_label_bad_ajax_response = '<?php printf( __('%s Response received from your server is malformed.', 'pinpointe'), '<i class="fa fa-times" style="font-size: 1.5em; color: red;"></i>'); ?>';610 var pinpointe_label_integration_status = '<?php _e('Integration status', 'pinpointe'); ?>';683 var pinpointe_label_bad_ajax_response = '<?php printf(esc_html__('%s Response received from your server is malformed.', 'pinpointe'), '<i class="fa fa-times" style="font-size: 1.5em; color: red;"></i>'); ?>'; 684 var pinpointe_label_integration_status = '<?php esc_html_e('Integration status', 'pinpointe'); ?>'; 611 685 612 686 <?php if ($current_tab == 'forms'): ?> … … 616 690 617 691 <?php if ($current_tab == 'checkboxes'): ?> 618 var pinpointe_selected_list = '<?php echo (isset($this->opt['pinpointe_checkbox_list']) ? $this->opt['pinpointe_checkbox_list'] : ''); ?>';692 var pinpointe_selected_list = '<?php echo esc_html(isset($this->opt['pinpointe_checkbox_list']) ? $this->opt['pinpointe_checkbox_list'] : ''); ?>'; 619 693 <?php endif; ?> 620 694 621 695 <?php if ($current_tab == 'sync'): ?> 622 var pinpointe_selected_list = '<?php echo (isset($this->opt['pinpointe_sync_list']) ? $this->opt['pinpointe_sync_list'] : ''); ?>';696 var pinpointe_selected_list = '<?php echo esc_html(isset($this->opt['pinpointe_sync_list']) ? $this->opt['pinpointe_sync_list'] : ''); ?>'; 623 697 <?php endif; ?> 624 698 … … 637 711 { 638 712 if (isset($this->section_info[$section['id']])) { 639 echo $this->section_info[$section['id']];713 echo esc_html($this->section_info[$section['id']]); 640 714 } 641 715 … … 645 719 ?> 646 720 <div class="pinpointe-forms"> 647 <p><?php printf( __('You must <a href="%s">enter</a> your Pinpointe API key to use this feature.', 'pinpointe'), admin_url('/options-general.php?page=pinpointe&tab=settings')); ?></p>721 <p><?php printf(esc_html__('You must <a href="%s">enter</a> your Pinpointe API key to use this feature.', 'pinpointe'), esc_url(admin_url('/options-general.php?page=pinpointe&tab=settings'))); ?></p> 648 722 </div> 649 723 <?php … … 853 927 ); 854 928 $pinpointe_selected_tags[$form_key] = array( 855 'tag ' => $form['tag']929 'tags' => $form['tags'] 856 930 ); 857 931 } … … 878 952 $pinpointe_selected_tags = array(); 879 953 } 880 954 ob_start(); 955 require PINPOINTE_PLUGIN_PATH . '/includes/pinpointe-confirmation-email.inc.php'; 956 $default_confirmation_email_html = ob_get_clean(); 881 957 ?> 882 958 … … 886 962 <?php foreach ($saved_forms as $form_key => $form): ?> 887 963 888 <div id="pinpointe_forms_list_<?php echo $form_key; ?>">889 <h4 class="pinpointe_forms_handle"><span class="pinpointe_forms_title" id="pinpointe_forms_title_<?php echo $form_key; ?>"><?php _e('Signup Form #', 'pinpointe'); ?><?php echo $form_key; ?></span> <span class="pinpointe_forms_title_name"><?php echo (!empty($form['title'])) ? '- ' . $form['title'] : ''; ?></span><span class="pinpointe_forms_remove" id="pinpointe_forms_remove_<?php echo $form_key; ?>" title="<?php_e('Remove', 'pinpointe'); ?>"><i class="fa fa-times"></i></span></h4>964 <div id="pinpointe_forms_list_<?php echo esc_attr($form_key); ?>"> 965 <h4 class="pinpointe_forms_handle"><span class="pinpointe_forms_title" id="pinpointe_forms_title_<?php echo esc_attr($form_key); ?>"><?php esc_html_e('Signup Form #', 'pinpointe'); ?><?php echo esc_html($form_key); ?></span> <span class="pinpointe_forms_title_name"><?php echo (!empty($form['title'])) ? '- ' . esc_html($form['title']) : ''; ?></span><span class="pinpointe_forms_remove" id="pinpointe_forms_remove_<?php echo esc_attr($form_key); ?>" title="<?php esc_html_e('Remove', 'pinpointe'); ?>"><i class="fa fa-times"></i></span></h4> 890 966 <div style="clear:both;"> 891 967 892 <div class="pinpointe_forms_section"><?php _e('Main Settings', 'pinpointe'); ?></div>968 <div class="pinpointe_forms_section"><?php esc_html_e('Main Settings', 'pinpointe'); ?></div> 893 969 <table class="form-table"><tbody> 894 970 <tr valign="top"> 895 <th scope="row"><?php _e('Form title', 'pinpointe'); ?></th>896 <td><input type="text" id="pinpointe_forms_title_field_<?php echo $form_key; ?>" name="pinpointe_options[forms][<?php echo $form_key; ?>][title]" value="<?php echo htmlentities($form['title']); ?>" class="pinpointe-field pinpointe_forms_title_field"></td>971 <th scope="row"><?php esc_html_e('Form title', 'pinpointe'); ?></th> 972 <td><input type="text" id="pinpointe_forms_title_field_<?php echo esc_attr($form_key); ?>" name="pinpointe_options[forms][<?php echo esc_attr($form_key); ?>][title]" value="<?php echo esc_attr($form['title']); ?>" class="pinpointe-field pinpointe_forms_title_field"></td> 897 973 </tr> 898 974 <tr valign="top"> 899 <th scope="row"><?php _e('Text above form', 'pinpointe'); ?></th>900 <td><input type="text" id="pinpointe_forms_above_field_<?php echo $form_key; ?>" name="pinpointe_options[forms][<?php echo $form_key; ?>][above]" value="<?php echo htmlentities($form['above']); ?>" class="pinpointe-field pinpointe_forms_above_field"></td>975 <th scope="row"><?php esc_html_e('Text above form', 'pinpointe'); ?></th> 976 <td><input type="text" id="pinpointe_forms_above_field_<?php echo esc_attr($form_key); ?>" name="pinpointe_options[forms][<?php echo esc_attr($form_key); ?>][above]" value="<?php echo esc_attr($form['above']); ?>" class="pinpointe-field pinpointe_forms_above_field"></td> 901 977 </tr> 902 978 <tr valign="top"> 903 <th scope="row"><?php _e('Text below form', 'pinpointe'); ?></th>904 <td><input type="text" id="pinpointe_forms_below_field_<?php echo $form_key; ?>" name="pinpointe_options[forms][<?php echo $form_key; ?>][below]" value="<?php echo htmlentities($form['below']); ?>" class="pinpointe-field pinpointe_forms_below_field"></td>979 <th scope="row"><?php esc_html_e('Text below form', 'pinpointe'); ?></th> 980 <td><input type="text" id="pinpointe_forms_below_field_<?php echo esc_attr($form_key); ?>" name="pinpointe_options[forms][<?php echo esc_attr($form_key); ?>][below]" value="<?php echo esc_attr($form['below']); ?>" class="pinpointe-field pinpointe_forms_below_field"></td> 905 981 </tr> 906 982 <tr valign="top"> 907 <th scope="row"><?php _e('Submit button label', 'pinpointe'); ?></th>908 <td><input type="text" id="pinpointe_forms_button_field_<?php echo $form_key; ?>" name="pinpointe_options[forms][<?php echo $form_key; ?>][button]" value="<?php echo htmlentities($form['button']); ?>" class="pinpointe-field pinpointe_forms_button_field"></td>983 <th scope="row"><?php esc_html_e('Submit button label', 'pinpointe'); ?></th> 984 <td><input type="text" id="pinpointe_forms_button_field_<?php echo esc_attr($form_key); ?>" name="pinpointe_options[forms][<?php echo esc_attr($form_key); ?>][button]" value="<?php echo isset($form['button']) ? esc_attr($form['button']) : ''; ?>" class="pinpointe-field pinpointe_forms_button_field"></td> 909 985 </tr> 910 986 <tr valign="top"> 911 <th scope="row"><?php _e('Color scheme', 'pinpointe'); ?></th>912 <td><select id="pinpointe_forms_color_scheme_<?php echo $form_key; ?>" name="pinpointe_options[forms][<?php echo $form_key; ?>][color_scheme]" class="pinpointe-field pinpointe_forms_color_scheme">987 <th scope="row"><?php esc_html_e('Color scheme', 'pinpointe'); ?></th> 988 <td><select id="pinpointe_forms_color_scheme_<?php echo esc_attr($form_key); ?>" name="pinpointe_options[forms][<?php echo esc_attr($form_key); ?>][color_scheme]" class="pinpointe-field pinpointe_forms_color_scheme"> 913 989 914 990 <?php 915 991 foreach ($color_schemes as $scheme_value => $scheme_title) { 916 992 $is_selected = ((isset($form['color_scheme']) && $form['color_scheme'] == $scheme_value) ? 'selected="selected"' : ''); 917 echo '<option value="' . $scheme_value . '" ' . $is_selected . '>' . $scheme_title. '</option>';993 echo '<option value="' . esc_attr($scheme_value) . '" ' . esc_attr($is_selected) . '>' . esc_html($scheme_title) . '</option>'; 918 994 } 919 995 ?> … … 922 998 </tr> 923 999 <tr valign="top"> 924 <th scope="row"><?php _e('Success redirect URL', 'pinpointe'); ?></th>925 <td><input type="text" id="pinpointe_forms_redirect_url_<?php echo $form_key; ?>" name="pinpointe_options[forms][<?php echo $form_key; ?>][redirect_url]" value="<?php echo $form['redirect_url']; ?>" class="pinpointe-field pinpointe_forms_redirect_url"></td>1000 <th scope="row"><?php esc_html_e('Success redirect URL', 'pinpointe'); ?></th> 1001 <td><input type="text" id="pinpointe_forms_redirect_url_<?php echo esc_attr($form_key); ?>" name="pinpointe_options[forms][<?php echo esc_attr($form_key); ?>][redirect_url]" value="<?php echo isset($form['redirect_url']) ? esc_attr($form['redirect_url']) : ''; ?>" class="pinpointe-field pinpointe_forms_redirect_url"></td> 926 1002 </tr> 927 1003 <tr valign="top"> 928 <th scope="row"><?php _e('Send confirmation email', 'pinpointe'); ?></th>1004 <th scope="row"><?php esc_html_e('Send confirmation email', 'pinpointe'); ?></th> 929 1005 <td> 930 1006 <?php 931 echo '<input type="checkbox" id="pinpointe_forms_send_confirmation_' . $form_key . '" name="pinpointe_options[forms][' . $form_key . '][send_confirmation]" class="pinpointe-field pinpointe_forms_send_confirmation" ' . ($form['send_confirmation'] ? "checked" : '') . '>';1007 echo '<input type="checkbox" id="pinpointe_forms_send_confirmation_' . esc_attr($form_key) . '" name="pinpointe_options[forms][' . esc_attr($form_key) . '][send_confirmation]" class="pinpointe-field pinpointe_forms_send_confirmation" ' . (isset($form['send_confirmation']) && $form['send_confirmation'] ? "checked" : '') . '>'; 932 1008 ?> 933 1009 </td> 934 1010 </tr> 1011 <tr valign="top" class="pinpointe_forms_confirmation_email_trs"> 1012 <th scope="row"><?php esc_html_e('Override default confirmation email', 'pinpointe'); ?></th> 1013 <td> 1014 <?php 1015 echo '<input type="checkbox" id="pinpointe_forms_overide_confirmation_' . esc_attr($form_key) . '" name="pinpointe_options[forms][' . esc_attr($form_key) . '][overide_confirmation]" class="pinpointe-field pinpointe_forms_overide_confirmation" ' . (isset($form['overide_confirmation']) && $form['overide_confirmation'] ? "checked" : '') . '>'; 1016 ?> 1017 </td> 1018 </tr> 1019 <tr valign="top" class="pinpointe_forms_confirmation_email_trs pinpointe_forms_confirmation_email_tr"> 1020 <td scope="row" colspan="2" id="forms_confirmation_email_td_<?php echo esc_attr($form_key) ?>"><strong><?php esc_html_e('Confirmation email', 'pinpointe'); ?></strong> 1021 <br/> 1022 <?php 1023 wp_enqueue_editor(); 1024 $editor_key = 'pinpointe_forms_html_confirmation_email_' . $form_key; 1025 1026 $content = isset($form['html_confirmation_email']) && !empty($form['html_confirmation_email']) ? $form['html_confirmation_email'] : 1027 $default_confirmation_email_html; 1028 1029 $textarea_name = 'pinpointe_options[forms][' . $form_key . '][html_confirmation_email]'; 1030 1031 echo '<textarea class="pinpointe-field pinpointe_forms_html_confirmation_email" name="' . esc_attr($textarea_name) . '" id="' . esc_attr($editor_key) . '" rows="25" style="width:100%">' . esc_textarea($content) . '</textarea>'; 1032 1033 ?> 1034 </td> 1035 </tr> 935 1036 </tbody></table> 936 1037 937 1038 <div class="pinpointe_forms_section">Database</div> 938 <p id="pinpointe_forms_list_<?php echo $form_key; ?>" class="pinpointe_loading_list pinpointe_forms_field_list_groups">1039 <p id="pinpointe_forms_list_<?php echo esc_attr($form_key); ?>" class="pinpointe_loading_list pinpointe_forms_field_list_groups"> 939 1040 <span class="pinpointe_loading_icon"></span> 940 <?php _e('Connecting to Pinpointe...', 'pinpointe'); ?>1041 <?php esc_html_e('Connecting to Pinpointe...', 'pinpointe'); ?> 941 1042 </p> 942 1043 943 1044 <div class="pinpointe_forms_section">List</div> 944 <p id="pinpointe_forms_tag_<?php echo $form_key; ?>" class="pinpointe_loading_tag pinpointe_forms_field_tag_groups"> 1045 1046 <p id="pinpointe_forms_tag_<?php echo esc_attr($form_key); ?>" class="pinpointe_loading_tag pinpointe_forms_field_tag_groups"> 945 1047 <span class="pinpointe_loading_icon"></span> 946 <?php _e('Connecting to Pinpointe...', 'pinpointe'); ?>1048 <?php esc_html_e('Connecting to Pinpointe...', 'pinpointe'); ?> 947 1049 </p> 1050 1051 <table class="form-table"> 1052 <tbody> 1053 <tr valign="top"> 1054 <th scope="row"><?php esc_html_e('Show Mailing lists', 'pinpointe'); ?></th> 1055 <td> 1056 <?php 1057 echo '<input type="checkbox" id="pinpointe_forms_show_mailing_list' . esc_attr($form_key) . '" name="pinpointe_options[forms][' . esc_attr($form_key) . '][show_mailing_list]" class="pinpointe-field pinpointe_forms_show_mailing_list" ' . (isset($form['show_mailing_list']) && $form['show_mailing_list'] === 'on' ? "checked" : '') . '>'; 1058 ?> 1059 </td> 1060 </tr> 1061 </tbody> 1062 </table> 948 1063 949 1064 <div class="pinpointe_forms_section">Form Fields</div> 950 <p id="pinpointe_fields_table_<?php echo $form_key; ?>" class="pinpointe_loading_list pinpointe_forms_field_fields">1065 <p id="pinpointe_fields_table_<?php echo esc_attr($form_key); ?>" class="pinpointe_loading_list pinpointe_forms_field_fields"> 951 1066 <span class="pinpointe_loading_icon"></span> 952 <?php _e('Connecting to Pinpointe...', 'pinpointe'); ?>1067 <?php esc_html_e('Connecting to Pinpointe...', 'pinpointe'); ?> 953 1068 </p> 954 1069 … … 956 1071 <table class="form-table"><tbody> 957 1072 <tr valign="top"> 958 <th scope="row"><?php _e('Display condition', 'pinpointe'); ?></th>959 <td><select id="pinpointe_forms_condition_<?php echo $form_key; ?>" name="pinpointe_options[forms][<?php echo $form_key; ?>][condition]" class="pinpointe-field form_condition_key">1073 <th scope="row"><?php esc_html_e('Display condition', 'pinpointe'); ?></th> 1074 <td><select id="pinpointe_forms_condition_<?php echo esc_attr($form_key); ?>" name="pinpointe_options[forms][<?php echo esc_attr($form_key); ?>][condition]" class="pinpointe-field form_condition_key"> 960 1075 961 1076 <?php 962 1077 foreach ($condition_options as $cond_cat) { 963 echo '<optgroup label="' . $cond_cat['title']. '">';1078 echo '<optgroup label="' . esc_attr($cond_cat['title']) . '">'; 964 1079 965 1080 foreach ($cond_cat['children'] as $cond_value => $cond_title) { 966 1081 $is_selected = (is_array($form['condition']) && isset($form['condition']['key']) && $form['condition']['key'] == $cond_value) ? 'selected="selected"' : ''; 967 echo '<option value="' . $cond_value . '" ' . $is_selected . '>' . $cond_title. '</option>';1082 echo '<option value="' . esc_attr($cond_value) . '" ' . esc_attr($is_selected) . '>' . esc_html($cond_title) . '</option>'; 968 1083 } 969 1084 … … 975 1090 </tr> 976 1091 <tr valign="top"> 977 <th scope="row"><?php _e('Pages', 'pinpointe'); ?></th>978 <td><select multiple id="pinpointe_forms_condition_pages_<?php echo $form_key; ?>" name="pinpointe_options[forms][<?php echo $form_key; ?>][condition_pages][]" class="pinpointe-field form_condition_value form_condition_value_pages form_condition_value_pages_not">1092 <th scope="row"><?php esc_html_e('Pages', 'pinpointe'); ?></th> 1093 <td><select multiple id="pinpointe_forms_condition_pages_<?php echo esc_attr($form_key); ?>" name="pinpointe_options[forms][<?php echo esc_attr($form_key); ?>][condition_pages][]" class="pinpointe-field form_condition_value form_condition_value_pages form_condition_value_pages_not"> 979 1094 980 1095 <?php 981 1096 foreach ($pages as $key => $name) { 982 1097 $is_selected = (is_array($form['condition']) && isset($form['condition']['key']) && in_array($form['condition']['key'], array('pages', 'pages_not')) && isset($form['condition']['value']) && is_array($form['condition']['value']) && in_array($key, $form['condition']['value'])) ? 'selected="selected"' : ''; 983 echo '<option value="' . $key . '" ' . $is_selected . '>' . $name. '</option>';1098 echo '<option value="' . esc_attr($key) . '" ' . esc_attr($is_selected) . '>' . esc_html($name) . '</option>'; 984 1099 } 985 1100 ?> … … 988 1103 </tr> 989 1104 <tr valign="top"> 990 <th scope="row"><?php _e('Posts', 'pinpointe'); ?></th>991 <td><select multiple id="pinpointe_forms_condition_posts_<?php echo $form_key; ?>" name="pinpointe_options[forms][<?php echo $form_key; ?>][condition_posts][]" class="pinpointe-field form_condition_value form_condition_value_posts form_condition_value_posts_not">1105 <th scope="row"><?php esc_html_e('Posts', 'pinpointe'); ?></th> 1106 <td><select multiple id="pinpointe_forms_condition_posts_<?php echo esc_attr($form_key); ?>" name="pinpointe_options[forms][<?php echo esc_attr($form_key); ?>][condition_posts][]" class="pinpointe-field form_condition_value form_condition_value_posts form_condition_value_posts_not"> 992 1107 993 1108 <?php 994 1109 foreach ($posts as $key => $name) { 995 1110 $is_selected = (is_array($form['condition']) && isset($form['condition']['key']) && in_array($form['condition']['key'], array('posts', 'posts_not')) && isset($form['condition']['value']) && is_array($form['condition']['value']) && in_array($key, $form['condition']['value'])) ? 'selected="selected"' : ''; 996 echo '<option value="' . $key . '" ' . $is_selected . '>' . $name. '</option>';1111 echo '<option value="' . esc_attr($key) . '" ' . esc_attr($is_selected) . '>' . esc_html($name) . '</option>'; 997 1112 } 998 1113 ?> … … 1001 1116 </tr> 1002 1117 <tr valign="top"> 1003 <th scope="row"><?php _e('Post categories', 'pinpointe'); ?></th>1004 <td><select multiple id="pinpointe_forms_condition_categories_<?php echo $form_key; ?>" name="pinpointe_options[forms][<?php echo $form_key; ?>][condition_categories][]" class="pinpointe-field form_condition_value form_condition_value_categories form_condition_value_categories_not">1118 <th scope="row"><?php esc_html_e('Post categories', 'pinpointe'); ?></th> 1119 <td><select multiple id="pinpointe_forms_condition_categories_<?php echo esc_attr($form_key); ?>" name="pinpointe_options[forms][<?php echo esc_attr($form_key); ?>][condition_categories][]" class="pinpointe-field form_condition_value form_condition_value_categories form_condition_value_categories_not"> 1005 1120 1006 1121 <?php 1007 1122 foreach ($post_categories as $key => $name) { 1008 1123 $is_selected = (is_array($form['condition']) && isset($form['condition']['key']) && in_array($form['condition']['key'], array('categories', 'categories_not')) && isset($form['condition']['value']) && is_array($form['condition']['value']) && in_array($key, $form['condition']['value'])) ? 'selected="selected"' : ''; 1009 echo '<option value="' . $key . '" ' . $is_selected . '>' . $name. '</option>';1124 echo '<option value="' . esc_attr($key) . '" ' . esc_attr($is_selected) . '>' . esc_html($name) . '</option>'; 1010 1125 } 1011 1126 ?> … … 1014 1129 </tr> 1015 1130 <tr valign="top"> 1016 <th scope="row"><?php _e('URL fragment', 'pinpointe'); ?></th> 1017 <td><input type="text" id="pinpointe_forms_condition_url_<?php echo $form_key; ?>" name="pinpointe_options[forms][<?php echo $form_key; ?>][condition_url]" value="<?php echo ((isset($form['condition']['key']) && in_array($form['condition']['key'], array('url', 'url_not')) && isset($form['condition']['value'])) ? $form['condition']['value'] : ''); ?>" class="pinpointe-field form_condition_value form_condition_value_url form_condition_value_url_not"></td> 1131 <th scope="row"><?php esc_html_e('URL fragment', 'pinpointe'); ?></th> 1132 <td><input type="text" id="pinpointe_forms_condition_url_<?php echo 1133 esc_attr($form_key); ?>" name="pinpointe_options[forms][<?php echo esc_attr($form_key); ?>][condition_url]" value="<?php echo ((isset($form['condition']['key']) && in_array($form['condition']['key'], array('url', 'url_not')) && isset($form['condition']['value'])) ? esc_attr($form['condition']['value']) : ''); ?>" class="pinpointe-field form_condition_value form_condition_value_url form_condition_value_url_not"></td> 1018 1134 </tr> 1019 1135 </tbody></table> … … 1027 1143 </div> 1028 1144 <div> 1029 <button type="button" name="pinpointe_add_set" id="pinpointe_add_set" disabled="disabled" class="button button-primary" value="<?php _e('Add Form', 'pinpointe'); ?>" title="<?php _e('Still connecting to Pinpointe...', 'pinpointe'); ?>"><i class="fa fa-plus"> <?php_e('Add Form', 'pinpointe'); ?></i></button>1145 <button type="button" name="pinpointe_add_set" id="pinpointe_add_set" disabled="disabled" class="button button-primary" value="<?php esc_html_e('Add Form', 'pinpointe'); ?>" title="<?php esc_html_e('Still connecting to Pinpointe...', 'pinpointe'); ?>"><i class="fa fa-plus"> <?php esc_html_e('Add Form', 'pinpointe'); ?></i></button> 1030 1146 <div style="clear: both;"></div> 1031 1147 </div> … … 1038 1154 else if ($section['id'] == 'help_display') { 1039 1155 echo '<div class="pinpointe-section-info"><p style="line-height: 160%;">' 1040 . __('You can create multiple newsletter signup forms on the "Forms" page. Each can be displayed in one of the following ways:', 'pinpointe')1156 . esc_html__('You can create multiple newsletter signup forms on the "Forms" page. Each can be displayed in one of the following ways:', 'pinpointe') 1041 1157 . '</p><p style="line-height: 160%;">' 1042 . '<strong style="color:#222;">' . __('Widget', 'pinpointe') . '</strong><br />'1043 . sprintf( __('Display any form on a sidebar of your choice by using a standard WordPress Widget. Go to the <a href="%s">Widgets page</a> and use the one named Pinpointe Signup. You can add as many instances of this widget as you like. You can optionally specify a comma-separated list of form IDs to limit which forms can be displayed on that particular spot.', 'pinpointe'), admin_url('/widgets.php'))1158 . '<strong style="color:#222;">' . esc_html__('Widget', 'pinpointe') . '</strong><br />' 1159 . sprintf(esc_html__('Display any form on a sidebar of your choice by using a standard WordPress Widget. Go to the <a href="%s">Widgets page</a> and use the one named Pinpointe Signup. You can add as many instances of this widget as you like. You can optionally specify a comma-separated list of form IDs to limit which forms can be displayed on that particular spot.', 'pinpointe'), esc_url(admin_url('/widgets.php'))) 1044 1160 . '</p><p style="line-height: 160%;">' 1045 . '<strong style="color:#222;">' . __('Shortcode', 'pinpointe') . ' <code>[pinpointe_form]</code></strong><br />'1046 . __('Insert a form into individual posts or pages by placing a shortcode anywhere in the content. You can limit which forms are eligible to be displayed here by specifying <code>forms</code> with a comma-separated list of form IDs, e.g. <code>[pinpointe_form forms="1,3,4"]</code>. A single form will be chosen from the list of form IDs.', 'pinpointe')1161 . '<strong style="color:#222;">' . esc_html__('Shortcode', 'pinpointe') . ' <code>[pinpointe_form]</code></strong><br />' 1162 . esc_html__('Insert a form into individual posts or pages by placing a shortcode anywhere in the content. You can limit which forms are eligible to be displayed here by specifying <code>forms</code> with a comma-separated list of form IDs, e.g. <code>[pinpointe_form forms="1,3,4"]</code>. A single form will be chosen from the list of form IDs.', 'pinpointe') 1047 1163 . '</p><p style="line-height: 160%;">' 1048 . '<strong style="color:#222;">' . __('Function', 'pinpointe') . ' <code>pinpointe_form()</code></strong><br />'1049 . __('To display a form in nonstandard parts of your website, take advantage of the PHP function <code>pinpointe_form()</code>. To limit which forms can be displayed at that particular spot, pass a list of allowed form IDs in an array, e.g. <code>pinpointe_form(array(\'1\', \'3\', \'4\'))</code>', 'pinpointe')1164 . '<strong style="color:#222;">' . esc_html__('Function', 'pinpointe') . ' <code>pinpointe_form()</code></strong><br />' 1165 . esc_html__('To display a form in nonstandard parts of your website, take advantage of the PHP function <code>pinpointe_form()</code>. To limit which forms can be displayed at that particular spot, pass a list of allowed form IDs in an array, e.g. <code>pinpointe_form(array(\'1\', \'3\', \'4\'))</code>', 'pinpointe') 1050 1166 . '</p><p style="line-height: 160%;">' 1051 . '<strong style="color:#222;">' . __('Popup', 'pinpointe') . '</strong><br />'1052 . sprintf( __('Increase the signup rate by displaying one of your signup forms in a <a href="%s">popup</a>. If you wish popup to be opened on click and not automatically on page load, simply assign ID <code>pinpointe_popup_open</code> to the element that you want to bind it to.', 'pinpointe'), admin_url('/options-general.php?page=pinpointe&tab=popup'))1167 . '<strong style="color:#222;">' . esc_html__('Popup', 'pinpointe') . '</strong><br />' 1168 . sprintf(esc_html__('Increase the signup rate by displaying one of your signup forms in a <a href="%s">popup</a>. If you wish popup to be opened on click and not automatically on page load, simply assign ID <code>pinpointe_popup_open</code> to the element that you want to bind it to.', 'pinpointe'), esc_url(admin_url('/options-general.php?page=pinpointe&tab=popup'))) 1053 1169 . '</p><p style="line-height: 160%;">' 1054 . '<strong style="color:#222;">' . __('Under Post Content', 'pinpointe') . '</strong><br />'1055 . sprintf( __('You can easily configure this plugin to display signup forms under each <a href="%s">post</a> that you publish. You can exclude (or include only particular posts) by setting appropriate form displaying conditions.', 'pinpointe'), admin_url('/options-general.php?page=pinpointe&tab=below'))1170 . '<strong style="color:#222;">' . esc_html__('Under Post Content', 'pinpointe') . '</strong><br />' 1171 . sprintf(esc_html__('You can easily configure this plugin to display signup forms under each <a href="%s">post</a> that you publish. You can exclude (or include only particular posts) by setting appropriate form displaying conditions.', 'pinpointe'), esc_url(admin_url('/options-general.php?page=pinpointe&tab=below'))) 1056 1172 . '</p><p style="line-height: 160%;">' 1057 . '<strong style="color:#222;">' . __('As Content Lock', 'pinpointe') . '</strong><br />'1058 . sprintf( __('If you have valuable content that your visitors are after, you may wish to <a href="%s">lock</a> some of it so only visitors who subscribe to your mailing list can access it.', 'pinpointe'), admin_url('/options-general.php?page=pinpointe&tab=lock'))1173 . '<strong style="color:#222;">' . esc_html__('As Content Lock', 'pinpointe') . '</strong><br />' 1174 . sprintf(esc_html__('If you have valuable content that your visitors are after, you may wish to <a href="%s">lock</a> some of it so only visitors who subscribe to your mailing list can access it.', 'pinpointe'), esc_url(admin_url('/options-general.php?page=pinpointe&tab=lock'))) 1059 1175 . '</p></div>'; 1060 1176 } 1061 1177 else if ($section['id'] == 'help_contact') { 1062 1178 echo '<div class="pinpointe-section-info"><p>' 1063 . sprintf( __('If you\'ve got any questions, feel free to contact us at <a href="mailto:%s">%s</a>.', 'pinpointe'), '[email protected]', '[email protected]')1179 . sprintf(esc_html__('If you\'ve got any questions, feel free to contact us at <a href="mailto:%s">%s</a>.', 'pinpointe'), '[email protected]', '[email protected]') 1064 1180 . '</p><p>' 1065 1181 . '</p></div>'; … … 1079 1195 printf( 1080 1196 '<input type="text" id="%s" name="pinpointe_options[%s]" value="%s" class="pinpointe-field" />', 1081 $args['name'],1082 $args['name'],1083 $args['options'][$args['name']] 1197 esc_attr($args['name']), 1198 esc_attr($args['name']), 1199 esc_attr($args['options'][$args['name']]) 1084 1200 ); 1085 1201 } … … 1096 1212 printf( 1097 1213 '<textarea id="%s" name="pinpointe_options[%s]" class="pinpointe-textarea">%s</textarea>', 1098 $args['name'],1099 $args['name'],1100 $args['options'][$args['name']] 1214 esc_attr($args['name']), 1215 esc_attr($args['name']), 1216 esc_html($args['options'][$args['name']]) 1101 1217 ); 1102 1218 } … … 1113 1229 printf( 1114 1230 '<input type="checkbox" id="%s" name="pinpointe_options[%s]" value="1" %s />', 1115 $args['name'],1116 $args['name'],1231 esc_attr($args['name']), 1232 esc_attr($args['name']), 1117 1233 checked($args['options'][$args['name']], true, false) 1118 1234 ); … … 1142 1258 printf( 1143 1259 '<input type="checkbox" id="%s_%s" name="pinpointe_options[%s][]" value="%s" %s />', 1144 $args['name'],1145 $key,1146 $args['name'],1147 $key,1260 esc_attr($args['name']), 1261 esc_attr($key), 1262 esc_attr($args['name']), 1263 esc_attr($key), 1148 1264 checked($is_checked, true, false) 1149 1265 ); 1150 1266 1151 echo $name. '</li>';1267 echo esc_html($name) . '</li>'; 1152 1268 } 1153 1269 … … 1166 1282 printf( 1167 1283 '<select id="%s" name="pinpointe_options[%s]" class="pinpointe-field">', 1168 $args['name'],1169 $args['name'] 1284 esc_attr($args['name']), 1285 esc_attr($args['name']), 1170 1286 ); 1171 1287 … … 1173 1289 printf( 1174 1290 '<option value="%s" %s>%s</option>', 1175 $key,1291 esc_attr($key), 1176 1292 selected($key, $args['options'][$args['name']], false), 1177 $name 1293 esc_html($name) 1178 1294 ); 1179 1295 } … … 1193 1309 printf( 1194 1310 '<select multiple id="%s" name="pinpointe_options[%s][]" class="pinpointe-field">', 1195 $args['name'],1196 $args['name']1311 esc_attr($args['name']), 1312 esc_attr($args['name']) 1197 1313 ); 1198 1314 … … 1200 1316 printf( 1201 1317 '<option value="%s" %s>%s</option>', 1202 $key,1318 esc_attr($key), 1203 1319 (in_array($key, $args['options'][$args['name']]) ? 'selected="selected"' : ''), 1204 $name 1320 esc_html($name) 1205 1321 ); 1206 1322 } … … 1220 1336 printf( 1221 1337 '<input type="password" id="%s" name="pinpointe_options[%s]" value="%s" class="pinpointe-field" />', 1222 $args['name'],1223 $args['name'],1224 $args['options'][$args['name']] 1338 esc_attr($args['name']), 1339 esc_attr($args['name']), 1340 esc_attr($args['options'][$args['name']]) 1225 1341 ); 1226 1342 } … … 1272 1388 $new_forms[$form_number]['send_confirmation'] = (isset($form['send_confirmation']) && !empty($form['send_confirmation'])) ? $form['send_confirmation']: ''; 1273 1389 1390 // overide_confirmation 1391 $new_forms[$form_number]['overide_confirmation'] = (isset($form['overide_confirmation']) && !empty($form['overide_confirmation'])) ? $form['overide_confirmation']: ''; 1392 1393 // html_confirmation_email 1394 if (isset($form['html_confirmation_email']) && !empty($form['html_confirmation_email'])) { 1395 $shortcode_validation_errors = $this->validateShortcodes($form['html_confirmation_email']); 1396 if (!empty($shortcode_validation_errors)) { 1397 foreach($shortcode_validation_errors as $error){ 1398 array_push($errors, array('setting' => 'html_confirmation_email', 'custom' => __($error, 'pinpointe'))); 1399 } 1400 $form['html_confirmation_email'] = ''; 1401 } 1402 $new_forms[$form_number]['html_confirmation_email'] = $form['html_confirmation_email']; 1403 } 1404 1274 1405 // List 1275 1406 $new_forms[$form_number]['list'] = (isset($form['list_field']) && !empty($form['list_field'])) ? $form['list_field']: ''; 1276 1407 1277 1408 // Tag 1278 $new_forms[$form_number]['tag'] = (isset($form['tag_field']) && !empty($form['tag_field'])) ? $form['tag_field']: ''; 1409 $new_forms[$form_number]['tags'] = (isset($form['tag_field']) && !empty($form['tag_field'])) ? $form['tag_field']: ''; 1410 1411 // Show Mailing list 1412 $new_forms[$form_number]['show_mailing_list'] = (isset($form['show_mailing_list']) && !empty($form['show_mailing_list'])) ? $form['show_mailing_list'] : 'off'; 1413 1414 $this->saveTagMetadata($form_number, $new_forms[$form_number]['show_mailing_list'], $new_forms[$form_number]['tags']); 1279 1415 1280 1416 // Groups … … 1396 1532 } 1397 1533 } 1398 1399 1534 $output['forms'] = $new_forms; 1400 1535 } … … 1436 1571 // Validate boolean values (actually 1 and 0) 1437 1572 case 'bool': 1438 $input[$field] = $input[$field] == '' ? '0' : $input[$field];1573 $input[$field] = !isset($input[$field]) || $input[$field] == '' ? '0' : $input[$field]; 1439 1574 if (in_array($input[$field], array('0', '1')) || ($input[$field] == '' && $allow_empty)) { 1440 1575 $output[$field] = $input[$field]; … … 1501 1636 } 1502 1637 else { 1503 if (is _array($input[$field]) && !empty($input[$field])) {1638 if (isset($input[$field]) && is_array($input[$field]) && !empty($input[$field])) { 1504 1639 $temporary_output = array(); 1505 1640 … … 1611 1746 // Display errors 1612 1747 foreach ($errors as $error) { 1613 1614 $message = (!isset($error['custom']) ? $messages[$error['code']] : $error['custom']) . '. ' . __('Reverted to a previous state.', 'pinpointe'); 1615 1616 add_settings_error( 1617 'pinpointe_settings_updated', 1618 //$error['setting'], 1619 $error['code'], 1620 __('Value of', 'pinpointe') . ' "' . $this->titles[$error['setting']] . '" ' . $message 1621 ); 1748 $message = (!isset($error['custom']) ? $messages[$error['code']] : $error['custom']) . '. ' . __('Reverted to a previous state.', 'pinpointe'); 1749 $setting = $error['setting']; 1750 1751 if (array_key_exists($error['setting'], $this->titles) && isset($this->titles[$error['setting']])) { 1752 $setting = $this->titles[$error['setting']]; 1753 } 1754 1755 1756 $code = array_key_exists('code', $error) && isset($error['code']) 1757 ? $error['code'] 1758 : $error['custom']; 1759 1760 add_settings_error( 1761 'pinpointe_settings_updated', 1762 $code, 1763 __('Value of', 'pinpointe') . ' "' . $setting . '" ' . $message 1764 ); 1622 1765 } 1623 1766 … … 1625 1768 } 1626 1769 1770 /** 1771 * Save tag metadata to the database as a `pinpointe_tags_metadata` option 1772 * 1773 * @param int $form_id The ID of the form. 1774 * @param array $tag_ids An array of tag IDs to associate with the form. 1775 * @param bool $show_mailing_list Whether to show the mailing list for the form. 1776 * 1777 * @throws \Exception If options cannot be saved || tag_ids is empty 1778 */ 1779 public function saveTagMetadata($form_id, $show_mailing_list, $tag_ids = []) 1780 { 1781 if(empty($tag_ids)){ 1782 throw new \Exception("Warning Tag Metadata: Cannot attempt to save empty tag_ids"); 1783 } 1784 // Get all available (from API) 1785 $all_tags = $this->get_tags(); 1786 1787 // select only the tags that are specified in $tag_ids 1788 // we are doing this so that we store only valid tags (tags from API) 1789 $tags = array_intersect_key($all_tags, array_flip($tag_ids)); 1790 1791 // get the saved tag_metatada 1792 $existing_metadata = $this->get_tag_metadata(); 1793 1794 if (empty($existing_metadata)) { 1795 $existing_metadata[] = [ 1796 'form_id' => $form_id, 1797 'tags' => wp_json_encode($tags), 1798 'show_mailing_list' => $show_mailing_list, 1799 'hash' => md5(time()) 1800 ]; 1801 } else { 1802 $is_form_id_found = false; 1803 1804 // loop through $existing_metadata to update or add new entry 1805 // take note we are modifying the &$existing_metadata if form_id has been is_form_id_found 1806 foreach ($existing_metadata as &$metadata) { 1807 if ($metadata['form_id'] == $form_id) { 1808 $metadata['tags'] = wp_json_encode($tags); 1809 $metadata['show_mailing_list'] = $show_mailing_list; 1810 $metadata['hash'] = md5(time()); 1811 1812 $is_form_id_found = true; 1813 break; // exit the loop once we've modified the form_id's metadata 1814 } 1815 } 1816 1817 unset($metadata); // unset the reference - cause we were modifying it and we are done 1818 1819 // If metadata for the form_id doesn't exist, create a new entry 1820 if (!$is_form_id_found) { 1821 $new_metadata = [ 1822 'form_id' => $form_id, 1823 'tags' => wp_json_encode($tags), 1824 'show_mailing_list' => $show_mailing_list, 1825 'hash' => md5(time()) 1826 ]; 1827 $existing_metadata[] = $new_metadata; 1828 } 1829 } 1830 1831 $status = update_option('pinpointe_tags_metadata', $existing_metadata); 1832 1833 if (!$status) { 1834 throw new \Exception("Tag Metadata, Options: Could not save the tag metadata for some reason - E241"); 1835 } 1836 } 1837 1838 /** 1839 * Get tag metadata for a specific form or all forms. 1840 * 1841 * @param int|null $form_id The ID of the form. If null, retrieves metadata for all forms. 1842 * 1843 * @return array An array of tag metadata for the specified form or all forms. 1844 */ 1845 public function get_tag_metadata($form_id = null) 1846 { 1847 $results = get_option('pinpointe_tags_metadata'); 1848 1849 // Check if a specific form ID is provided and if its metadata exists 1850 if ($form_id !== null && isset($results[$form_id])) { 1851 return $results[$form_id]; 1852 } 1853 1854 return $results ? $results : []; 1855 } 1856 1857 1858 /** 1859 * Custom validation for shortcodes in the html email content 1860 * 1861 * @access public 1862 * @param string $key 1863 * @return mixed 1864 */ 1865 public function validateShortcodes($content) 1866 { 1867 $errors = []; 1868 /** 1869 * Shortcodes to check for existence. 1870 * 1871 * @var string[] 1872 */ 1873 $shortcodes_to_check = array( 1874 'pinpointe_powered_by', 1875 'pinpointe_email_sent_to', 1876 'pinpointe_confirm_link', 1877 'pinpointe_confirm_link_href', 1878 ); 1879 1880 foreach($shortcodes_to_check as $shortcode) { 1881 $shortcode_pattern = '/' . preg_quote('[' . $shortcode, '/') . '/'; 1882 if (!preg_match($shortcode_pattern, $content)) { 1883 $errors[] = ' missing '.$shortcode.' in the confirmation email content'; 1884 } 1885 } 1886 return $errors; 1887 } 1627 1888 /** 1628 1889 * Custom validation for service provider API key … … 1876 2137 // Check if we have something pre-selected 1877 2138 if (!empty($data)) { 1878 // Get merge vars1879 $merge = $this->get_merge_vars($lists);1880 2139 1881 2140 $lists_to_get = array(); … … 1885 2144 $lists_to_get[] = $form['list']; 1886 2145 } 1887 1888 $groups = $this->get_groups($lists_to_get); 1889 } 1890 1891 echo json_encode(array('message' => array('lists' => $lists, 'groups' => $groups, 'merge' => $merge))); 2146 2147 // Get merge vars 2148 // only fetch merge_vars with lists in lists_to_get instead of every list. 2149 $merge = $this->get_merge_vars(array_intersect_key($lists, array_flip($lists_to_get))); 2150 2151 } 2152 2153 echo json_encode(array('message' => array('lists' => $lists, 'groups' => null, 'merge' => $merge))); 1892 2154 die(); 1893 2155 } … … 1970 2232 } 1971 2233 1972 $results = array('' => '');2234 $results = []; 1973 2235 1974 2236 foreach ($tags as $tag) { 1975 $results[$tag['tagid']] = $tag['name']; 2237 $tagInfo = array( 2238 'name' => $tag['name'], 2239 'description' => isset($tag['description']) || !empty($tag['description']) ? $tag['description'] : 'Default description for ' . $tag['name'] 2240 ); 2241 2242 if (isset($tag['tagid'])) { // for xml api 2243 $results[$tag['tagid']] = $tagInfo; 2244 } else { // for json api 2245 $results[$tag['id']] = $tagInfo; 2246 } 2247 1976 2248 } 1977 2249 … … 2121 2393 // Check if we have received required data 2122 2394 if (isset($_POST['data']) && isset($_POST['data']['list'])) { 2123 $groups = $this->get_groups($_POST['data']['list']);2124 2395 $merge_vars = $this->get_merge_vars(array($_POST['data']['list'] => '')); 2125 2396 } 2126 2397 else { 2127 $groups = array('' => '');2128 2398 $merge_vars = array('' => ''); 2129 2399 } 2130 2400 2131 echo json_encode(array('message' => array('groups' => $groups, 'merge' => $merge_vars)));2401 echo json_encode(array('message' => array('groups' => ['' => ''], 'merge' => $merge_vars))); 2132 2402 die(); 2133 2403 } … … 2248 2518 { 2249 2519 if (!$this->load_pinpointe()) { 2250 $message = '<h4 style="margin:0px;"><i class="fa fa-check" style="font-size: 1.5em; color: green;"></i> ' . __('Pinpointe credentials could not be set', 'pinpointe') . ' ' . $account_info['username'] .'</h4>';2520 $message = '<h4 style="margin:0px;"><i class="fa fa-check" style="font-size: 1.5em; color: green;"></i> ' . __('Pinpointe credentials could not be set', 'pinpointe') . '</h4>'; 2251 2521 } 2252 2522 else if ( ($msg = $this->test_pinpointe()) !== true) { … … 2588 2858 require_once PINPOINTE_PLUGIN_PATH . '/includes/pinpointe-prepare-form.inc.php'; 2589 2859 2590 $form_html = pinpointe_prepare_form($form, $this->opt, 'after_posts' , $args);2860 $form_html = pinpointe_prepare_form($form, $this->opt, 'after_posts'); 2591 2861 2592 2862 return $content . $form_html; 2863 } 2864 2865 /** 2866 * Form shortcode handler 2867 * 2868 * @access public 2869 * @param mixed $attributes 2870 * @return void 2871 */ 2872 public function powered_by_shortcode($attributes) 2873 { 2874 return '<strong>Email marketing powered by <a style="display: inline-block; text-decoration: none; font-family: Helvetica, Arial, sans-serif; color: #262f57;" href="https://www.pinpointe.com/">Pinpointe</a></strong>'; 2875 } 2876 2877 /** 2878 * Form shortcode handler 2879 * 2880 * @access public 2881 * @param mixed $attributes 2882 * @return void 2883 */ 2884 public function email_sent_to_shortcode($attributes) 2885 { 2886 return '<small style="font-size: 86%; font-weight: normal;">This email was sent to <a style="display: inline-block; text-decoration: none; font-family: Helvetica, Arial, sans-serif; color: #7a7a7a;" href="mailto:%%emailaddress%%">%%emailaddress%%</a>.</small>'; 2887 } 2888 2889 /** 2890 * Form shortcode handler 2891 * 2892 * @access public 2893 * @param mixed $attributes 2894 * @return void 2895 */ 2896 public function confirm_link_shortcode($attributes) 2897 { 2898 return '<small style="font-size: 86%; font-weight: normal;">If the above link does not work, copy and paste the following link into your browser:<br/><a style="display: inline-block; text-decoration: none; font-family: Helvetica, Arial, sans-serif; color: #262f57;" href="%%CONFIRMLINK%%">%%CONFIRMLINK%%</a></small>'; 2899 } 2900 2901 /** 2902 * Form shortcode handler 2903 * 2904 * @access public 2905 * @param mixed $attributes 2906 * @return void 2907 */ 2908 public function confirm_link_href_shortcode($attributes) 2909 { 2910 return '%%CONFIRMLINK%%'; 2593 2911 } 2594 2912 … … 2658 2976 * @return mixed 2659 2977 */ 2660 public function subscribe($list_id, $email, $groups, $custom_fields, $is_backend = false, $tag _id = 0, $send_confirmation = false)2978 public function subscribe($list_id, $email, $groups, $custom_fields, $is_backend = false, $tags = [], $send_confirmation = false, $custom_data = [] ) 2661 2979 { 2662 2980 // Load Pinpointe … … 2714 3032 $this->opt['pinpointe_add_to_autoresponders'], 2715 3033 $this->opt['pinpointe_update_existing'], 2716 $tag_id, 2717 $send_confirmation 3034 $tags, 3035 $send_confirmation, 3036 $custom_data 2718 3037 ); 2719 3038 … … 2965 3284 $date_format = self::get_date_pattern('date', $this->opt['pinpointe_date_format'], 'date_format'); 2966 3285 2967 // Parse to array with date details (using strptime to support PHP 5.2) 2968 $date_parsed = strptime($data['custom'][$field['tag']], $date_format); 3286 if (version_compare(phpversion(), '7.2.0', '>=')){ 3287 $date_parsed = date_parse_from_format($date_format, $data['custom'][$field['tag']]); 3288 } 3289 else{ 3290 // Parse to array with date details (using strptime to support PHP 5.2) 3291 $date_parsed = strptime($data['custom'][$field['tag']], $date_format); 3292 } 3293 3294 $date_parsed = date_parse_from_format($date_format, $data['custom'][$field['tag']]); 2969 3295 2970 3296 if (!$date_parsed) { … … 3049 3375 } 3050 3376 3377 $custom_data = [ 3378 'html_confirmation_email' => $form['send_confirmation'] && !empty($form['html_confirmation_email']) && $form['overide_confirmation'] ? do_shortcode($form['html_confirmation_email']) : null, 3379 ]; 3380 3381 $tags = isset($data['custom']['selected_tags']) ? $data['custom']['selected_tags'] : $form['tags']; 3051 3382 // Subscribe user 3052 $subscribe_result = $this->subscribe($form['list'], $email, $subscribe_groups, $custom_fields, false, $form['tag'], $form['send_confirmation']); 3383 $subscribe_result = $this->subscribe( 3384 $form['list'], 3385 $email, 3386 $subscribe_groups, 3387 $custom_fields, 3388 false, 3389 $tags, 3390 $form['send_confirmation'], 3391 $custom_data 3392 ); 3393 3053 3394 3054 3395 if (is_bool($subscribe_result)) { … … 3785 4126 setTimeout(function() { 3786 4127 pinpointe_open_popup(); 3787 }, <?php echo ($this->opt['pinpointe_popup_delay'] != '' ? ($this->opt['pinpointe_popup_delay'] * 1000) : 1); ?>);4128 }, <?php echo esc_js($this->opt['pinpointe_popup_delay'] != '' ? ($this->opt['pinpointe_popup_delay'] * 1000) : 1); ?>); 3788 4129 } 3789 4130 … … 3794 4135 } 3795 4136 3796 form = jQuery('#pinpointe_popup_<?php echo $prepared_form_id; ?>');4137 form = jQuery('#pinpointe_popup_<?php echo esc_attr($prepared_form_id); ?>'); 3797 4138 3798 4139 jQuery('#sky-form-modal-overlay').fadeIn(); … … 3814 4155 3815 4156 <?php if ($this->opt['pinpointe_popup_time_limit']): ?> 3816 var minutes = <?php echo $this->opt['pinpointe_popup_time_limit']; ?>;4157 var minutes = <?php echo esc_html($this->opt['pinpointe_popup_time_limit']); ?>; 3817 4158 pinpointe_write_cookie('pinpointe_t', '1', minutes); 3818 4159 <?php endif; ?> … … 3840 4181 <?php 3841 4182 3842 echo $form_html;4183 echo wp_kses_post($form_html); 3843 4184 } 3844 4185 … … 3936 4277 public function render_checkbox($context) 3937 4278 { 3938 echo '<p style="margin: 2px 6px 16px 0px;"><label for="pinpointe_checkbox_signup"><input type="checkbox" id="pinpointe_checkbox_signup" name="pinpointe_checkbox_signup" value="1" ' . ($this->opt['pinpointe_checkbox_state'] == '1' ? 'checked="checked"' : '') . ' /> ' . $this->opt['pinpointe_checkbox_label']. '</label></p>';4279 echo '<p style="margin: 2px 6px 16px 0px;"><label for="pinpointe_checkbox_signup"><input type="checkbox" id="pinpointe_checkbox_signup" name="pinpointe_checkbox_signup" value="1" ' . esc_attr($this->opt['pinpointe_checkbox_state'] == '1' ? 'checked="checked"' : '') . ' /> ' . esc_html($this->opt['pinpointe_checkbox_label']) . '</label></p>'; 3939 4280 } 3940 4281 … … 3982 4323 3983 4324 // Role 3984 $merge['ROLE'] = array_shift(array_values($user->roles)); 4325 $array = array_values($user->roles); 4326 $merge['ROLE'] = array_shift($array); 3985 4327 3986 4328 // User name … … 4073 4415 4074 4416 // Role 4075 $merge['ROLE'] = array_shift(array_values($user->roles)); 4417 $array = array_values($user->roles); 4418 $merge['ROLE'] = array_shift($array); 4076 4419 4077 4420 // User name … … 4159 4502 4160 4503 // Role 4161 $role = array_shift(array_values($user->roles)); 4162 $role_old = array_shift(array_values($user_old->roles)); 4504 $roles = array_values($user->roles); 4505 $role = array_shift($roles); 4506 $old_roles = array_values($user_old->roles); 4507 $role_old = array_shift($old_roles); 4163 4508 4164 4509 if ($role != $role_old) { -
pinpointe-form-integration/trunk/readme.txt
r2547924 r3065401 3 3 Tags: email marketing, forms, popups, opt-in, mailing list, subscription 4 4 Requires at least: 3.5 5 Tested up to: 5.75 Tested up to: 6.4.2 6 6 Stable tag: 1.5 7 7 Requires PHP: 5.4 … … 49 49 50 50 == Changelog == 51 1.6 52 * Added ability to display multiple mailing lists on the subscription form 53 * Added option to override default pinpointe confirmation email sent to the subscriber upon form submission 54 * Fixed bugs related to PHP deprecations for PHP 8.0 and PHP 8.2 55 * Tested with WordPress v6.4.2 56 51 57 1.5 52 58 * Fixed an issue where not passing a list (tag) would cause the updated Pinpointe API to detect an error with the XML structure
Note: See TracChangeset
for help on using the changeset viewer.