Plugin Directory

Changeset 3065401


Ignore:
Timestamp:
04/05/2024 11:27:07 AM (23 months ago)
Author:
pinpointe
Message:

plugin update to v1.6

Location:
pinpointe-form-integration/trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • pinpointe-form-integration/trunk/assets/css/style-admin.css

    r2547924 r3065401  
    7070    width: 70px;
    7171    min-width: 70px;
     72}
     73
     74.pinpointe_forms_confirmation_email_tr td{
     75    padding-left: 0px;
    7276}
    7377
  • pinpointe-form-integration/trunk/assets/js/pinpointe-admin.js

    r2547924 r3065401  
    1010     */
    1111    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
    1221        jQuery(this).find(':input').each(function(){
    1322            if (typeof pinpointe_hints !== 'undefined' && typeof pinpointe_hints[jQuery(this).prop('id')] !== 'undefined') {
     
    3847    });
    3948    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    });
    4082
    4183    /**
     
    120162    });
    121163
     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
    122176    /**
    123177     * Set up accordion (form management)
    124178     */
    125179    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        },
    129207    }).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();
    136223    /**
    137224     * Make pages, posts and post_categories fields chosen on form setup
     
    182269    });
    183270
     271    var selected_options = [];
    184272    /**
    185273     * Forms page - lists and groups
     
    214302
    215303                    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)
    217305                        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;
    220313
    221314                        // List selection
    222315                        if (typeof result['message']['tags'] === 'object') {
    223                             // var fields = '';
    224                             var fields = '<option value="">&nbsp;</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="">&nbsp;</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="">&nbsp;</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>';
    227368                            }
    228369
    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">&nbsp;&nbsp;' + 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                                });
    239388                            });
    240 
    241                          }
    242 
     389                        }
    243390                         pinpointe_forms_page_hints();
    244391
     
    347494        });
    348495    }
     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   
    349620
    350621    /**
     
    8181089            jQuery('#pinpointe_forms_redirect_url_' + next_id).val('');
    8191090
     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           
    8201149            // 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
    8211205            jQuery(this).find('#pinpointe_forms_list_field_' + current_id).attr('id', 'pinpointe_forms_list_field_' + next_id);
    8221206            jQuery('#pinpointe_forms_list_field_' + next_id).attr('name', 'pinpointe_options[forms][' + next_id + '][list_field]');
     
    10961480        if(jQuery(this).find('option[value="email"]:selected').length != 1) {
    10971481            enabled = false;
     1482        }  else {
     1483            enabled = true;
    10981484        }
    10991485
  • pinpointe-form-integration/trunk/includes/pinpointe-form.inc.php

    r1340221 r3065401  
    88    function pinpointe_form($allowed_forms = array())
    99    {
    10         $opt = get_option('pinpointe_options', $results);
     10        $opt = get_option('pinpointe_options', $results = false);
    1111
    1212        // Check if integration is enabled
     
    2626        $html = pinpointe_prepare_form($form, $opt, 'shortcode');
    2727
    28         echo $html;
     28        echo esc_html($html);
    2929    }
    3030}
  • pinpointe-form-integration/trunk/includes/pinpointe-plugin-structure.inc.php

    r2093592 r3065401  
    3131                                            'empty' => true,
    3232                                        ),
    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'),
    3434                                    ),
    3535
     
    4242                                            'empty' => true,
    4343                                        ),
    44                                         'hint' => __('<p>Enter your Pinpointe username.</p>', 'pinpointe'),
     44                                        'hint' => esc_html__('<p>Enter your Pinpointe username.</p>', 'pinpointe'),
    4545                                    ),
    4646
     
    5353                                            'empty' => true,
    5454                                        ),
    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'),
    5656                                    ),
    5757                                ),
     
    6868                                            'empty' => false
    6969                                        ),
    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'),
    7171                                    ),
    7272                                    'send_welcome' => array(
     
    7878                                            'empty' => false
    7979                                        ),
    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'),
    8181                                    ),
    8282                                    'replace_groups' => array(
     
    8888                                            'empty' => false
    8989                                        ),
    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'),
    9191                                    ),*/
    9292                                    'add_to_autoresponders' => array(
     
    9898                                            'empty' => false
    9999                                        ),
    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'),
    101101                                    ),
    102102                                    'update_existing' => array(
     
    108108                                            'empty' => false
    109109                                        ),
    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'),
    111111                                    ),
    112112                                ),
     
    123123                                            'empty' => false
    124124                                        ),
    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'),
    126126                                    ),
    127127                                    /*'groups_hidden' => array(
     
    133133                                            'empty' => false
    134134                                        ),
    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'),
    136136                                    ),*/
    137137                                    'width_limit' => array(
     
    143143                                            'empty' => true,
    144144                                        ),
    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'),
    146146                                    ),
    147147                                    'css_override' => array(
     
    153153                                            'empty' => true
    154154                                        ),
    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'),
    156156                                    ),
    157157                                ),
     
    185185                                            'empty' => false
    186186                                        ),
    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'),
    188188                                    ),
    189189                                    'popup_form' => array(
     
    196196                                        ),
    197197                                        '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'),
    199199                                    ),
    200200                                    'popup_delay' => array(
     
    206206                                            'empty' => true,
    207207                                        ),
    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'),
    209209                                    ),
    210210                                    'popup_display_on' => array(
     
    222222                                            '4' => __('Everywhere else', 'pinpointe'),
    223223                                        ),
    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'),
    225226                                    ),
    226227                                ),
     
    237238                                            'empty' => true,
    238239                                        ),
    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'),
    240241                                    ),
    241242                                    'popup_time_limit' => array(
     
    247248                                            'empty' => true,
    248249                                        ),
    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'),
    250252                                    ),
    251253                                    'popup_allow_dismissing' => array(
     
    257259                                            'empty' => false
    258260                                        ),
    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'),
    260262                                    ),
    261263                                    'label_dismiss_popup' => array(
     
    267269                                            'empty' => true
    268270                                        ),
    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'),
    270272                                    ),
    271273                                ),
     
    292294                                            '2' => __('Pages', 'pinpointe'),
    293295                                        ),
    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'),
    295297                                    ),
    296298                                    'after_posts_allowed_forms' => array(
     
    303305                                        ),
    304306                                        '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'),
    306308                                    ),
    307309                                ),
     
    324326                                            'empty' => false
    325327                                        ),
    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'),
    327329                                    ),
    328330                                    'lock_form' => array(
     
    335337                                        ),
    336338                                        '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'),
    338340                                    ),
    339341                                    'lock_title' => array(
     
    345347                                            'empty' => true
    346348                                        ),
    347                                         'hint' => __('<p>Title to display above signup form.</p>', 'pinpointe'),
     349                                        'hint' => esc_html__('<p>Title to display above signup form.</p>', 'pinpointe'),
    348350                                    ),
    349351                                    'lock_message' => array(
     
    355357                                            'empty' => true
    356358                                        ),
    357                                         'hint' => __('<p>Message to display above signup form.</p>', 'pinpointe'),
     359                                        'hint' => esc_html__('<p>Message to display above signup form.</p>', 'pinpointe'),
    358360                                    ),
    359361                                ),
     
    380382                                            '2' => __('Comments Form', 'pinpointe'),
    381383                                        ),
    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'),
    383385                                    ),
    384386                                    'checkbox_label' => array(
     
    390392                                            'empty' => true
    391393                                        ),
    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'),
    393395                                    ),
    394396                                    'checkbox_state' => array(
     
    404406                                            '1' => __('Checked', 'pinpointe'),
    405407                                        ),
    406                                         'hint' => __('<p>Default checkbox state.</p>', 'pinpointe'),
     408                                        'hint' => esc_html__('<p>Default checkbox state.</p>', 'pinpointe'),
    407409                                    ),
    408410                                    'checkbox_list' => array(
     
    414416                                            'empty' => true
    415417                                        ),
    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'),
    417419                                    ),
    418420                                ),
     
    436438                                        ),
    437439                                        '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'),
    439441                                    ),
    440442                                    'sync_list' => array(
     
    446448                                            'empty' => true
    447449                                        ),
    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'),
    449451                                    ),
    450452                                ),
  • pinpointe-form-integration/trunk/includes/pinpointe-prepare-form.inc.php

    r1558838 r3065401  
    1717        $global_form_id = $pinpointe->get_next_rendered_form_id();
    1818
     19        //get mailing lists
     20        $mailing_lists = $pinpointe->get_tag_metadata();
     21
     22        $mailing_list_settings = [];
     23       
    1924        // Extract form id and form settings
    2025        reset($form);
     
    2227        $form = array_pop($form);
    2328
     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       
    2436        // Title
    2537        $title = ($context == 'widget') ? apply_filters('widget_title', $form['title']) : $form['title'];
     
    415427        }
    416428
     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
    417447        // Text below form
    418448        if (isset($form['below']) && $form['below'] != '') {
  • pinpointe-form-integration/trunk/includes/pinpointe-service.class.php

    r2547924 r3065401  
    9595            );
    9696
    97             $xml = $this->arrayToXml($request, '<xmlrequest />');
    98 
    99             // We have to use DOMDocument now to prevent self closing XML tags since the
    100             // 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 
    11397            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);
    117123            $responseBody = @curl_exec($this->curl);
    118124
     
    121127            }
    122128
    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);
    128136            }
    129137            else {
     
    148156                if (is_array($value)) {
    149157                    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                        }
    153166                    } else {
    154167                        foreach ($value as $k => $v) {
     
    237250
    238251            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;
    242256
    243257                $mergeVars = [
     
    250264
    251265                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                    }
    253272
    254273                    $mergeVars[$mergeVar['fieldid']] = [
     
    260279                    if($mergeVar['fieldtype'] == 'dropdown' || $mergeVar['fieldtype'] == 'checkbox' || $mergeVar['fieldtype'] == 'radiobutton') {
    261280                        $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                            }
    264285                        }
    265286
     
    284305         */
    285306        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
    287322            return unserialize($string);
    288323        }
     
    298333         */
    299334        public function lists_subscribe($id, $email, $merge_vars = array(), $email_type = 'html',
    300                                         $add_to_autoresponders = false, $update_existing = false, $tagid, $send_confirmation) {
     335                                        $add_to_autoresponders = false, $update_existing = false, $tag_ids, $send_confirmation = false, $custom_data = []) {
    301336            if(!is_string($email)) {
    302337                $email = $email['email'];
     
    310345            );
    311346
    312             if (!empty($tagid))
    313                 $data['tag'] = $tagid;
     347            if (!empty($tag_ids))
     348                $data['tags'] = $tag_ids;
    314349
    315350            if ($send_confirmation) {
    316351                $data['confirmed'] = 'no';
    317352                $data['send_confirmation'] = 'true';
     353            }
     354
     355            if(!empty($custom_data['html_confirmation_email'])){
     356                $data['html_confirmation_email'] = $custom_data['html_confirmation_email'];
    318357            }
    319358
  • pinpointe-form-integration/trunk/includes/pinpointe-widget.class.php

    r1340221 r3065401  
    1111    class Pinpointe_Widget extends WP_Widget
    1212    {
     13        public $opt;
     14        public $settings;
     15       
    1316        /**
    1417         * Widget constructor (registering widget with WP)
     
    8992            $form_html = pinpointe_prepare_form($form, $this->opt, 'widget', $args);
    9093
    91             echo $form_html;
     94            echo wp_kses_post($form_html);
    9295        }
    9396
     
    107110
    108111            <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'))); ?>
    110113            </p>
    111114            <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); ?>" />
    114117            </p>
    115118
     
    130133
    131134            // 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']) : '';
    133136
    134137            if ($instance['allowed_forms'] != '' && preg_match('/^([0-9]+,?)+$/', $instance['allowed_forms'])) {
  • pinpointe-form-integration/trunk/pinpointe-signup-form.php

    r2547924 r3065401  
    55 * Plugin URI: https://help.pinpointe.com/support/solutions/articles/5000664320-wordpress-plugin-download
    66 * Description: Add Pinpointe forms to your WordPress site
    7  * Version: 1.5
     7 * Version: 1.6
    88 * Author: Pinpointe
    99 * Author URI: http://www.pinpointe.com/
    1010 * Requires at least: 3.5
    11  * Tested up to: 5.7.2
     11 * Tested up to: 6.4.2
    1212 *
    1313 * Text Domain: pinpointe
     
    2727define('PINPOINTE_PLUGIN_PATH', untrailingslashit(plugin_dir_path(__FILE__)));
    2828define('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 reload
     29define('PINPOINTE_VERSION', '2.2.1'); // Increment this to force cached JS to reload
    3030
    3131if (!class_exists('PinpointeSignupForm')) {
     
    4343        private $popup_page_capping_in_effect = false;
    4444
     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
    4557        /**
    4658         * Singleton control
     
    88100
    89101                    // 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'])) {
    91103                        add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts_and_styles'));
    92                     }
     104                     }
    93105                }
    94106
     
    133145             * For all
    134146             */
    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
    136155            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'));
    137160            register_uninstall_hook(__FILE__, array('PinpointeSignupForm', 'uninstall'));
     161
     162            // validate the short codes before we do anything else
     163            $this->validate_all_shortcodes();
    138164
    139165            /**
     
    150176            add_action('wp_ajax_nopriv_pinpointe_subscribe', array($this, 'ajax_subscribe'));
    151177
     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            }
    152217        }
    153218
     
    417482                foreach ($page_value['children'] as $subpage => $subpage_value) {
    418483                    $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'] != '' ? '&nbsp;' : '') : '').$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'] != '' ? '&nbsp;' : '')
     487                            : '') .$subpage_value['title'];
     488                    echo '<a class="nav-tab'.esc_attr($class).'" href="'. esc_url($href).'">'.wp_kses_post($link_value)
     489                        .'</a>';
    420490                }
    421491            }
     
    497567                        <div class="pinpointe-left">
    498568                            <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); ?>" />
    500570
    501571
     
    507577
    508578                                    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>';
    510580                                    }
    511581                                    else if ($current_tab == 'help') {
     
    541611
    542612                        $pinpointe_selected_tags[$form_key] = array(
    543                             'tag'       => $form['tag']
     613                            'tags'       => $form['tags']
    544614                        );
    545615                    }
     
    554624                 */
    555625                $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'),
    572642                );
    573643
     
    577647                    var pinpointe_hints = <?php echo json_encode($this->hints); ?>;
    578648                    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'); ?>';
    608682                    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'); ?>';
    611685
    612686                    <?php if ($current_tab == 'forms'): ?>
     
    616690
    617691                    <?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'] : ''); ?>';
    619693                    <?php endif; ?>
    620694
    621695                    <?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'] : ''); ?>';
    623697                    <?php endif; ?>
    624698
     
    637711        {
    638712            if (isset($this->section_info[$section['id']])) {
    639                 echo $this->section_info[$section['id']];
     713                echo esc_html($this->section_info[$section['id']]);
    640714            }
    641715
     
    645719                    ?>
    646720                    <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>
    648722                    </div>
    649723                    <?php
     
    853927                            );
    854928                            $pinpointe_selected_tags[$form_key] = array(
    855                                 'tag'       => $form['tag']
     929                                'tags'       => $form['tags']
    856930                            );
    857931                        }
     
    878952                        $pinpointe_selected_tags = array();
    879953                    }
    880 
     954                    ob_start();
     955                    require PINPOINTE_PLUGIN_PATH . '/includes/pinpointe-confirmation-email.inc.php';
     956                    $default_confirmation_email_html = ob_get_clean();
    881957                    ?>
    882958
     
    886962                        <?php foreach ($saved_forms as $form_key => $form): ?>
    887963
    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>&nbsp;<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>&nbsp;<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>
    890966                                <div style="clear:both;">
    891967
    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>
    893969                                    <table class="form-table"><tbody>
    894970                                        <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>
    897973                                        </tr>
    898974                                        <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>
    901977                                        </tr>
    902978                                        <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>
    905981                                        </tr>
    906982                                        <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>
    909985                                        </tr>
    910986                                        <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">
    913989
    914990                                                <?php
    915991                                                    foreach ($color_schemes as $scheme_value => $scheme_title) {
    916992                                                        $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>';
    918994                                                    }
    919995                                                ?>
     
    922998                                        </tr>
    923999                                        <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>
    9261002                                        </tr>
    9271003                                        <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>
    9291005                                            <td>
    9301006                                                <?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" : '') . '>';
    9321008                                                ?>
    9331009                                            </td>
    9341010                                        </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>
    9351036                                    </tbody></table>
    9361037
    9371038                                    <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">
    9391040                                        <span class="pinpointe_loading_icon"></span>
    940                                         <?php _e('Connecting to Pinpointe...', 'pinpointe'); ?>
     1041                                        <?php esc_html_e('Connecting to Pinpointe...', 'pinpointe'); ?>
    9411042                                    </p>
    9421043
    9431044                                    <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">
    9451047                                        <span class="pinpointe_loading_icon"></span>
    946                                         <?php _e('Connecting to Pinpointe...', 'pinpointe'); ?>
     1048                                        <?php esc_html_e('Connecting to Pinpointe...', 'pinpointe'); ?>
    9471049                                    </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>
    9481063
    9491064                                    <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">
    9511066                                        <span class="pinpointe_loading_icon"></span>
    952                                         <?php _e('Connecting to Pinpointe...', 'pinpointe'); ?>
     1067                                        <?php esc_html_e('Connecting to Pinpointe...', 'pinpointe'); ?>
    9531068                                    </p>
    9541069
     
    9561071                                    <table class="form-table"><tbody>
    9571072                                        <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">
    9601075
    9611076                                                <?php
    9621077                                                foreach ($condition_options as $cond_cat) {
    963                                                     echo '<optgroup label="' . $cond_cat['title'] . '">';
     1078                                                    echo '<optgroup label="' . esc_attr($cond_cat['title']) . '">';
    9641079
    9651080                                                    foreach ($cond_cat['children'] as $cond_value => $cond_title) {
    9661081                                                        $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>';
    9681083                                                    }
    9691084
     
    9751090                                        </tr>
    9761091                                        <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">
    9791094
    9801095                                                <?php
    9811096                                                    foreach ($pages as $key => $name) {
    9821097                                                        $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>';
    9841099                                                    }
    9851100                                                ?>
     
    9881103                                        </tr>
    9891104                                        <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">
    9921107
    9931108                                                <?php
    9941109                                                    foreach ($posts as $key => $name) {
    9951110                                                        $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>';
    9971112                                                    }
    9981113                                                ?>
     
    10011116                                        </tr>
    10021117                                        <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">
    10051120
    10061121                                                <?php
    10071122                                                    foreach ($post_categories as $key => $name) {
    10081123                                                        $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>';
    10101125                                                    }
    10111126                                                ?>
     
    10141129                                        </tr>
    10151130                                        <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>
    10181134                                        </tr>
    10191135                                    </tbody></table>
     
    10271143                        </div>
    10281144                        <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">&nbsp;&nbsp;<?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">&nbsp;&nbsp;<?php esc_html_e('Add Form', 'pinpointe'); ?></i></button>
    10301146                            <div style="clear: both;"></div>
    10311147                        </div>
     
    10381154            else if ($section['id'] == 'help_display') {
    10391155                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')
    10411157                   . '</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')))
    10441160                   . '</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')
    10471163                   . '</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')
    10501166                   . '</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')))
    10531169                   . '</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')))
    10561172                   . '</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')))
    10591175                   . '</p></div>';
    10601176            }
    10611177            else if ($section['id'] == 'help_contact') {
    10621178                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]')
    10641180                   . '</p><p>'
    10651181                   . '</p></div>';
     
    10791195            printf(
    10801196                '<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']])
    10841200            );
    10851201        }
     
    10961212            printf(
    10971213                '<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']])
    11011217            );
    11021218        }
     
    11131229            printf(
    11141230                '<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']),
    11171233                checked($args['options'][$args['name']], true, false)
    11181234            );
     
    11421258                printf(
    11431259                    '<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),
    11481264                    checked($is_checked, true, false)
    11491265                );
    11501266
    1151                 echo $name . '</li>';
     1267                echo esc_html($name) . '</li>';
    11521268            }
    11531269
     
    11661282            printf(
    11671283                '<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']),
    11701286            );
    11711287
     
    11731289                printf(
    11741290                    '<option value="%s" %s>%s</option>',
    1175                     $key,
     1291                    esc_attr($key),
    11761292                    selected($key, $args['options'][$args['name']], false),
    1177                     $name
     1293                    esc_html($name)
    11781294                );
    11791295            }
     
    11931309            printf(
    11941310                '<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'])
    11971313            );
    11981314
     
    12001316                printf(
    12011317                    '<option value="%s" %s>%s</option>',
    1202                     $key,
     1318                    esc_attr($key),
    12031319                    (in_array($key, $args['options'][$args['name']]) ? 'selected="selected"' : ''),
    1204                     $name
     1320                    esc_html($name)
    12051321                );
    12061322            }
     
    12201336            printf(
    12211337                '<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']])
    12251341            );
    12261342        }
     
    12721388                        $new_forms[$form_number]['send_confirmation'] = (isset($form['send_confirmation']) && !empty($form['send_confirmation'])) ? $form['send_confirmation']: '';
    12731389
     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
    12741405                        // List
    12751406                        $new_forms[$form_number]['list'] = (isset($form['list_field']) && !empty($form['list_field'])) ? $form['list_field']: '';
    12761407
    12771408                        // 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']);
    12791415
    12801416                        // Groups
     
    13961532                    }
    13971533                }
    1398 
    13991534                $output['forms'] = $new_forms;
    14001535            }
     
    14361571                        // Validate boolean values (actually 1 and 0)
    14371572                        case 'bool':
    1438                             $input[$field] = $input[$field] == '' ? '0' : $input[$field];
     1573                            $input[$field] = !isset($input[$field]) || $input[$field] == '' ? '0' : $input[$field];
    14391574                            if (in_array($input[$field], array('0', '1')) || ($input[$field] == '' && $allow_empty)) {
    14401575                                $output[$field] = $input[$field];
     
    15011636                            }
    15021637                            else {
    1503                                 if (is_array($input[$field]) && !empty($input[$field])) {
     1638                                if (isset($input[$field]) && is_array($input[$field]) && !empty($input[$field])) {
    15041639                                    $temporary_output = array();
    15051640
     
    16111746            // Display errors
    16121747            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                );
    16221765            }
    16231766
     
    16251768        }
    16261769
     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        }
    16271888        /**
    16281889         * Custom validation for service provider API key
     
    18762137            // Check if we have something pre-selected
    18772138            if (!empty($data)) {
    1878                 // Get merge vars
    1879                 $merge = $this->get_merge_vars($lists);
    18802139
    18812140                $lists_to_get = array();
     
    18852144                    $lists_to_get[] = $form['list'];
    18862145                }
    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)));
    18922154            die();
    18932155        }
     
    19702232                }
    19712233
    1972                 $results = array('' => '');
     2234                $results = [];
    19732235
    19742236                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               
    19762248                }
    19772249
     
    21212393            // Check if we have received required data
    21222394            if (isset($_POST['data']) && isset($_POST['data']['list'])) {
    2123                 $groups = $this->get_groups($_POST['data']['list']);
    21242395                $merge_vars = $this->get_merge_vars(array($_POST['data']['list'] => ''));
    21252396            }
    21262397            else {
    2127                 $groups = array('' => '');
    21282398                $merge_vars = array('' => '');
    21292399            }
    21302400
    2131             echo json_encode(array('message' => array('groups' => $groups, 'merge' => $merge_vars)));
     2401            echo json_encode(array('message' => array('groups' => ['' => ''], 'merge' => $merge_vars)));
    21322402            die();
    21332403        }
     
    22482518        {
    22492519            if (!$this->load_pinpointe()) {
    2250                 $message = '<h4 style="margin:0px;"><i class="fa fa-check" style="font-size: 1.5em; color: green;"></i>&nbsp;&nbsp;&nbsp;' . __('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>&nbsp;&nbsp;&nbsp;' . __('Pinpointe credentials could not be set', 'pinpointe') . '</h4>';
    22512521            }
    22522522            else if ( ($msg = $this->test_pinpointe()) !== true) {
     
    25882858            require_once PINPOINTE_PLUGIN_PATH . '/includes/pinpointe-prepare-form.inc.php';
    25892859
    2590             $form_html = pinpointe_prepare_form($form, $this->opt, 'after_posts', $args);
     2860            $form_html = pinpointe_prepare_form($form, $this->opt, 'after_posts');
    25912861
    25922862            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%%';
    25932911        }
    25942912
     
    26582976         * @return mixed
    26592977         */
    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 = [] )
    26612979        {
    26622980            // Load Pinpointe
     
    27143032                    $this->opt['pinpointe_add_to_autoresponders'],
    27153033                    $this->opt['pinpointe_update_existing'],
    2716                     $tag_id,
    2717                     $send_confirmation
     3034                    $tags,
     3035                    $send_confirmation,
     3036                    $custom_data
    27183037                );
    27193038
     
    29653284                        $date_format = self::get_date_pattern('date', $this->opt['pinpointe_date_format'], 'date_format');
    29663285
    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']]);
    29693295
    29703296                        if (!$date_parsed) {
     
    30493375            }
    30503376
     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'];
    30513382            // 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
    30533394
    30543395            if (is_bool($subscribe_result)) {
     
    37854126                            setTimeout(function() {
    37864127                                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); ?>);
    37884129                        }
    37894130
     
    37944135                            }
    37954136
    3796                             form = jQuery('#pinpointe_popup_<?php echo $prepared_form_id; ?>');
     4137                            form = jQuery('#pinpointe_popup_<?php echo esc_attr($prepared_form_id); ?>');
    37974138
    37984139                            jQuery('#sky-form-modal-overlay').fadeIn();
     
    38144155
    38154156                            <?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']); ?>;
    38174158                                pinpointe_write_cookie('pinpointe_t', '1', minutes);
    38184159                            <?php endif; ?>
     
    38404181            <?php
    38414182
    3842             echo $form_html;
     4183            echo wp_kses_post($form_html);
    38434184        }
    38444185
     
    39364277        public function render_checkbox($context)
    39374278        {
    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>';
    39394280        }
    39404281
     
    39824323
    39834324            // Role
    3984             $merge['ROLE'] = array_shift(array_values($user->roles));
     4325            $array = array_values($user->roles);
     4326            $merge['ROLE'] = array_shift($array);
    39854327
    39864328            // User name
     
    40734415
    40744416            // Role
    4075             $merge['ROLE'] = array_shift(array_values($user->roles));
     4417            $array = array_values($user->roles);
     4418            $merge['ROLE'] = array_shift($array);
    40764419
    40774420            // User name
     
    41594502
    41604503            // 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);
    41634508
    41644509            if ($role != $role_old) {
  • pinpointe-form-integration/trunk/readme.txt

    r2547924 r3065401  
    33Tags: email marketing, forms, popups, opt-in, mailing list, subscription
    44Requires at least: 3.5
    5 Tested up to: 5.7
     5Tested up to: 6.4.2
    66Stable tag: 1.5
    77Requires PHP: 5.4
     
    4949
    5050== Changelog ==
     511.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
    51571.5
    5258* 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.