WooCommerce Checkout Field Editor (Manager) Pro - Version 1.4.9

Version Description

  • Added security improvements.
  • Added compatibility with PHP 8 version.
  • Added WooCommerce version - 5.6.0 compatibility.
  • Added WordPress version - 5.8 compatibility.
Download this release

Release Info

Developer ThemeHigh
Plugin Icon 128x128 WooCommerce Checkout Field Editor (Manager) Pro
Version 1.4.9
Comparing to
See all releases

Code changes from version 1.4.8 to 1.4.9

admin/assets/js/thwcfd-admin.js CHANGED
@@ -419,6 +419,7 @@ var thwcfd_settings_field = (function($, window, document) {
419
  var FIELDS_TO_HIDE = {
420
  radio : ['placeholder', 'validate'],
421
  select : ['validate'],
 
422
  };
423
 
424
  function open_new_field_form(sname){
@@ -544,7 +545,7 @@ var thwcfd_settings_field = (function($, window, document) {
544
  var type = field['type'];
545
  var value = props && props[name] ? props[name] : '';
546
 
547
- if(ftype == 'textarea' && name == 'value'){
548
  type = "textarea";
549
  }
550
 
@@ -679,6 +680,9 @@ var thwcfd_settings_field = (function($, window, document) {
679
  var ftype = thwcfd_base.get_property_field_value(form, 'select', 'type');
680
  var ftitle = thwcfd_base.get_property_field_value(form, 'text', 'label');
681
  var fotype = thwcfd_base.get_property_field_value(form, 'hidden', 'otype');
 
 
 
682
 
683
  if(ftype == '' && ($.inArray(fotype, SPECIAL_FIELD_TYPES) == -1) ){
684
  err_msgs = 'Type is required';
@@ -690,6 +694,12 @@ var thwcfd_settings_field = (function($, window, document) {
690
  err_msgs = MSG_INVALID_NAME;
691
  }
692
 
 
 
 
 
 
 
693
  if(err_msgs != ''){
694
  form.find('.err_msgs').html(err_msgs);
695
  thwcfd_base.form_wizard_start(popup);
@@ -855,7 +865,7 @@ var thwcfd_settings = (function($, window, document) {
855
  var nonce = wrapper.data("nonce");
856
  var action = wrapper.data("action");
857
  var data = {
858
- security: nonce,
859
  action: action,
860
  };
861
  $.post( ajaxurl, data, function() {
@@ -867,7 +877,14 @@ var thwcfd_settings = (function($, window, document) {
867
  setTimeout(function(){
868
  $("#thwcfd_review_request_notice").fadeIn(500);
869
  }, 2000);
870
- });
 
 
 
 
 
 
 
871
 
872
  function select_all_fields(elm){
873
  var checkAll = $(elm).prop('checked');
@@ -907,7 +924,7 @@ var thwcfd_settings = (function($, window, document) {
907
  var wrapper = $(elm).closest('div.thpladmin-notice');
908
  var nonce = wrapper.data("nonce");
909
  var data = {
910
- security: nonce,
911
  action: 'skip_thwcfd_review_request_notice',
912
  };
913
  $.post( ajaxurl, data, function() {
419
  var FIELDS_TO_HIDE = {
420
  radio : ['placeholder', 'validate'],
421
  select : ['validate'],
422
+ password: ['default'],
423
  };
424
 
425
  function open_new_field_form(sname){
545
  var type = field['type'];
546
  var value = props && props[name] ? props[name] : '';
547
 
548
+ if(ftype == 'textarea' && name == 'default'){
549
  type = "textarea";
550
  }
551
 
680
  var ftype = thwcfd_base.get_property_field_value(form, 'select', 'type');
681
  var ftitle = thwcfd_base.get_property_field_value(form, 'text', 'label');
682
  var fotype = thwcfd_base.get_property_field_value(form, 'hidden', 'otype');
683
+ var fvalue = thwcfd_base.get_property_field_value(form, 'text', 'default');
684
+ var option_values = form.find("input[name='i_options_key[]']").map(function(){ return $(this).val(); }).get();
685
+
686
 
687
  if(ftype == '' && ($.inArray(fotype, SPECIAL_FIELD_TYPES) == -1) ){
688
  err_msgs = 'Type is required';
694
  err_msgs = MSG_INVALID_NAME;
695
  }
696
 
697
+ if(option_values.length>0 && fvalue !='' && (ftype == 'select' || ftype == 'radio') ){
698
+ if(!(option_values.includes(fvalue))){
699
+ err_msgs = 'Only default value that given as an option value is allowed';
700
+ }
701
+ }
702
+
703
  if(err_msgs != ''){
704
  form.find('.err_msgs').html(err_msgs);
705
  thwcfd_base.form_wizard_start(popup);
865
  var nonce = wrapper.data("nonce");
866
  var action = wrapper.data("action");
867
  var data = {
868
+ thwcfd_security_review_notice: nonce,
869
  action: action,
870
  };
871
  $.post( ajaxurl, data, function() {
877
  setTimeout(function(){
878
  $("#thwcfd_review_request_notice").fadeIn(500);
879
  }, 2000);
880
+ });
881
+
882
+ $(document).keypress(function(e) {
883
+ if ($("#thwcfd_field_form_pp").is(':visible') && (e.keycode == 13 || e.which == 13)) {
884
+ e.preventDefault();
885
+ thwcfdSaveField(this);
886
+ }
887
+ });
888
 
889
  function select_all_fields(elm){
890
  var checkAll = $(elm).prop('checked');
924
  var wrapper = $(elm).closest('div.thpladmin-notice');
925
  var nonce = wrapper.data("nonce");
926
  var data = {
927
+ thwcfd_security_review_notice: nonce,
928
  action: 'skip_thwcfd_review_request_notice',
929
  };
930
  $.post( ajaxurl, data, function() {
admin/assets/js/thwcfd-admin.min.js CHANGED
@@ -1 +1 @@
1
- function thwcfdSetupEnhancedMultiSelectWithValue(elm){thwcfd_base.setupEnhancedMultiSelectWithValue(elm)}function thwcfdSetupSortableTable(parent,elm,left){thwcfd_base.setupSortableTable(parent,elm,left)}function thwcfdCloseModal(elm){thwcfd_base.form_wizard_close(elm)}function thwcfdWizardNext(elm){thwcfd_base.form_wizard_next(elm)}function thwcfdWizardPrevious(elm){thwcfd_base.form_wizard_previous(elm)}function thwcfdOpenNewFieldForm(sectionName){thwcfd_settings_field.openNewFieldForm(sectionName)}function thwcfdOpenEditFieldForm(elm,rowId){thwcfd_settings_field.openEditFieldForm(elm,rowId)}function thwcfdOpenCopyFieldForm(elm,rowId){thwcfd_settings_field.openCopyFieldForm(elm,rowId)}function thwcfdFieldTypeChangeListner(elm){thwcfd_settings_field.fieldTypeChangeListner(elm)}function thwcfdAddNewOptionRow(elm){thwcfd_settings_field.addNewOptionRow(elm)}function thwcfdRemoveOptionRow(elm){thwcfd_settings_field.removeOptionRow(elm)}function thwcfdSaveField(elm){thwcfd_settings_field.save_field(elm)}function thwcfdSelectAllCheckoutFields(elm){thwcfd_settings.selectAllFields(elm)}function thwcfdRemoveSelectedFields(){thwcfd_settings.removeSelectedFields()}function thwcfdEnableSelectedFields(){thwcfd_settings.enableDisableSelectedFields(1)}function thwcfdDisableSelectedFields(){thwcfd_settings.enableDisableSelectedFields(0)}function thwcfdHideReviewRequestNotice(elm){thwcfd_settings.hideReviewRequestNotice(elm)}var thwcfd_base=function($,window,document){"use strict";function escapeHTML(html){var fn=function(tag){return{"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&#34;"}[tag]||tag};return html.replace(/[&<>"]/g,fn)}function decodeHtml(str){if(str&&"string"==typeof str){var map={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#039;":"'"};return str.replace(/&amp;|&lt;|&gt;|&quot;|&#039;/g,function(m){return map[m]})}return str}function isHtmlIdValid(id){return/^[a-z\_]+[a-z0-9\_]*$/.test(id.trim())}function isValidHexColor(value){return!!preg_match("/^#[a-f0-9]{6}$/i",value)}function is_option_field(type){var result=!1;return"select"!=type&&"multiselect"!=type&&"radio"!=type&&"checkboxgroup"!=type||(result=!0),result}function setup_tiptip_tooltips(){var tiptip_args={attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200};$(".tips").tipTip(tiptip_args)}function setup_enhanced_multi_select(parent){parent.find("select.thwcfd-enhanced-multi-select").each(function(){$(this).hasClass("enhanced")||$(this).selectWoo({allowClear:!0,placeholder:$(this).data("placeholder")}).addClass("enhanced")})}function setup_enhanced_multi_select_with_value(parent){parent.find("select.thwcfd-enhanced-multi-select").each(function(){if(!$(this).hasClass("enhanced")){$(this).selectWoo({allowClear:!0,placeholder:$(this).data("placeholder")}).addClass("enhanced");var value=$(this).data("value");value=value.split(","),$(this).val(value),$(this).trigger("change")}})}function setup_color_picker(form){form.find(".thpladmin-colorpick").iris({change:function(event,ui){$(this).parent().find(".thpladmin-colorpickpreview").css({backgroundColor:ui.color.toString()})},hide:!0,border:!0}).click(function(){$(".iris-picker").hide(),$(this).closest("td").find(".iris-picker").show()}),$("body").click(function(){$(".iris-picker").hide()}),$(".thpladmin-colorpick").click(function(event){event.stopPropagation()})}function setup_color_pick_preview(form){form.find(".thpladmin-colorpick").each(function(){$(this).parent().find(".thpladmin-colorpickpreview").css({backgroundColor:this.value})})}function prepare_field_order_indexes(elm){$(elm+" tbody tr").each(function(index,el){$("input.f_order",el).val(parseInt($(el).index(elm+" tbody tr")))})}function setup_sortable_table(parent,elm,left){parent.find(elm+" tbody").sortable({items:"tr",cursor:"move",axis:"y",handle:".sort",scrollSensitivity:40,helper:function(e,ui){return ui.children().each(function(){$(this).width($(this).width())}),ui.css("left",left),ui}}),$(elm+" tbody").on("sortstart",function(event,ui){ui.item.css("background-color","#f6f6f6")}),$(elm+" tbody").on("sortstop",function(event,ui){ui.item.removeAttr("style"),prepare_field_order_indexes(elm)})}function get_property_field_value(form,type,name){var value="";switch(type){case"select":value=form.find("select[name=i_"+name+"]").val(),value=null==value?"":value;break;case"checkbox":value=form.find("input[name=i_"+name+"]").prop("checked"),value=value?1:0;break;case"textarea":value=form.find("textarea[name=i_"+name+"]").val(),value=null==value?"":value;break;default:value=form.find("input[name=i_"+name+"]").val(),value=null==value?"":value}return value}function set_property_field_value(form,type,name,value,multiple){switch(type){case"select":1==multiple?(value="string"==typeof value?value.split(","):value,name+="[]",form.find('select[name="i_'+name+'"]').val(value).trigger("change")):form.find('select[name="i_'+name+'"]').val(value);break;case"checkbox":value=1==value||"yes"==value,form.find("input[name=i_"+name+"]").prop("checked",value);break;case"textarea":value=value?decodeHtml(value):value,form.find("textarea[name=i_"+name+"]").val(value);break;case"colorpicker":var bg_color=value?{backgroundColor:value}:{};form.find("input[name=i_"+name+"]").val(value),form.find("."+name+"_preview").css(bg_color);break;default:value=value?decodeHtml(value):value,form.find("input[name=i_"+name+"]").val(value)}}function setup_form_wizard(){$(".pp_nav_links > li").click(function(){var index=$(this).data("index");open_tab($(this).closest(".thpladmin-modal-mask"),$(this),index),active_tab=index})}function get_popup(elm){return $(elm).closest(".thpladmin-modal-mask")}function get_active_tab(popup){return popup.find("ul.pp_nav_links").find("li.active")}function get_next_tab_index(elm){var popup=get_popup(elm),active=get_active_tab(popup),link=active.nextAll("li").not(".disabled").first();return link.length?link.data("index"):active_tab}function get_prev_tab_index(elm){var popup=get_popup(elm),active=get_active_tab(popup),link=active.prevAll("li").not(".disabled").first();return link.length?link.data("index"):active_tab}function form_wizard_open(popup){active_tab=0,popup.find("ul.pp_nav_links li").first().click(),popup.css("display","block")}function form_wizard_close(elm){get_popup(elm).css("display","none"),active_tab=0}function form_wizard_next(elm){active_tab=get_next_tab_index(elm),move_to(elm,active_tab)}function form_wizard_previous(elm){active_tab=get_prev_tab_index(elm),move_to(elm,active_tab)}function form_wizard_start(elm){active_tab=0,move_to(elm,active_tab)}function move_to(elm,index){var popup=get_popup(elm);open_tab(popup,popup.find('*[data-index="'+index+'"]'),index)}function open_tab(popup,link,index){var panel=popup.find(".data_panel_"+index);close_all_data_panel(popup),link.addClass("active"),panel.css("display","block"),enable_disable_btns(popup,link)}function close_all_data_panel(popup){popup.find(".pp_nav_links > li").removeClass("active"),popup.find(".data-panel").css("display","none")}function enable_disable_tab(popup,index,disable){var link=popup.find('*[data-index="'+index+'"]'),panel=popup.find(".data_panel_"+index);disable?(link.addClass("disabled"),panel.find(":input").attr("disabled",!0)):(link.removeClass("disabled"),panel.find(":input").attr("disabled",!1))}function form_wizard_enable_tab(popup,index){enable_disable_tab(popup,index,0)}function form_wizard_disable_tab(popup,index){enable_disable_tab(popup,index,1)}function form_wizard_enable_all_tabs(popup){popup.find(".pp_nav_links > li").removeClass("disabled")}function enable_disable_btns(popup,link){var nextBtn=popup.find(".next-btn"),prevBtn=popup.find(".prev-btn");link.hasClass("first")?(nextBtn.prop("disabled",!1),prevBtn.prop("disabled",!0)):link.hasClass("last")?(nextBtn.prop("disabled",!0),prevBtn.prop("disabled",!1)):(nextBtn.prop("disabled",!1),prevBtn.prop("disabled",!1))}var active_tab=0;return{escapeHTML:escapeHTML,decodeHtml:decodeHtml,isHtmlIdValid:isHtmlIdValid,isValidHexColor:isValidHexColor,is_option_field:is_option_field,setup_tiptip_tooltips:setup_tiptip_tooltips,setupEnhancedMultiSelect:setup_enhanced_multi_select,setupEnhancedMultiSelectWithValue:setup_enhanced_multi_select_with_value,setupColorPicker:setup_color_picker,setup_color_pick_preview:setup_color_pick_preview,setupSortableTable:setup_sortable_table,get_property_field_value:get_property_field_value,set_property_field_value:set_property_field_value,setup_form_wizard:setup_form_wizard,form_wizard_open:form_wizard_open,form_wizard_close:form_wizard_close,form_wizard_next:form_wizard_next,form_wizard_previous:form_wizard_previous,form_wizard_start:form_wizard_start,form_wizard_enable_tab:form_wizard_enable_tab,form_wizard_disable_tab:form_wizard_disable_tab,form_wizard_enable_all_tabs:form_wizard_enable_all_tabs}}(window.jQuery,window,document),thwcfd_settings_field=function($,window,document){"use strict";function open_new_field_form(sname){open_field_form("new",!1,sname)}function open_edit_field_form(elm,rowId){open_field_form("edit",elm,!1)}function open_copy_field_form(elm,rowId){open_field_form("copy",elm,!1)}function open_field_form(type,elm,sname){var popup=$("#thwcfd_field_form_pp");populate_field_form(popup,$("#thwcfd_field_form"),type,elm,sname),thwcfd_base.form_wizard_open(popup)}function populate_field_form(popup,form,action,elm,sname){var title="edit"===action?"Edit Field":"New Field";if(popup.find(".wizard-title").text(title),form.find(".err_msgs").html(""),form.find("input[name=f_action]").val(action),"new"===action)"billing"!=sname&&"shipping"!=sname&&"additional"!=sname||(sname+="_"),clear_field_form_general(form),form.find("select[name=i_type]").change(),thwcfd_base.set_property_field_value(form,"text","name",sname,0),thwcfd_base.set_property_field_value(form,"text","class","form-row-wide",0);else{var row=$(elm).closest("tr"),props_json=row.find(".f_props").val(),props=JSON.parse(props_json);populate_field_form_general(action,form,props),form.find("select[name=i_type]").change(),populate_field_form_props(form,row,props)}}function clear_field_form_general(form){thwcfd_base.set_property_field_value(form,"hidden","autocomplete","",0),thwcfd_base.set_property_field_value(form,"hidden","priority","",0),thwcfd_base.set_property_field_value(form,"hidden","custom","",0),thwcfd_base.set_property_field_value(form,"hidden","oname","",0),thwcfd_base.set_property_field_value(form,"hidden","otype","",0),thwcfd_base.set_property_field_value(form,"select","type","text",0),thwcfd_base.set_property_field_value(form,"text","name","",0)}function populate_field_form_general(action,form,props){var autocomplete=props.autocomplete?props.autocomplete:"",priority=props.priority?props.priority:"",custom=props.custom?props.custom:"",type=props.type?props.type:"text",name=props.name?props.name:"";"copy"===action&&(name=""),thwcfd_base.set_property_field_value(form,"hidden","autocomplete",autocomplete,0),thwcfd_base.set_property_field_value(form,"hidden","priority",priority,0),thwcfd_base.set_property_field_value(form,"hidden","custom",custom,0),thwcfd_base.set_property_field_value(form,"hidden","oname",name,0),thwcfd_base.set_property_field_value(form,"hidden","otype",type,0),thwcfd_base.set_property_field_value(form,"select","type",type,0),thwcfd_base.set_property_field_value(form,"text","name",name,0)}function populate_field_form_props(form,row,props){var ftype=props.type,custom=props.custom?props.custom:"";$.each(FIELD_FORM_PROPS,function(name,field){if("name"==name||"type"==name)return!0;var type=field.type,value=props&&props[name]?props[name]:"";"textarea"==ftype&&"value"==name&&(type="textarea"),thwcfd_base.set_property_field_value(form,type,name,value,field.multiple),"select"==type?(name=1==field.multiple?name+"[]":name,1!=field.multiple&&1!=field.change||form.find('select[name="i_'+name+'"]').trigger("change")):"checkbox"==type&&1==field.change&&form.find('input[name="i_'+name+'"]').trigger("change")});var optionsJson=row.find(".f_options").val();populate_options_list(form,optionsJson),1==custom?(form.find("input[name=i_name]").prop("disabled",!1),form.find("select[name=i_type]").prop("disabled",!1),form.find("input[name=i_show_in_email]").prop("disabled",!1),form.find("input[name=i_show_in_order]").prop("disabled",!1)):(thwcfd_base.set_property_field_value(form,"checkbox","show_in_email",!0,0),thwcfd_base.set_property_field_value(form,"checkbox","show_in_order",!0,0),form.find("input[name=i_name]").prop("disabled",!0),form.find("select[name=i_type]").prop("disabled",!0),form.find("input[name=i_show_in_email]").prop("disabled",!0),form.find("input[name=i_show_in_order]").prop("disabled",!0),form.find("input[name=i_label]").focus())}function field_type_change_listner(elm){var popup=$("#thwcfd_field_form_pp"),form=$(elm).closest("form"),type=$(elm).val();type=null==type?"text":type,form.find(".thwcfd_field_form_tab_general_placeholder").html($("#thwcfd_field_form_id_"+type).html()),enable_all_tabs_and_fields(popup,form),type in FIELDS_TO_HIDE&&$.each(FIELDS_TO_HIDE[type],function(index,name){if(FIELD_FORM_PROPS[name]){var f_props=FIELD_FORM_PROPS[name];disable_hide_field(form,f_props.type,name)}}),thwcfd_base.setupEnhancedMultiSelect(form),thwcfd_base.setupColorPicker(form),thwcfd_base.setupSortableTable(form,".thwcfd-option-list","100")}function enable_all_tabs_and_fields(popup,form){thwcfd_base.form_wizard_enable_all_tabs(popup),form.find(":input").attr("disabled",!1),form.find("tr").removeClass("disabled hide")}function enable_disable_field(form,type,name,enabled,hide){var elm=null;switch(type){case"select":elm=form.find('select[name="i_'+name+'"]'),0==elm.length&&(elm=form.find('select[name="i_'+name+'[]"]'));break;case"textarea":elm=form.find("textarea[name=i_"+name+"]"),0==elm.length&&(elm=form.find('textarea[name="i_'+name+'[]"]'));break;default:elm=form.find("input[name=i_"+name+"]"),0==elm.length&&(elm=form.find('input[name="i_'+name+'[]"]'))}if(elm&&elm.length){var rowClass=hide?"disabled hide":"disabled";enabled?(elm.attr("disabled",!1),elm.closest("tr.form_field_"+name).removeClass("disabled hide")):(elm.attr("disabled",!0),elm.closest("tr.form_field_"+name).addClass(rowClass))}}function disable_hide_field(form,type,name){enable_disable_field(form,type,name,!1,!0)}function save_field(elm){var popup=$("#thwcfd_field_form_pp"),form=$("#thwcfd_field_form");validate_field_form(form,popup)&&(prepare_field_form(form),form.submit())}function validate_field_form(form,popup){var err_msgs="",fname=thwcfd_base.get_property_field_value(form,"text","name"),ftype=thwcfd_base.get_property_field_value(form,"select","type"),fotype=(thwcfd_base.get_property_field_value(form,"text","label"),thwcfd_base.get_property_field_value(form,"hidden","otype"));return""==ftype&&-1==$.inArray(fotype,SPECIAL_FIELD_TYPES)?err_msgs="Type is required":""==fname?err_msgs="Name is required":thwcfd_base.isHtmlIdValid(fname)||(err_msgs=MSG_INVALID_NAME),""==err_msgs||(form.find(".err_msgs").html(err_msgs),thwcfd_base.form_wizard_start(popup),!1)}function prepare_field_form(form){var options_json=get_options(form);thwcfd_base.set_property_field_value(form,"hidden","options_json",options_json,0)}function get_options(form){for(var optionsKey=form.find("input[name='i_options_key[]']").map(function(){return $(this).val()}).get(),optionsText=form.find("input[name='i_options_text[]']").map(function(){return $(this).val()}).get(),optionsSize=optionsText.length,optionsArr=[],i=0;i<optionsSize;i++){var optionDetails={};optionDetails.key=optionsKey[i],optionDetails.text=optionsText[i],optionsArr.push(optionDetails)}var optionsJson=optionsArr.length>0?JSON.stringify(optionsArr):"";return optionsJson=encodeURIComponent(optionsJson)}function populate_options_list(form,optionsJson){var optionsHtml="";if(optionsJson)try{optionsJson=decodeURIComponent(optionsJson);var optionsList=$.parseJSON(optionsJson);optionsList&&jQuery.each(optionsList,function(){optionsHtml+=prepare_option_row_html(this)})}catch(err){console.log(err)}var optionsTable=form.find(".thwcfd-option-list tbody");optionsHtml?optionsTable.html(optionsHtml):optionsTable.html(prepare_option_row_html(null))}function prepare_option_row_html(option){var key="",text="";option&&(key=option.key?option.key:"",text=option.text?option.text:"");var html="<tr>";return html+='<td class="key"><input type="text" name="i_options_key[]" value="'+key+'" placeholder="Option Value"></td>',html+='<td class="value"><input type="text" name="i_options_text[]" value="'+text+'" placeholder="Option Text"></td>',html+='<td class="action-cell">',html+='<a href="javascript:void(0)" onclick="thwcfdAddNewOptionRow(this)" class="btn btn-tiny btn-primary" title="Add new option">+</a>',html+='<a href="javascript:void(0)" onclick="thwcfdRemoveOptionRow(this)" class="btn btn-tiny btn-danger" title="Remove option">x</a>',html+='<span class="btn btn-tiny sort ui-sortable-handle"></span></td>',html+="</tr>"}function add_new_option_row(elm){var ptable=$(elm).closest("table");ptable.find("tbody tr").size()>0?ptable.find("tbody tr:last").after(prepare_option_row_html(null)):ptable.find("tbody").append(prepare_option_row_html(null))}function remove_option_row(elm){var ptable=$(elm).closest("table");$(elm).closest("tr").remove(),0==ptable.find("tbody tr").size()&&ptable.find("tbody").append(prepare_option_row_html(null))}var MSG_INVALID_NAME='NAME/ID must begin with a lowercase letter ([a-z]) or underscores ("_") and may be followed by any number of lowercase letters, digits ([0-9]) and underscores ("_")',SPECIAL_FIELD_TYPES=["country","state","city"],FIELD_FORM_PROPS={name:{name:"name",type:"text"},type:{name:"type",type:"select"},label:{name:"label",type:"text"},default:{name:"default",type:"text"},placeholder:{name:"placeholder",type:"text"},class:{name:"class",type:"text"},validate:{name:"validate",type:"select",multiple:1},required:{name:"required",type:"checkbox"},enabled:{name:"enabled",type:"checkbox"},show_in_email:{name:"show_in_email",type:"checkbox"},show_in_order:{name:"show_in_order",type:"checkbox"}},FIELDS_TO_HIDE={radio:["placeholder","validate"],select:["validate"]};return{openNewFieldForm:open_new_field_form,openEditFieldForm:open_edit_field_form,openCopyFieldForm:open_copy_field_form,fieldTypeChangeListner:field_type_change_listner,addNewOptionRow:add_new_option_row,removeOptionRow:remove_option_row,save_field:save_field}}(window.jQuery,window,document),thwcfd_settings=function($,window,document){"use strict";function select_all_fields(elm){var checkAll=$(elm).prop("checked");$("#thwcfd_checkout_fields tbody input:checkbox[name=select_field]").prop("checked",checkAll)}function remove_selected_fields(){$("#thwcfd_checkout_fields tbody tr").removeClass("strikeout"),$("#thwcfd_checkout_fields tbody input:checkbox[name=select_field]:checked").each(function(){var row=$(this).closest("tr");row.hasClass("strikeout")||row.addClass("strikeout"),row.find(".f_deleted").val(1)})}function enable_disable_selected_fields(enabled){$("#thwcfd_checkout_fields tbody input:checkbox[name=select_field]:checked").each(function(){var row=$(this).closest("tr");0==enabled?row.hasClass("thpladmin-disabled")||row.addClass("thpladmin-disabled"):row.removeClass("thpladmin-disabled"),row.find(".td_enabled").html(1==enabled?'<span class="dashicons dashicons-yes tips" data-tip="Yes"></span>':"-"),row.find(".f_enabled").val(enabled)})}function hide_review_request_notice(elm){var wrapper=$(elm).closest("div.thpladmin-notice"),nonce=wrapper.data("nonce"),data={security:nonce,action:"skip_thwcfd_review_request_notice"};$.post(ajaxurl,data,function(){}),$(wrapper).hide(50)}return $(function(){var settings_form=$("#thwcfd_checkout_fields_form");thwcfd_base.setupSortableTable(settings_form,"#thwcfd_checkout_fields","0"),thwcfd_base.setup_tiptip_tooltips(),thwcfd_base.setup_form_wizard()}),$(document).on("click",".thpladmin-notice .notice-dismiss",function(){var wrapper=$(this).closest("div.thpladmin-notice"),nonce=wrapper.data("nonce"),action=wrapper.data("action"),data={security:nonce,action:action};$.post(ajaxurl,data,function(){})}),$(document).ready(function(){setTimeout(function(){$("#thwcfd_review_request_notice").fadeIn(500)},2e3)}),{selectAllFields:select_all_fields,removeSelectedFields:remove_selected_fields,enableDisableSelectedFields:enable_disable_selected_fields,hideReviewRequestNotice:hide_review_request_notice}}(window.jQuery,window,document);
1
+ function thwcfdSetupEnhancedMultiSelectWithValue(elm){thwcfd_base.setupEnhancedMultiSelectWithValue(elm)}function thwcfdSetupSortableTable(parent,elm,left){thwcfd_base.setupSortableTable(parent,elm,left)}function thwcfdCloseModal(elm){thwcfd_base.form_wizard_close(elm)}function thwcfdWizardNext(elm){thwcfd_base.form_wizard_next(elm)}function thwcfdWizardPrevious(elm){thwcfd_base.form_wizard_previous(elm)}function thwcfdOpenNewFieldForm(sectionName){thwcfd_settings_field.openNewFieldForm(sectionName)}function thwcfdOpenEditFieldForm(elm,rowId){thwcfd_settings_field.openEditFieldForm(elm,rowId)}function thwcfdOpenCopyFieldForm(elm,rowId){thwcfd_settings_field.openCopyFieldForm(elm,rowId)}function thwcfdFieldTypeChangeListner(elm){thwcfd_settings_field.fieldTypeChangeListner(elm)}function thwcfdAddNewOptionRow(elm){thwcfd_settings_field.addNewOptionRow(elm)}function thwcfdRemoveOptionRow(elm){thwcfd_settings_field.removeOptionRow(elm)}function thwcfdSaveField(elm){thwcfd_settings_field.save_field(elm)}function thwcfdSelectAllCheckoutFields(elm){thwcfd_settings.selectAllFields(elm)}function thwcfdRemoveSelectedFields(){thwcfd_settings.removeSelectedFields()}function thwcfdEnableSelectedFields(){thwcfd_settings.enableDisableSelectedFields(1)}function thwcfdDisableSelectedFields(){thwcfd_settings.enableDisableSelectedFields(0)}function thwcfdHideReviewRequestNotice(elm){thwcfd_settings.hideReviewRequestNotice(elm)}var thwcfd_base=function($,window,document){"use strict";function escapeHTML(html){var fn=function(tag){return{"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&#34;"}[tag]||tag};return html.replace(/[&<>"]/g,fn)}function decodeHtml(str){if(str&&"string"==typeof str){var map={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#039;":"'"};return str.replace(/&amp;|&lt;|&gt;|&quot;|&#039;/g,function(m){return map[m]})}return str}function isHtmlIdValid(id){return/^[a-z\_]+[a-z0-9\_]*$/.test(id.trim())}function isValidHexColor(value){return!!preg_match("/^#[a-f0-9]{6}$/i",value)}function is_option_field(type){var result=!1;return"select"!=type&&"multiselect"!=type&&"radio"!=type&&"checkboxgroup"!=type||(result=!0),result}function setup_tiptip_tooltips(){var tiptip_args={attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200};$(".tips").tipTip(tiptip_args)}function setup_enhanced_multi_select(parent){parent.find("select.thwcfd-enhanced-multi-select").each(function(){$(this).hasClass("enhanced")||$(this).selectWoo({allowClear:!0,placeholder:$(this).data("placeholder")}).addClass("enhanced")})}function setup_enhanced_multi_select_with_value(parent){parent.find("select.thwcfd-enhanced-multi-select").each(function(){if(!$(this).hasClass("enhanced")){$(this).selectWoo({allowClear:!0,placeholder:$(this).data("placeholder")}).addClass("enhanced");var value=$(this).data("value");value=value.split(","),$(this).val(value),$(this).trigger("change")}})}function setup_color_picker(form){form.find(".thpladmin-colorpick").iris({change:function(event,ui){$(this).parent().find(".thpladmin-colorpickpreview").css({backgroundColor:ui.color.toString()})},hide:!0,border:!0}).click(function(){$(".iris-picker").hide(),$(this).closest("td").find(".iris-picker").show()}),$("body").click(function(){$(".iris-picker").hide()}),$(".thpladmin-colorpick").click(function(event){event.stopPropagation()})}function setup_color_pick_preview(form){form.find(".thpladmin-colorpick").each(function(){$(this).parent().find(".thpladmin-colorpickpreview").css({backgroundColor:this.value})})}function prepare_field_order_indexes(elm){$(elm+" tbody tr").each(function(index,el){$("input.f_order",el).val(parseInt($(el).index(elm+" tbody tr")))})}function setup_sortable_table(parent,elm,left){parent.find(elm+" tbody").sortable({items:"tr",cursor:"move",axis:"y",handle:".sort",scrollSensitivity:40,helper:function(e,ui){return ui.children().each(function(){$(this).width($(this).width())}),ui.css("left",left),ui}}),$(elm+" tbody").on("sortstart",function(event,ui){ui.item.css("background-color","#f6f6f6")}),$(elm+" tbody").on("sortstop",function(event,ui){ui.item.removeAttr("style"),prepare_field_order_indexes(elm)})}function get_property_field_value(form,type,name){var value="";switch(type){case"select":value=form.find("select[name=i_"+name+"]").val(),value=null==value?"":value;break;case"checkbox":value=form.find("input[name=i_"+name+"]").prop("checked"),value=value?1:0;break;case"textarea":value=form.find("textarea[name=i_"+name+"]").val(),value=null==value?"":value;break;default:value=form.find("input[name=i_"+name+"]").val(),value=null==value?"":value}return value}function set_property_field_value(form,type,name,value,multiple){switch(type){case"select":1==multiple?(value="string"==typeof value?value.split(","):value,name+="[]",form.find('select[name="i_'+name+'"]').val(value).trigger("change")):form.find('select[name="i_'+name+'"]').val(value);break;case"checkbox":value=1==value||"yes"==value,form.find("input[name=i_"+name+"]").prop("checked",value);break;case"textarea":value=value?decodeHtml(value):value,form.find("textarea[name=i_"+name+"]").val(value);break;case"colorpicker":var bg_color=value?{backgroundColor:value}:{};form.find("input[name=i_"+name+"]").val(value),form.find("."+name+"_preview").css(bg_color);break;default:value=value?decodeHtml(value):value,form.find("input[name=i_"+name+"]").val(value)}}function setup_form_wizard(){$(".pp_nav_links > li").click(function(){var index=$(this).data("index");open_tab($(this).closest(".thpladmin-modal-mask"),$(this),index),active_tab=index})}function get_popup(elm){return $(elm).closest(".thpladmin-modal-mask")}function get_active_tab(popup){return popup.find("ul.pp_nav_links").find("li.active")}function get_next_tab_index(elm){var popup=get_popup(elm),active=get_active_tab(popup),link=active.nextAll("li").not(".disabled").first();return link.length?link.data("index"):active_tab}function get_prev_tab_index(elm){var popup=get_popup(elm),active=get_active_tab(popup),link=active.prevAll("li").not(".disabled").first();return link.length?link.data("index"):active_tab}function form_wizard_open(popup){active_tab=0,popup.find("ul.pp_nav_links li").first().click(),popup.css("display","block")}function form_wizard_close(elm){get_popup(elm).css("display","none"),active_tab=0}function form_wizard_next(elm){active_tab=get_next_tab_index(elm),move_to(elm,active_tab)}function form_wizard_previous(elm){active_tab=get_prev_tab_index(elm),move_to(elm,active_tab)}function form_wizard_start(elm){active_tab=0,move_to(elm,active_tab)}function move_to(elm,index){var popup=get_popup(elm);open_tab(popup,popup.find('*[data-index="'+index+'"]'),index)}function open_tab(popup,link,index){var panel=popup.find(".data_panel_"+index);close_all_data_panel(popup),link.addClass("active"),panel.css("display","block"),enable_disable_btns(popup,link)}function close_all_data_panel(popup){popup.find(".pp_nav_links > li").removeClass("active"),popup.find(".data-panel").css("display","none")}function enable_disable_tab(popup,index,disable){var link=popup.find('*[data-index="'+index+'"]'),panel=popup.find(".data_panel_"+index);disable?(link.addClass("disabled"),panel.find(":input").attr("disabled",!0)):(link.removeClass("disabled"),panel.find(":input").attr("disabled",!1))}function form_wizard_enable_tab(popup,index){enable_disable_tab(popup,index,0)}function form_wizard_disable_tab(popup,index){enable_disable_tab(popup,index,1)}function form_wizard_enable_all_tabs(popup){popup.find(".pp_nav_links > li").removeClass("disabled")}function enable_disable_btns(popup,link){var nextBtn=popup.find(".next-btn"),prevBtn=popup.find(".prev-btn");link.hasClass("first")?(nextBtn.prop("disabled",!1),prevBtn.prop("disabled",!0)):link.hasClass("last")?(nextBtn.prop("disabled",!0),prevBtn.prop("disabled",!1)):(nextBtn.prop("disabled",!1),prevBtn.prop("disabled",!1))}var active_tab=0;return{escapeHTML:escapeHTML,decodeHtml:decodeHtml,isHtmlIdValid:isHtmlIdValid,isValidHexColor:isValidHexColor,is_option_field:is_option_field,setup_tiptip_tooltips:setup_tiptip_tooltips,setupEnhancedMultiSelect:setup_enhanced_multi_select,setupEnhancedMultiSelectWithValue:setup_enhanced_multi_select_with_value,setupColorPicker:setup_color_picker,setup_color_pick_preview:setup_color_pick_preview,setupSortableTable:setup_sortable_table,get_property_field_value:get_property_field_value,set_property_field_value:set_property_field_value,setup_form_wizard:setup_form_wizard,form_wizard_open:form_wizard_open,form_wizard_close:form_wizard_close,form_wizard_next:form_wizard_next,form_wizard_previous:form_wizard_previous,form_wizard_start:form_wizard_start,form_wizard_enable_tab:form_wizard_enable_tab,form_wizard_disable_tab:form_wizard_disable_tab,form_wizard_enable_all_tabs:form_wizard_enable_all_tabs}}(window.jQuery,window,document),thwcfd_settings_field=function($,window,document){"use strict";function open_new_field_form(sname){open_field_form("new",!1,sname)}function open_edit_field_form(elm,rowId){open_field_form("edit",elm,!1)}function open_copy_field_form(elm,rowId){open_field_form("copy",elm,!1)}function open_field_form(type,elm,sname){var popup=$("#thwcfd_field_form_pp");populate_field_form(popup,$("#thwcfd_field_form"),type,elm,sname),thwcfd_base.form_wizard_open(popup)}function populate_field_form(popup,form,action,elm,sname){var title="edit"===action?"Edit Field":"New Field";if(popup.find(".wizard-title").text(title),form.find(".err_msgs").html(""),form.find("input[name=f_action]").val(action),"new"===action)"billing"!=sname&&"shipping"!=sname&&"additional"!=sname||(sname+="_"),clear_field_form_general(form),form.find("select[name=i_type]").change(),thwcfd_base.set_property_field_value(form,"text","name",sname,0),thwcfd_base.set_property_field_value(form,"text","class","form-row-wide",0);else{var row=$(elm).closest("tr"),props_json=row.find(".f_props").val(),props=JSON.parse(props_json);populate_field_form_general(action,form,props),form.find("select[name=i_type]").change(),populate_field_form_props(form,row,props)}}function clear_field_form_general(form){thwcfd_base.set_property_field_value(form,"hidden","autocomplete","",0),thwcfd_base.set_property_field_value(form,"hidden","priority","",0),thwcfd_base.set_property_field_value(form,"hidden","custom","",0),thwcfd_base.set_property_field_value(form,"hidden","oname","",0),thwcfd_base.set_property_field_value(form,"hidden","otype","",0),thwcfd_base.set_property_field_value(form,"select","type","text",0),thwcfd_base.set_property_field_value(form,"text","name","",0)}function populate_field_form_general(action,form,props){var autocomplete=props.autocomplete?props.autocomplete:"",priority=props.priority?props.priority:"",custom=props.custom?props.custom:"",type=props.type?props.type:"text",name=props.name?props.name:"";"copy"===action&&(name=""),thwcfd_base.set_property_field_value(form,"hidden","autocomplete",autocomplete,0),thwcfd_base.set_property_field_value(form,"hidden","priority",priority,0),thwcfd_base.set_property_field_value(form,"hidden","custom",custom,0),thwcfd_base.set_property_field_value(form,"hidden","oname",name,0),thwcfd_base.set_property_field_value(form,"hidden","otype",type,0),thwcfd_base.set_property_field_value(form,"select","type",type,0),thwcfd_base.set_property_field_value(form,"text","name",name,0)}function populate_field_form_props(form,row,props){var ftype=props.type,custom=props.custom?props.custom:"";$.each(FIELD_FORM_PROPS,function(name,field){if("name"==name||"type"==name)return!0;var type=field.type,value=props&&props[name]?props[name]:"";"textarea"==ftype&&"default"==name&&(type="textarea"),thwcfd_base.set_property_field_value(form,type,name,value,field.multiple),"select"==type?(name=1==field.multiple?name+"[]":name,1!=field.multiple&&1!=field.change||form.find('select[name="i_'+name+'"]').trigger("change")):"checkbox"==type&&1==field.change&&form.find('input[name="i_'+name+'"]').trigger("change")});var optionsJson=row.find(".f_options").val();populate_options_list(form,optionsJson),1==custom?(form.find("input[name=i_name]").prop("disabled",!1),form.find("select[name=i_type]").prop("disabled",!1),form.find("input[name=i_show_in_email]").prop("disabled",!1),form.find("input[name=i_show_in_order]").prop("disabled",!1)):(thwcfd_base.set_property_field_value(form,"checkbox","show_in_email",!0,0),thwcfd_base.set_property_field_value(form,"checkbox","show_in_order",!0,0),form.find("input[name=i_name]").prop("disabled",!0),form.find("select[name=i_type]").prop("disabled",!0),form.find("input[name=i_show_in_email]").prop("disabled",!0),form.find("input[name=i_show_in_order]").prop("disabled",!0),form.find("input[name=i_label]").focus())}function field_type_change_listner(elm){var popup=$("#thwcfd_field_form_pp"),form=$(elm).closest("form"),type=$(elm).val();type=null==type?"text":type,form.find(".thwcfd_field_form_tab_general_placeholder").html($("#thwcfd_field_form_id_"+type).html()),enable_all_tabs_and_fields(popup,form),type in FIELDS_TO_HIDE&&$.each(FIELDS_TO_HIDE[type],function(index,name){if(FIELD_FORM_PROPS[name]){var f_props=FIELD_FORM_PROPS[name];disable_hide_field(form,f_props.type,name)}}),thwcfd_base.setupEnhancedMultiSelect(form),thwcfd_base.setupColorPicker(form),thwcfd_base.setupSortableTable(form,".thwcfd-option-list","100")}function enable_all_tabs_and_fields(popup,form){thwcfd_base.form_wizard_enable_all_tabs(popup),form.find(":input").attr("disabled",!1),form.find("tr").removeClass("disabled hide")}function enable_disable_field(form,type,name,enabled,hide){var elm=null;switch(type){case"select":elm=form.find('select[name="i_'+name+'"]'),0==elm.length&&(elm=form.find('select[name="i_'+name+'[]"]'));break;case"textarea":elm=form.find("textarea[name=i_"+name+"]"),0==elm.length&&(elm=form.find('textarea[name="i_'+name+'[]"]'));break;default:elm=form.find("input[name=i_"+name+"]"),0==elm.length&&(elm=form.find('input[name="i_'+name+'[]"]'))}if(elm&&elm.length){var rowClass=hide?"disabled hide":"disabled";enabled?(elm.attr("disabled",!1),elm.closest("tr.form_field_"+name).removeClass("disabled hide")):(elm.attr("disabled",!0),elm.closest("tr.form_field_"+name).addClass(rowClass))}}function disable_hide_field(form,type,name){enable_disable_field(form,type,name,!1,!0)}function save_field(elm){var popup=$("#thwcfd_field_form_pp"),form=$("#thwcfd_field_form");validate_field_form(form,popup)&&(prepare_field_form(form),form.submit())}function validate_field_form(form,popup){var err_msgs="",fname=thwcfd_base.get_property_field_value(form,"text","name"),ftype=thwcfd_base.get_property_field_value(form,"select","type"),fotype=(thwcfd_base.get_property_field_value(form,"text","label"),thwcfd_base.get_property_field_value(form,"hidden","otype")),fvalue=thwcfd_base.get_property_field_value(form,"text","default"),option_values=form.find("input[name='i_options_key[]']").map(function(){return $(this).val()}).get();return""==ftype&&-1==$.inArray(fotype,SPECIAL_FIELD_TYPES)?err_msgs="Type is required":""==fname?err_msgs="Name is required":thwcfd_base.isHtmlIdValid(fname)||(err_msgs=MSG_INVALID_NAME),option_values.length>0&&""!=fvalue&&("select"==ftype||"radio"==ftype)&&(option_values.includes(fvalue)||(err_msgs="Only default value that given as an option value is allowed")),""==err_msgs||(form.find(".err_msgs").html(err_msgs),thwcfd_base.form_wizard_start(popup),!1)}function prepare_field_form(form){var options_json=get_options(form);thwcfd_base.set_property_field_value(form,"hidden","options_json",options_json,0)}function get_options(form){for(var optionsKey=form.find("input[name='i_options_key[]']").map(function(){return $(this).val()}).get(),optionsText=form.find("input[name='i_options_text[]']").map(function(){return $(this).val()}).get(),optionsSize=optionsText.length,optionsArr=[],i=0;i<optionsSize;i++){var optionDetails={};optionDetails.key=optionsKey[i],optionDetails.text=optionsText[i],optionsArr.push(optionDetails)}var optionsJson=optionsArr.length>0?JSON.stringify(optionsArr):"";return optionsJson=encodeURIComponent(optionsJson)}function populate_options_list(form,optionsJson){var optionsHtml="";if(optionsJson)try{optionsJson=decodeURIComponent(optionsJson);var optionsList=$.parseJSON(optionsJson);optionsList&&jQuery.each(optionsList,function(){optionsHtml+=prepare_option_row_html(this)})}catch(err){console.log(err)}var optionsTable=form.find(".thwcfd-option-list tbody");optionsHtml?optionsTable.html(optionsHtml):optionsTable.html(prepare_option_row_html(null))}function prepare_option_row_html(option){var key="",text="";option&&(key=option.key?option.key:"",text=option.text?option.text:"");var html="<tr>";return html+='<td class="key"><input type="text" name="i_options_key[]" value="'+key+'" placeholder="Option Value"></td>',html+='<td class="value"><input type="text" name="i_options_text[]" value="'+text+'" placeholder="Option Text"></td>',html+='<td class="action-cell">',html+='<a href="javascript:void(0)" onclick="thwcfdAddNewOptionRow(this)" class="btn btn-tiny btn-primary" title="Add new option">+</a>',html+='<a href="javascript:void(0)" onclick="thwcfdRemoveOptionRow(this)" class="btn btn-tiny btn-danger" title="Remove option">x</a>',html+='<span class="btn btn-tiny sort ui-sortable-handle"></span></td>',html+="</tr>"}function add_new_option_row(elm){var ptable=$(elm).closest("table");ptable.find("tbody tr").size()>0?ptable.find("tbody tr:last").after(prepare_option_row_html(null)):ptable.find("tbody").append(prepare_option_row_html(null))}function remove_option_row(elm){var ptable=$(elm).closest("table");$(elm).closest("tr").remove(),0==ptable.find("tbody tr").size()&&ptable.find("tbody").append(prepare_option_row_html(null))}var MSG_INVALID_NAME='NAME/ID must begin with a lowercase letter ([a-z]) or underscores ("_") and may be followed by any number of lowercase letters, digits ([0-9]) and underscores ("_")',SPECIAL_FIELD_TYPES=["country","state","city"],FIELD_FORM_PROPS={name:{name:"name",type:"text"},type:{name:"type",type:"select"},label:{name:"label",type:"text"},default:{name:"default",type:"text"},placeholder:{name:"placeholder",type:"text"},class:{name:"class",type:"text"},validate:{name:"validate",type:"select",multiple:1},required:{name:"required",type:"checkbox"},enabled:{name:"enabled",type:"checkbox"},show_in_email:{name:"show_in_email",type:"checkbox"},show_in_order:{name:"show_in_order",type:"checkbox"}},FIELDS_TO_HIDE={radio:["placeholder","validate"],select:["validate"],password:["default"]};return{openNewFieldForm:open_new_field_form,openEditFieldForm:open_edit_field_form,openCopyFieldForm:open_copy_field_form,fieldTypeChangeListner:field_type_change_listner,addNewOptionRow:add_new_option_row,removeOptionRow:remove_option_row,save_field:save_field}}(window.jQuery,window,document),thwcfd_settings=function($,window,document){"use strict";function select_all_fields(elm){var checkAll=$(elm).prop("checked");$("#thwcfd_checkout_fields tbody input:checkbox[name=select_field]").prop("checked",checkAll)}function remove_selected_fields(){$("#thwcfd_checkout_fields tbody tr").removeClass("strikeout"),$("#thwcfd_checkout_fields tbody input:checkbox[name=select_field]:checked").each(function(){var row=$(this).closest("tr");row.hasClass("strikeout")||row.addClass("strikeout"),row.find(".f_deleted").val(1)})}function enable_disable_selected_fields(enabled){$("#thwcfd_checkout_fields tbody input:checkbox[name=select_field]:checked").each(function(){var row=$(this).closest("tr");0==enabled?row.hasClass("thpladmin-disabled")||row.addClass("thpladmin-disabled"):row.removeClass("thpladmin-disabled"),row.find(".td_enabled").html(1==enabled?'<span class="dashicons dashicons-yes tips" data-tip="Yes"></span>':"-"),row.find(".f_enabled").val(enabled)})}function hide_review_request_notice(elm){var wrapper=$(elm).closest("div.thpladmin-notice"),nonce=wrapper.data("nonce"),data={thwcfd_security_review_notice:nonce,action:"skip_thwcfd_review_request_notice"};$.post(ajaxurl,data,function(){}),$(wrapper).hide(50)}return $(function(){var settings_form=$("#thwcfd_checkout_fields_form");thwcfd_base.setupSortableTable(settings_form,"#thwcfd_checkout_fields","0"),thwcfd_base.setup_tiptip_tooltips(),thwcfd_base.setup_form_wizard()}),$(document).on("click",".thpladmin-notice .notice-dismiss",function(){var wrapper=$(this).closest("div.thpladmin-notice"),nonce=wrapper.data("nonce"),action=wrapper.data("action"),data={thwcfd_security_review_notice:nonce,action:action};$.post(ajaxurl,data,function(){})}),$(document).ready(function(){setTimeout(function(){$("#thwcfd_review_request_notice").fadeIn(500)},2e3)}),$(document).keypress(function(e){!$("#thwcfd_field_form_pp").is(":visible")||13!=e.keycode&&13!=e.which||(e.preventDefault(),thwcfdSaveField(this))}),{selectAllFields:select_all_fields,removeSelectedFields:remove_selected_fields,enableDisableSelectedFields:enable_disable_selected_fields,hideReviewRequestNotice:hide_review_request_notice}}(window.jQuery,window,document);
admin/class-thwcfd-admin-form-field.php CHANGED
@@ -61,7 +61,7 @@ class THWCFD_Admin_Form_Field extends THWCFD_Admin_Form{
61
  $display_style = array(
62
  'full' => 'Full width',
63
  'half_left' => 'Half width left',
64
- 'ha;lf_right' => 'Half width right',
65
  );
66
 
67
  return array(
@@ -74,7 +74,7 @@ class THWCFD_Admin_Form_Field extends THWCFD_Admin_Form{
74
  //'options' => array('type'=>'text', 'name'=>'options', 'label'=>'Options', 'placeholder'=>'Seperate options with pipe(|)'),
75
  'class' => array('type'=>'text', 'name'=>'class', 'label'=>'Class', 'placeholder'=>'Separate classes with comma'),
76
  'validate' => array('type'=>'multiselect', 'name'=>'validate', 'label'=>'Validation', 'placeholder'=>'Select validations', 'options'=>$validations, 'multiple'=>1),
77
- 'disp_style' => array('type'=>'select', 'name'=>'disp_style', 'label'=>'Field Display', 'options'=>$display_style),
78
 
79
  'required' => array('type'=>'checkbox', 'name'=>'required', 'label'=>'Required', 'value'=>'1', 'checked'=>1),
80
  //'clear' => array('type'=>'checkbox', 'name'=>'clear', 'label'=>'Clear Row', 'value'=>'1', 'checked'=>1),
@@ -150,6 +150,7 @@ class THWCFD_Admin_Form_Field extends THWCFD_Admin_Form{
150
  <!-- <div class="data-panel data_panel_1">
151
  <?php //$this->render_form_tab_display_details(); ?>
152
  </div> -->
 
153
  </form>
154
  </main>
155
  <footer>
61
  $display_style = array(
62
  'full' => 'Full width',
63
  'half_left' => 'Half width left',
64
+ 'half_right' => 'Half width right',
65
  );
66
 
67
  return array(
74
  //'options' => array('type'=>'text', 'name'=>'options', 'label'=>'Options', 'placeholder'=>'Seperate options with pipe(|)'),
75
  'class' => array('type'=>'text', 'name'=>'class', 'label'=>'Class', 'placeholder'=>'Separate classes with comma'),
76
  'validate' => array('type'=>'multiselect', 'name'=>'validate', 'label'=>'Validation', 'placeholder'=>'Select validations', 'options'=>$validations, 'multiple'=>1),
77
+ // 'disp_style' => array('type'=>'select', 'name'=>'disp_style', 'label'=>'Field Display', 'options'=>$display_style),
78
 
79
  'required' => array('type'=>'checkbox', 'name'=>'required', 'label'=>'Required', 'value'=>'1', 'checked'=>1),
80
  //'clear' => array('type'=>'checkbox', 'name'=>'clear', 'label'=>'Clear Row', 'value'=>'1', 'checked'=>1),
150
  <!-- <div class="data-panel data_panel_1">
151
  <?php //$this->render_form_tab_display_details(); ?>
152
  </div> -->
153
+ <?php wp_nonce_field( 'thwcfd_field_form', 'thwcfd_security_manage_field' ); ?>
154
  </form>
155
  </main>
156
  <footer>
admin/class-thwcfd-admin-settings-advanced.php CHANGED
@@ -81,18 +81,30 @@ class THWCFD_Admin_Settings_Advanced extends THWCFD_Admin_Settings{
81
  }
82
 
83
  private function reset_settings(){
 
 
 
 
 
 
84
  delete_option(THWCFD_Utils::OPTION_KEY_ADVANCED_SETTINGS);
85
  $this->print_notices('Settings successfully reset.', 'updated', false);
86
  }
87
 
88
  private function save_settings(){
 
 
 
 
 
 
89
  $settings = array();
90
 
91
  foreach( $this->settings_fields as $name => $field ) {
92
  $value = '';
93
 
94
  if($field['type'] === 'checkbox'){
95
- $value = !empty( $_POST['i_'.$name] ) ? $_POST['i_'.$name] : '';
96
 
97
  }else if($field['type'] === 'multiselect_grouped'){
98
  $value = !empty( $_POST['i_'.$name] ) ? $_POST['i_'.$name] : '';
@@ -145,6 +157,7 @@ class THWCFD_Admin_Settings_Advanced extends THWCFD_Admin_Settings{
145
  <input type="submit" name="reset_settings" class="btn btn-small" value="Reset to default"
146
  onclick="return confirm('Are you sure you want to reset to default settings? all your changes will be deleted.');">
147
  </p>
 
148
  </form>
149
  </div>
150
  <?php
81
  }
82
 
83
  private function reset_settings(){
84
+ $nonse = isset($_REQUEST['thwcfd_security_advanced_settings']) ? $_REQUEST['thwcfd_security_advanced_settings'] : false;
85
+ $capability = THWCFD_Utils::wcfd_capability();
86
+ if(!wp_verify_nonce($nonse, 'thwcfd_advanced_settings') || !current_user_can($capability)){
87
+ die();
88
+ }
89
+
90
  delete_option(THWCFD_Utils::OPTION_KEY_ADVANCED_SETTINGS);
91
  $this->print_notices('Settings successfully reset.', 'updated', false);
92
  }
93
 
94
  private function save_settings(){
95
+ $nonse = isset($_REQUEST['thwcfd_security_advanced_settings']) ? $_REQUEST['thwcfd_security_advanced_settings'] : false;
96
+ $capability = THWCFD_Utils::wcfd_capability();
97
+ if(!wp_verify_nonce($nonse, 'thwcfd_advanced_settings') || !current_user_can($capability)){
98
+ die();
99
+ }
100
+
101
  $settings = array();
102
 
103
  foreach( $this->settings_fields as $name => $field ) {
104
  $value = '';
105
 
106
  if($field['type'] === 'checkbox'){
107
+ $value = !empty( $_POST['i_'.$name] ) ? '1' : '';
108
 
109
  }else if($field['type'] === 'multiselect_grouped'){
110
  $value = !empty( $_POST['i_'.$name] ) ? $_POST['i_'.$name] : '';
157
  <input type="submit" name="reset_settings" class="btn btn-small" value="Reset to default"
158
  onclick="return confirm('Are you sure you want to reset to default settings? all your changes will be deleted.');">
159
  </p>
160
+ <?php wp_nonce_field( 'thwcfd_advanced_settings', 'thwcfd_security_advanced_settings' ); ?>
161
  </form>
162
  </div>
163
  <?php
admin/class-thwcfd-admin-settings-general.php CHANGED
@@ -53,6 +53,12 @@ class THWCFD_Admin_Settings_General extends THWCFD_Admin_Settings{
53
  }
54
 
55
  public function reset_to_default() {
 
 
 
 
 
 
56
  delete_option('wc_fields_billing');
57
  delete_option('wc_fields_shipping');
58
  delete_option('wc_fields_additional');
@@ -110,6 +116,9 @@ class THWCFD_Admin_Settings_General extends THWCFD_Admin_Settings{
110
  if(isset($_POST['save_fields']))
111
  echo $this->save_fields($section);
112
 
 
 
 
113
  $fields = THWCFD_Utils::get_fields($section);
114
 
115
  ?>
@@ -162,10 +171,10 @@ class THWCFD_Admin_Settings_General extends THWCFD_Admin_Settings{
162
  </td>
163
  <td class="td_select"><input type="checkbox" name="select_field"/></td>
164
  <td class="td_name"><?php echo esc_attr( $name ); ?></td>
165
- <td class="td_type"><?php echo $type; ?></td>
166
- <td class="td_label"><?php THWCFD_Utils::et($label); ?></td>
167
- <td class="td_placeholder"><?php THWCFD_Utils::et($placeholder); ?></td>
168
- <td class="td_validate"><?php echo $validate; ?></td>
169
  <td class="td_required status"><?php echo $required_status; ?></td>
170
  <td class="td_enabled status"><?php echo $enabled_status; ?></td>
171
  <td class="td_edit action">
@@ -178,7 +187,8 @@ class THWCFD_Admin_Settings_General extends THWCFD_Admin_Settings{
178
  endforeach;
179
  ?>
180
  </tbody>
181
- </table>
 
182
  </form>
183
  <?php
184
  $this->field_form->output_field_forms();
@@ -201,6 +211,12 @@ class THWCFD_Admin_Settings_General extends THWCFD_Admin_Settings{
201
  }
202
 
203
  private function save_or_update_field($section, $action) {
 
 
 
 
 
 
204
  try {
205
  $result = false;
206
  $fields = THWCFD_Utils::get_fields($section);
@@ -213,7 +229,7 @@ class THWCFD_Admin_Settings_General extends THWCFD_Admin_Settings{
213
  $field['custom'] = 1;
214
  $field['priority'] = $priority;
215
  }else{
216
- $oname = isset($_POST['i_oname']) ? trim(stripslashes($_POST['i_oname'])) : false;
217
  if($name && $oname && $name !== $oname ){
218
  unset($fields[$oname]);
219
  }
@@ -235,16 +251,26 @@ class THWCFD_Admin_Settings_General extends THWCFD_Admin_Settings{
235
  }
236
 
237
  private function save_fields($section) {
 
 
 
 
 
 
238
  try {
239
- $f_names = !empty( $_POST['f_name'] ) ? $_POST['f_name'] : array();
 
240
  if(empty($f_names)){
241
  $this->print_notices('Your changes were not saved due to no fields found.', 'error');
242
  return;
243
  }
244
 
245
- $f_order = !empty( $_POST['f_order'] ) ? $_POST['f_order'] : array();
 
246
  $f_deleted = !empty( $_POST['f_deleted'] ) ? $_POST['f_deleted'] : array();
 
247
  $f_enabled = !empty( $_POST['f_enabled'] ) ? $_POST['f_enabled'] : array();
 
248
 
249
  $fields = THWCFD_Utils::get_fields($section);
250
 
@@ -260,8 +286,8 @@ class THWCFD_Admin_Settings_General extends THWCFD_Admin_Settings{
260
  continue;
261
  }
262
 
263
- $order = isset($f_order[$i]) ? trim(stripslashes($f_order[$i])) : 0;
264
- $enabled = isset($f_enabled[$i]) ? trim(stripslashes($f_enabled[$i])) : 0;
265
  $priority = THWCFD_Utils::prepare_field_priority($fields, $order, false);
266
 
267
  $field = $fields[$name];
@@ -296,13 +322,24 @@ class THWCFD_Admin_Settings_General extends THWCFD_Admin_Settings{
296
  $pvalue = isset($posted[$iname]) && $posted[$iname] ? 1 : 0;
297
  }else if(isset($posted[$iname])){
298
  //$pvalue = is_array($posted[$iname]) ? implode(',', $posted[$iname]) : trim(stripslashes($posted[$iname]));
299
- $pvalue = is_array($posted[$iname]) ? $posted[$iname] : trim(stripslashes($posted[$iname]));
300
- }
301
-
302
- if($pname === 'class'){
303
- //$pvalue = is_string($pvalue) ? array_map('trim', explode(',', $pvalue)) : $pvalue;
304
- $pvalue = is_string($pvalue) ? preg_split('/(\s*,*\s*)*,+(\s*,*\s*)*/', $pvalue) : $pvalue;
305
- $pvalue = is_array($pvalue) ? $pvalue : array();
 
 
 
 
 
 
 
 
 
 
 
306
  }
307
 
308
  $field[$pname] = $pvalue;
@@ -310,13 +347,13 @@ class THWCFD_Admin_Settings_General extends THWCFD_Admin_Settings{
310
 
311
  $type = isset($field['type']) ? $field['type'] : '';
312
  if(!$type){
313
- $type = isset($posted['i_otype']) ? trim(stripslashes($posted['i_otype'])) : '';
314
  $field['type'] = $type;
315
  }
316
 
317
  $name = isset($field['name']) ? $field['name'] : '';
318
  if(!$name){
319
- $field['name'] = isset($posted['i_oname']) ? trim(stripslashes($posted['i_oname'])) : '';
320
  }
321
 
322
  if($type === 'select'){
@@ -330,19 +367,34 @@ class THWCFD_Admin_Settings_General extends THWCFD_Admin_Settings{
330
 
331
  if($type === 'select' || $type === 'radio'){
332
  $options_json = isset($posted['i_options_json']) ? trim(stripslashes($posted['i_options_json'])) : '';
333
- $options_arr = THWCFD_Utils::prepare_options_array($options_json);
334
-
335
- //$field['options_json'] = $options_json;
 
 
 
 
 
 
 
 
336
  $field['options'] = $options_arr;
 
 
 
 
 
 
 
 
337
  }else{
338
  $field['options'] = '';
339
  }
340
 
341
- $field['autocomplete'] = isset($posted['i_autocomplete']) ? $posted['i_autocomplete'] : '';
342
- $field['priority'] = isset($posted['i_priority']) ? $posted['i_priority'] : '';
343
  //$field['custom'] = isset($posted['i_custom']) ? $posted['i_custom'] : '';
344
  $field['custom'] = isset($posted['i_custom']) && $posted['i_custom'] ? 1 : 0;
345
-
346
  return $field;
347
  }
348
 
@@ -373,7 +425,7 @@ class THWCFD_Admin_Settings_General extends THWCFD_Admin_Settings{
373
  $value = get_post_meta( $order_id, $name, true );
374
  if(!empty($value)){
375
  $value = THWCFD_Utils::get_option_text($field, $value);
376
- $label = isset($field['label']) && $field['label'] ? THWCFD_Utils::t($field['label']) : $name;
377
  $html .= '<p><strong>'. $label .':</strong><br/> '. wptexturize($value) .'</p>';
378
  }
379
  }
@@ -388,14 +440,14 @@ class THWCFD_Admin_Settings_General extends THWCFD_Admin_Settings{
388
  /******* TABS & SECTIONS *******/
389
  /*******************************/
390
  public function get_current_tab(){
391
- return isset( $_GET['tab'] ) ? esc_attr( $_GET['tab'] ) : 'fields';
392
  }
393
 
394
  public function get_current_section(){
395
  $tab = $this->get_current_tab();
396
  $section = '';
397
  if($tab === 'fields'){
398
- $section = isset( $_GET['section'] ) ? esc_attr( $_GET['section'] ) : 'billing';
399
  }
400
  return $section;
401
  }
@@ -411,7 +463,7 @@ class THWCFD_Admin_Settings_General extends THWCFD_Admin_Settings{
411
  foreach( $this->tabs as $id => $label ){
412
  $active = ( $current_tab == $id ) ? 'nav-tab-active' : '';
413
  $label = __($label, 'woo-checkout-field-editor-pro');
414
- echo '<a class="nav-tab '.$active.'" href="'. $this->get_admin_url($id) .'">'.$label.'</a>';
415
  }
416
  echo '</h2>';
417
  }
@@ -419,9 +471,6 @@ class THWCFD_Admin_Settings_General extends THWCFD_Admin_Settings{
419
  public function output_sections() {
420
  $result = false;
421
 
422
- if(isset($_POST['reset_fields']))
423
- $result = $this->reset_to_default();
424
-
425
  $current_tab = $this->get_current_tab();
426
  $current_section = $this->get_current_section();
427
 
@@ -435,7 +484,7 @@ class THWCFD_Admin_Settings_General extends THWCFD_Admin_Settings{
435
  foreach( $this->sections as $id => $label ){
436
  $label = __($label, 'woo-checkout-field-editor-pro');
437
  $url = $this->get_admin_url($current_tab, sanitize_title($id));
438
- echo '<li><a href="'. $url .'" class="'. ( $current_section == $id ? 'current' : '' ) .'">'. $label .'</a> '. (end( $array_keys ) == $id ? '' : '|') .' </li>';
439
  }
440
  echo '</ul>';
441
 
53
  }
54
 
55
  public function reset_to_default() {
56
+ $nonse = isset($_REQUEST['thwcfd_security_manage_fields']) ? $_REQUEST['thwcfd_security_manage_fields'] : false;
57
+ $capability = THWCFD_Utils::wcfd_capability();
58
+ if(!wp_verify_nonce($nonse, 'thwcfd_section_fields') || !current_user_can($capability)){
59
+ die();
60
+ }
61
+
62
  delete_option('wc_fields_billing');
63
  delete_option('wc_fields_shipping');
64
  delete_option('wc_fields_additional');
116
  if(isset($_POST['save_fields']))
117
  echo $this->save_fields($section);
118
 
119
+ if(isset($_POST['reset_fields']))
120
+ echo $this->reset_to_default();
121
+
122
  $fields = THWCFD_Utils::get_fields($section);
123
 
124
  ?>
171
  </td>
172
  <td class="td_select"><input type="checkbox" name="select_field"/></td>
173
  <td class="td_name"><?php echo esc_attr( $name ); ?></td>
174
+ <td class="td_type"><?php echo esc_attr($type); ?></td>
175
+ <td class="td_label"><?php echo esc_html_e($label, 'woo-checkout-field-editor-pro'); ?></td>
176
+ <td class="td_placeholder"><?php echo esc_html_e($placeholder, 'woo-checkout-field-editor-pro'); ?></td>
177
+ <td class="td_validate"><?php echo esc_html($validate); ?></td>
178
  <td class="td_required status"><?php echo $required_status; ?></td>
179
  <td class="td_enabled status"><?php echo $enabled_status; ?></td>
180
  <td class="td_edit action">
187
  endforeach;
188
  ?>
189
  </tbody>
190
+ </table>
191
+ <?php wp_nonce_field( 'thwcfd_section_fields', 'thwcfd_security_manage_fields' ); ?>
192
  </form>
193
  <?php
194
  $this->field_form->output_field_forms();
211
  }
212
 
213
  private function save_or_update_field($section, $action) {
214
+ $nonse = isset($_REQUEST['thwcfd_security_manage_field']) ? $_REQUEST['thwcfd_security_manage_field'] : false;
215
+ $capability = THWCFD_Utils::wcfd_capability();
216
+ if(!wp_verify_nonce($nonse, 'thwcfd_field_form') || !current_user_can($capability)){
217
+ die();
218
+ }
219
+
220
  try {
221
  $result = false;
222
  $fields = THWCFD_Utils::get_fields($section);
229
  $field['custom'] = 1;
230
  $field['priority'] = $priority;
231
  }else{
232
+ $oname = isset($_POST['i_oname']) ? sanitize_key($_POST['i_oname']) : false;
233
  if($name && $oname && $name !== $oname ){
234
  unset($fields[$oname]);
235
  }
251
  }
252
 
253
  private function save_fields($section) {
254
+ $nonse = isset($_REQUEST['thwcfd_security_manage_fields']) ? $_REQUEST['thwcfd_security_manage_fields'] : false;
255
+ $capability = THWCFD_Utils::wcfd_capability();
256
+ if(!wp_verify_nonce($nonse, 'thwcfd_section_fields') || !current_user_can($capability)){
257
+ die();
258
+ }
259
+
260
  try {
261
+ $f_names = !empty( $_POST['f_name'] ) ? $_POST['f_name'] : array();
262
+ $f_names = array_map('sanitize_key', $f_names);
263
  if(empty($f_names)){
264
  $this->print_notices('Your changes were not saved due to no fields found.', 'error');
265
  return;
266
  }
267
 
268
+ $f_order = !empty( $_POST['f_order'] ) ? $_POST['f_order'] : array();
269
+ $f_order = array_map('absint', $f_order);
270
  $f_deleted = !empty( $_POST['f_deleted'] ) ? $_POST['f_deleted'] : array();
271
+ $f_deleted = array_map('absint', $f_deleted);
272
  $f_enabled = !empty( $_POST['f_enabled'] ) ? $_POST['f_enabled'] : array();
273
+ $f_enabled = array_map('absint', $f_enabled);
274
 
275
  $fields = THWCFD_Utils::get_fields($section);
276
 
286
  continue;
287
  }
288
 
289
+ $order = isset($f_order[$i]) ? $f_order[$i] : 0;
290
+ $enabled = isset($f_enabled[$i]) ? $f_enabled[$i] : 0;
291
  $priority = THWCFD_Utils::prepare_field_priority($fields, $order, false);
292
 
293
  $field = $fields[$name];
322
  $pvalue = isset($posted[$iname]) && $posted[$iname] ? 1 : 0;
323
  }else if(isset($posted[$iname])){
324
  //$pvalue = is_array($posted[$iname]) ? implode(',', $posted[$iname]) : trim(stripslashes($posted[$iname]));
325
+ // $pvalue = is_array($posted[$iname]) ? $posted[$iname] : trim(stripslashes($posted[$iname]));
326
+
327
+ if(($pname === 'type') || ($pname === 'name')){
328
+ $pvalue = !empty($posted[$iname]) ? sanitize_key($posted[$iname]) : "";
329
+ }else if(($pname === 'label')){
330
+ //$pvalue = !empty($posted[$iname]) ? htmlentities(stripslashes($posted[$iname])) : "";
331
+ $pvalue = !empty($posted[$iname]) ? wp_unslash(wp_filter_post_kses($posted[$iname])) : "";
332
+ }else if(($pname === 'validate')){
333
+ $pvalue = !empty($posted[$iname]) ? (array) $posted[$iname] : array();
334
+ $pvalue = array_map( 'sanitize_key', $pvalue );
335
+ }else if($pname === 'class'){
336
+ //$pvalue = is_string($pvalue) ? array_map('trim', explode(',', $pvalue)) : $pvalue;
337
+ $pvalue = !empty($posted[$iname]) ? $posted[$iname] : '';
338
+ $pvalue = is_string($pvalue) ? preg_split('/(\s*,*\s*)*,+(\s*,*\s*)*/', $pvalue) : array();
339
+ $pvalue = array_map('sanitize_key', $pvalue);
340
+ }else{
341
+ $pvalue = !empty($posted[$iname]) ? sanitize_text_field(wp_unslash($posted[$iname])) : "";
342
+ }
343
  }
344
 
345
  $field[$pname] = $pvalue;
347
 
348
  $type = isset($field['type']) ? $field['type'] : '';
349
  if(!$type){
350
+ $type = isset($posted['i_otype']) ? sanitize_key($posted['i_otype']) : '';
351
  $field['type'] = $type;
352
  }
353
 
354
  $name = isset($field['name']) ? $field['name'] : '';
355
  if(!$name){
356
+ $field['name'] = isset($posted['i_oname']) ? sanitize_key($posted['i_oname']) : '';
357
  }
358
 
359
  if($type === 'select'){
367
 
368
  if($type === 'select' || $type === 'radio'){
369
  $options_json = isset($posted['i_options_json']) ? trim(stripslashes($posted['i_options_json'])) : '';
370
+ $options_arr = THWCFD_Utils::prepare_options_array($options_json, $type);
371
+
372
+ $keys = array_keys($options_arr);
373
+ // $keys = array_map('sanitize_key', $keys);
374
+ $keys = array_map('sanitize_text_field', $keys);
375
+
376
+ $values = array_values($options_arr);
377
+ $values = array_map('htmlspecialchars', $values);
378
+
379
+ $options_arr = array_combine($keys, $values);
380
+
381
  $field['options'] = $options_arr;
382
+
383
+ // // Sanitize default value same like option values
384
+ // $default_value = isset($field['default']) ? $field['default'] : '';
385
+ // if($default_value){
386
+ // $field['default'] = sanitize_key($default_value);
387
+ // }
388
+
389
+
390
  }else{
391
  $field['options'] = '';
392
  }
393
 
394
+ $field['autocomplete'] = isset($posted['i_autocomplete']) ? sanitize_text_field($posted['i_autocomplete']) : '';
395
+ $field['priority'] = isset($posted['i_priority']) ? absint($posted['i_priority']) : '';
396
  //$field['custom'] = isset($posted['i_custom']) ? $posted['i_custom'] : '';
397
  $field['custom'] = isset($posted['i_custom']) && $posted['i_custom'] ? 1 : 0;
 
398
  return $field;
399
  }
400
 
425
  $value = get_post_meta( $order_id, $name, true );
426
  if(!empty($value)){
427
  $value = THWCFD_Utils::get_option_text($field, $value);
428
+ $label = isset($field['label']) && $field['label'] ? esc_html($field['label'], 'woo-checkout-field-editor-pro') : $name;
429
  $html .= '<p><strong>'. $label .':</strong><br/> '. wptexturize($value) .'</p>';
430
  }
431
  }
440
  /******* TABS & SECTIONS *******/
441
  /*******************************/
442
  public function get_current_tab(){
443
+ return isset( $_GET['tab'] ) ? sanitize_key( $_GET['tab'] ) : 'fields';
444
  }
445
 
446
  public function get_current_section(){
447
  $tab = $this->get_current_tab();
448
  $section = '';
449
  if($tab === 'fields'){
450
+ $section = isset( $_GET['section'] ) ? sanitize_key( $_GET['section'] ) : 'billing';
451
  }
452
  return $section;
453
  }
463
  foreach( $this->tabs as $id => $label ){
464
  $active = ( $current_tab == $id ) ? 'nav-tab-active' : '';
465
  $label = __($label, 'woo-checkout-field-editor-pro');
466
+ echo '<a class="nav-tab '.$active.'" href="'. esc_url($this->get_admin_url($id)) .'">'.$label.'</a>';
467
  }
468
  echo '</h2>';
469
  }
471
  public function output_sections() {
472
  $result = false;
473
 
 
 
 
474
  $current_tab = $this->get_current_tab();
475
  $current_section = $this->get_current_section();
476
 
484
  foreach( $this->sections as $id => $label ){
485
  $label = __($label, 'woo-checkout-field-editor-pro');
486
  $url = $this->get_admin_url($current_tab, sanitize_title($id));
487
+ echo '<li><a href="'.esc_url($url) .'" class="'. ( $current_section == $id ? 'current' : '' ) .'">'. $label .'</a> '. (end( $array_keys ) == $id ? '' : '|') .' </li>';
488
  }
489
  echo '</ul>';
490
 
admin/class-thwcfd-admin-settings.php CHANGED
@@ -32,7 +32,7 @@ abstract class THWCFD_Admin_Settings{
32
  }
33
 
34
  public function get_current_section(){
35
- return isset( $_GET['section'] ) ? esc_attr( $_GET['section'] ) : $this->section_id;
36
  }
37
 
38
  public function render_tabs(){
@@ -46,8 +46,8 @@ abstract class THWCFD_Admin_Settings{
46
  echo '<h2 class="thpladmin-tabs nav-tab-wrapper woo-nav-tab-wrapper">';
47
  foreach( $tabs as $id => $label ){
48
  $active = ( $current_tab == $id ) ? 'nav-tab-active' : '';
49
- $label = __($label, 'woo-checkout-field-editor-pro');
50
- echo '<a class="nav-tab '.$active.'" href="'. $this->get_admin_url($id) .'">'.$label.'</a>';
51
  }
52
  echo '</h2>';
53
  }
@@ -102,7 +102,7 @@ abstract class THWCFD_Admin_Settings{
102
  // $tooltip_html = '<a href="javascript:void(0)" title="'. $tooltip .'" class="thpladmin_tooltip"><img src="'. $icon .'" alt="" title=""/></a>';
103
  }
104
  ?>
105
- <td style="width: 26px; padding:0px;"><?php echo $tooltip_html; ?></td>
106
  <?php
107
  }
108
 
32
  }
33
 
34
  public function get_current_section(){
35
+ return isset( $_GET['section'] ) ? sanitize_key( $_GET['section'] ) : $this->section_id;
36
  }
37
 
38
  public function render_tabs(){
46
  echo '<h2 class="thpladmin-tabs nav-tab-wrapper woo-nav-tab-wrapper">';
47
  foreach( $tabs as $id => $label ){
48
  $active = ( $current_tab == $id ) ? 'nav-tab-active' : '';
49
+ $label = esc_html__($label, 'woo-checkout-field-editor-pro');
50
+ echo '<a class="nav-tab '.$active.'" href="'. esc_url($this->get_admin_url($id)) .'">'.$label.'</a>';
51
  }
52
  echo '</h2>';
53
  }
102
  // $tooltip_html = '<a href="javascript:void(0)" title="'. $tooltip .'" class="thpladmin_tooltip"><img src="'. $icon .'" alt="" title=""/></a>';
103
  }
104
  ?>
105
+ <td style="width: 26px; padding:0px;"><?php esc_html_e($tooltip_html, 'woo-checkout-field-editor-pro'); ?></td>
106
  <?php
107
  }
108
 
admin/class-thwcfd-admin.php CHANGED
@@ -48,19 +48,9 @@ class THWCFD_Admin {
48
 
49
  wp_enqueue_script('thwcfd-admin-script', THWCFD_ASSETS_URL_ADMIN . 'js/thwcfd-admin'. $suffix .'.js', $deps, $this->version, false);
50
  }
51
-
52
- public function wcfd_capability() {
53
- $allowed = array('manage_woocommerce', 'manage_options');
54
- $capability = apply_filters('thwcfd_required_capability', 'manage_woocommerce');
55
-
56
- if(!in_array($capability, $allowed)){
57
- $capability = 'manage_woocommerce';
58
- }
59
- return $capability;
60
- }
61
 
62
  public function admin_menu() {
63
- $capability = $this->wcfd_capability();
64
  $this->screen_id = add_submenu_page('woocommerce', __('WooCommerce Checkout Field Editor', 'woo-checkout-field-editor-pro'), __('Checkout Form', 'woo-checkout-field-editor-pro'), $capability, 'checkout_form_designer', array($this, 'output_settings'));
65
  }
66
 
@@ -72,7 +62,7 @@ class THWCFD_Admin {
72
  }
73
 
74
  public function plugin_action_links($links) {
75
- $settings_link = '<a href="'.admin_url('admin.php?page=checkout_form_designer').'">'. __('Settings', 'woo-checkout-field-editor-pro') .'</a>';
76
  array_unshift($links, $settings_link);
77
  $pro_link = '<a style="color:green; font-weight:bold" target="_blank" href="https://www.themehigh.com/product/woocommerce-checkout-field-editor-pro/?utm_source=free&utm_medium=plugin_action_link&utm_campaign=wcfe_upgrade_link">'. __('Get Pro', 'woo-checkout-field-editor-pro') .'</a>';
78
  array_push($links,$pro_link);
@@ -116,7 +106,7 @@ class THWCFD_Admin {
116
  <button type="button" class="button button-primary" onclick="window.open('https://wordpress.org/support/plugin/woo-checkout-field-editor-pro/reviews?rate=5#new-post', '_blank')">Review Now</button>
117
  <button type="button" class="button" onclick="thwcfdHideReviewRequestNotice(this)">Remind Me Later</button>
118
  <span class="logo"><a target="_blank" href="https://www.themehigh.com">
119
- <img src="<?php echo THWCFD_ASSETS_URL_ADMIN ?>css/logo.svg" />
120
  </a></span>
121
 
122
  </p>
@@ -125,7 +115,7 @@ class THWCFD_Admin {
125
  }
126
 
127
  public function get_current_tab(){
128
- return isset( $_GET['tab'] ) ? esc_attr( $_GET['tab'] ) : 'fields';
129
  }
130
 
131
  public function output_settings(){
@@ -151,14 +141,18 @@ class THWCFD_Admin {
151
  }
152
 
153
  public function dismiss_thwcfd_review_request_notice(){
154
- if(! check_ajax_referer( 'thwcfd_review_request_notice', 'security' )){
 
 
155
  die();
156
  }
157
  set_transient('thwcfd_review_request_notice_dismissed', true, apply_filters('thwcfd_dismissed_review_request_notice_lifespan', 1 * YEAR_IN_SECONDS));
158
  }
159
 
160
  public function skip_thwcfd_review_request_notice(){
161
- if(! check_ajax_referer( 'thwcfd_review_request_notice', 'security' )){
 
 
162
  die();
163
  }
164
  set_transient('thwcfd_skip_review_request_notice', true, apply_filters('thwcfd_skip_review_request_notice_lifespan', 1 * DAY_IN_SECONDS));
48
 
49
  wp_enqueue_script('thwcfd-admin-script', THWCFD_ASSETS_URL_ADMIN . 'js/thwcfd-admin'. $suffix .'.js', $deps, $this->version, false);
50
  }
 
 
 
 
 
 
 
 
 
 
51
 
52
  public function admin_menu() {
53
+ $capability = THWCFD_Utils::wcfd_capability();
54
  $this->screen_id = add_submenu_page('woocommerce', __('WooCommerce Checkout Field Editor', 'woo-checkout-field-editor-pro'), __('Checkout Form', 'woo-checkout-field-editor-pro'), $capability, 'checkout_form_designer', array($this, 'output_settings'));
55
  }
56
 
62
  }
63
 
64
  public function plugin_action_links($links) {
65
+ $settings_link = '<a href="'.esc_url(admin_url('admin.php?page=checkout_form_designer')).'">'. __('Settings', 'woo-checkout-field-editor-pro') .'</a>';
66
  array_unshift($links, $settings_link);
67
  $pro_link = '<a style="color:green; font-weight:bold" target="_blank" href="https://www.themehigh.com/product/woocommerce-checkout-field-editor-pro/?utm_source=free&utm_medium=plugin_action_link&utm_campaign=wcfe_upgrade_link">'. __('Get Pro', 'woo-checkout-field-editor-pro') .'</a>';
68
  array_push($links,$pro_link);
106
  <button type="button" class="button button-primary" onclick="window.open('https://wordpress.org/support/plugin/woo-checkout-field-editor-pro/reviews?rate=5#new-post', '_blank')">Review Now</button>
107
  <button type="button" class="button" onclick="thwcfdHideReviewRequestNotice(this)">Remind Me Later</button>
108
  <span class="logo"><a target="_blank" href="https://www.themehigh.com">
109
+ <img src="<?php echo esc_url(THWCFD_ASSETS_URL_ADMIN .'css/logo.svg'); ?>" />
110
  </a></span>
111
 
112
  </p>
115
  }
116
 
117
  public function get_current_tab(){
118
+ return isset( $_GET['tab'] ) ? sanitize_key( $_GET['tab'] ) : 'fields';
119
  }
120
 
121
  public function output_settings(){
141
  }
142
 
143
  public function dismiss_thwcfd_review_request_notice(){
144
+ $nonse = isset($_REQUEST['thwcfd_security_review_notice']) ? $_REQUEST['thwcfd_security_review_notice'] : false;
145
+ $capability = THWCFD_Utils::wcfd_capability();
146
+ if(!wp_verify_nonce($nonse, 'thwcfd_review_request_notice') || !current_user_can($capability)){
147
  die();
148
  }
149
  set_transient('thwcfd_review_request_notice_dismissed', true, apply_filters('thwcfd_dismissed_review_request_notice_lifespan', 1 * YEAR_IN_SECONDS));
150
  }
151
 
152
  public function skip_thwcfd_review_request_notice(){
153
+ $nonse = isset($_REQUEST['thwcfd_security_review_notice']) ? $_REQUEST['thwcfd_security_review_notice'] : false;
154
+ $capability = THWCFD_Utils::wcfd_capability();
155
+ if(!wp_verify_nonce($nonse, 'thwcfd_review_request_notice') || !current_user_can($capability)){
156
  die();
157
  }
158
  set_transient('thwcfd_skip_review_request_notice', true, apply_filters('thwcfd_skip_review_request_notice_lifespan', 1 * DAY_IN_SECONDS));
checkout-form-designer.php CHANGED
@@ -3,13 +3,13 @@
3
  * Plugin Name: Checkout Field Editor for WooCommerce
4
  * Description: Customize WooCommerce checkout fields(Add, Edit, Delete and re-arrange fields).
5
  * Author: ThemeHigh
6
- * Version: 1.4.8
7
  * Author URI: https://www.themehigh.com
8
  * Plugin URI: https://www.themehigh.com
9
  * Text Domain: woo-checkout-field-editor-pro
10
  * Domain Path: /languages
11
  * WC requires at least: 3.0.0
12
- * WC tested up to: 5.2.2
13
  */
14
 
15
  if(!defined( 'ABSPATH' )) exit;
@@ -25,7 +25,7 @@ if (!function_exists('is_woocommerce_active')){
25
  }
26
 
27
  if(is_woocommerce_active()) {
28
- define('THWCFD_VERSION', '1.4.8');
29
  !defined('THWCFD_BASE_NAME') && define('THWCFD_BASE_NAME', plugin_basename( __FILE__ ));
30
  !defined('THWCFD_PATH') && define('THWCFD_PATH', plugin_dir_path( __FILE__ ));
31
  !defined('THWCFD_URL') && define('THWCFD_URL', plugins_url( '/', __FILE__ ));
3
  * Plugin Name: Checkout Field Editor for WooCommerce
4
  * Description: Customize WooCommerce checkout fields(Add, Edit, Delete and re-arrange fields).
5
  * Author: ThemeHigh
6
+ * Version: 1.4.9
7
  * Author URI: https://www.themehigh.com
8
  * Plugin URI: https://www.themehigh.com
9
  * Text Domain: woo-checkout-field-editor-pro
10
  * Domain Path: /languages
11
  * WC requires at least: 3.0.0
12
+ * WC tested up to: 5.6.0
13
  */
14
 
15
  if(!defined( 'ABSPATH' )) exit;
25
  }
26
 
27
  if(is_woocommerce_active()) {
28
+ define('THWCFD_VERSION', '1.4.9');
29
  !defined('THWCFD_BASE_NAME') && define('THWCFD_BASE_NAME', plugin_basename( __FILE__ ));
30
  !defined('THWCFD_PATH') && define('THWCFD_PATH', plugin_dir_path( __FILE__ ));
31
  !defined('THWCFD_URL') && define('THWCFD_URL', plugins_url( '/', __FILE__ ));
includes/utils/class-thwcfd-utils.php CHANGED
@@ -19,6 +19,16 @@ class THWCFD_Utils {
19
 
20
  }
21
 
 
 
 
 
 
 
 
 
 
 
22
  public static function is_address_field($name){
23
  $address_fields = array(
24
  'billing_address_1', 'billing_address_2', 'billing_state', 'billing_postcode', 'billing_city',
@@ -166,17 +176,22 @@ class THWCFD_Utils {
166
  return is_array($options) ? $options : array();
167
  }
168
 
169
- public static function prepare_options_array($options_json){
170
  $options_json = rawurldecode($options_json);
171
  $options_arr = json_decode($options_json, true);
172
  $options = array();
173
 
174
  if($options_arr){
 
175
  foreach($options_arr as $option){
176
  $okey = isset($option['key']) ? $option['key'] : '';
177
  $otext = isset($option['text']) ? $option['text'] : '';
178
- //$okey = $okey ? $okey : $otext;
179
-
 
 
 
 
180
  //if($okey || $otext){
181
  $options[$okey] = $otext;
182
  //}
19
 
20
  }
21
 
22
+ public static function wcfd_capability() {
23
+ $allowed = array('manage_woocommerce', 'manage_options');
24
+ $capability = apply_filters('thwcfd_required_capability', 'manage_woocommerce');
25
+
26
+ if(!in_array($capability, $allowed)){
27
+ $capability = 'manage_woocommerce';
28
+ }
29
+ return $capability;
30
+ }
31
+
32
  public static function is_address_field($name){
33
  $address_fields = array(
34
  'billing_address_1', 'billing_address_2', 'billing_state', 'billing_postcode', 'billing_city',
176
  return is_array($options) ? $options : array();
177
  }
178
 
179
+ public static function prepare_options_array($options_json, $type = 'radio'){
180
  $options_json = rawurldecode($options_json);
181
  $options_arr = json_decode($options_json, true);
182
  $options = array();
183
 
184
  if($options_arr){
185
+ $i = 0;
186
  foreach($options_arr as $option){
187
  $okey = isset($option['key']) ? $option['key'] : '';
188
  $otext = isset($option['text']) ? $option['text'] : '';
189
+ if($i == 0 && $type == 'select'){
190
+ $okey = $okey ? $okey : '';
191
+ }else{
192
+ $okey = $okey ? $okey : sanitize_key($otext);
193
+ }
194
+ $i++;
195
  //if($okey || $otext){
196
  $options[$okey] = $otext;
197
  //}
public/class-thwcfd-public-checkout.php CHANGED
@@ -165,7 +165,7 @@ class THWCFD_Public_Checkout {
165
  if(is_wc_endpoint_url('edit-address')){
166
  return $fields;
167
  }else{
168
- return $this->prepare_address_fields(get_option('wc_fields_billing'), $fields, 'billing', $country);
169
  }
170
  }
171
 
@@ -173,7 +173,7 @@ class THWCFD_Public_Checkout {
173
  if(is_wc_endpoint_url('edit-address')){
174
  return $fields;
175
  }else{
176
- return $this->prepare_address_fields(get_option('wc_fields_shipping'), $fields, 'shipping', $country);
177
  }
178
  }
179
 
@@ -202,7 +202,7 @@ class THWCFD_Public_Checkout {
202
  return $fields;
203
  }
204
 
205
- public function prepare_address_fields($fieldset, $original_fieldset = false, $sname = 'billing', $country){
206
  if(is_array($fieldset) && !empty($fieldset)) {
207
  $locale = WC()->countries->get_country_locale();
208
 
@@ -334,37 +334,33 @@ class THWCFD_Public_Checkout {
334
 
335
  foreach($fieldset as $key => $field) {
336
  if(isset($posted[$key]) && !THWCFD_Utils::is_blank($posted[$key])){
337
- $this->validate_custom_field($field, $posted, $errors);
338
  }
339
  }
340
  }
341
  }
342
 
343
- public function validate_custom_field($field, $posted, $errors=false, $return=false){
344
  $err_msgs = array();
345
- $key = isset($field['name']) ? $field['name'] : false;
346
-
347
- if($key){
348
- $value = isset($posted[$key]) ? $posted[$key] : '';
349
- $validators = isset($field['validate']) ? $field['validate'] : '';
350
-
351
- if($value && is_array($validators) && !empty($validators)){
352
- foreach($validators as $vname){
353
- $err_msg = '';
354
- $flabel = isset($field['label']) ? THWCFD_Utils::t($field['label']) : $key;
355
-
356
- if($vname === 'number'){
357
- if(!is_numeric($value)){
358
- $err_msg = '<strong>'. $flabel .'</strong> '. THWCFD_Utils::t('is not a valid number.');
359
- }
360
  }
 
361
 
362
- if($err_msg){
363
- if($errors || !$return){
364
- $this->add_validation_error($err_msg, $errors);
365
- }
366
- $err_msgs[] = $err_msg;
367
  }
 
368
  }
369
  }
370
  }
@@ -393,7 +389,21 @@ class THWCFD_Public_Checkout {
393
 
394
  foreach($fields as $name => $field){
395
  if(THWCFD_Utils::is_active_custom_field($field) && isset($posted[$name])){
396
- $value = wc_clean($posted[$name]);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
397
  if($value){
398
  update_post_meta($order_id, $name, $value);
399
  }
@@ -430,11 +440,17 @@ class THWCFD_Public_Checkout {
430
 
431
  if($value){
432
  $label = isset($field['label']) && $field['label'] ? $field['label'] : $key;
433
- $label = esc_attr($label);
434
  $value = THWCFD_Utils::get_option_text($field, $value);
 
 
 
 
 
 
435
 
436
  $custom_field = array();
437
- $custom_field['label'] = THWCFD_Utils::t($label);
438
  $custom_field['value'] = $value;
439
 
440
  $custom_fields[$key] = $custom_field;
@@ -460,11 +476,18 @@ class THWCFD_Public_Checkout {
460
  $value = get_post_meta( $order_id, $key, true );
461
 
462
  if($value){
463
- $label = isset($field['label']) && $field['label'] ? THWCFD_Utils::t($field['label']) : $key;
464
 
465
- $label = esc_attr($label);
 
466
  //$value = wptexturize($value);
467
  $value = THWCFD_Utils::get_option_text($field, $value);
 
 
 
 
 
 
468
 
469
  if(is_account_page()){
470
  if(apply_filters( 'thwcfd_view_order_customer_details_table_view', true )){
165
  if(is_wc_endpoint_url('edit-address')){
166
  return $fields;
167
  }else{
168
+ return $this->prepare_address_fields(get_option('wc_fields_billing'), $country, $fields, 'billing');
169
  }
170
  }
171
 
173
  if(is_wc_endpoint_url('edit-address')){
174
  return $fields;
175
  }else{
176
+ return $this->prepare_address_fields(get_option('wc_fields_shipping'), $country, $fields, 'shipping');
177
  }
178
  }
179
 
202
  return $fields;
203
  }
204
 
205
+ public function prepare_address_fields($fieldset, $country, $original_fieldset = false, $sname = 'billing'){
206
  if(is_array($fieldset) && !empty($fieldset)) {
207
  $locale = WC()->countries->get_country_locale();
208
 
334
 
335
  foreach($fieldset as $key => $field) {
336
  if(isset($posted[$key]) && !THWCFD_Utils::is_blank($posted[$key])){
337
+ $this->validate_custom_field($key, $field, $posted, $errors);
338
  }
339
  }
340
  }
341
  }
342
 
343
+ public function validate_custom_field($key, $field, $posted, $errors=false, $return=false){
344
  $err_msgs = array();
345
+ $value = isset($posted[$key]) ? $posted[$key] : '';
346
+ $validators = isset($field['validate']) ? $field['validate'] : '';
347
+
348
+ if($value && is_array($validators) && !empty($validators)){
349
+ foreach($validators as $vname){
350
+ $err_msg = '';
351
+ $flabel = isset($field['label']) ? THWCFD_Utils::t($field['label']) : $key;
352
+
353
+ if($vname === 'number'){
354
+ if(!is_numeric($value)){
355
+ $err_msg = '<strong>'. $flabel .'</strong> '. THWCFD_Utils::t('is not a valid number.');
 
 
 
 
356
  }
357
+ }
358
 
359
+ if($err_msg){
360
+ if($errors || !$return){
361
+ $this->add_validation_error($err_msg, $errors);
 
 
362
  }
363
+ $err_msgs[] = $err_msg;
364
  }
365
  }
366
  }
389
 
390
  foreach($fields as $name => $field){
391
  if(THWCFD_Utils::is_active_custom_field($field) && isset($posted[$name])){
392
+
393
+ $type = isset($field['type']) ? $field['type'] : 'text';
394
+
395
+ if($type == 'textarea'){
396
+ $value = isset($posted[$name]) ? sanitize_textarea_field($posted[$name]) : '';
397
+ }else if($type == 'email'){
398
+ $value = isset($posted[$name]) ? sanitize_email($posted[$name]) : '';
399
+ }else if(($type == 'select') || ($type == 'radio')){
400
+ $options = isset($field['options']) ? $field['options'] : array();
401
+ $value = isset($posted[$name]) ? sanitize_text_field($posted[$name]) : '';
402
+ $value = array_key_exists($value, $options) ? $value : '';
403
+ }else{
404
+ $value = isset($posted[$name]) ? sanitize_text_field($posted[$name]) : '';
405
+ }
406
+
407
  if($value){
408
  update_post_meta($order_id, $name, $value);
409
  }
440
 
441
  if($value){
442
  $label = isset($field['label']) && $field['label'] ? $field['label'] : $key;
443
+ //$label = esc_attr($label);
444
  $value = THWCFD_Utils::get_option_text($field, $value);
445
+
446
+ $f_type = isset($field['type']) ? $field['type'] : 'text';
447
+ $value = esc_html__($value, 'woo-checkout-field-editor-pro');
448
+ if($f_type == 'textarea'){
449
+ $value = nl2br($value);
450
+ }
451
 
452
  $custom_field = array();
453
+ $custom_field['label'] = wp_kses_post(__($label, 'woo-checkout-field-editor-pro'));
454
  $custom_field['value'] = $value;
455
 
456
  $custom_fields[$key] = $custom_field;
476
  $value = get_post_meta( $order_id, $key, true );
477
 
478
  if($value){
479
+ $label = isset($field['label']) && $field['label'] ? $field['label'] : $key;
480
 
481
+ //$label = esc_attr($label);
482
+ $label = wp_kses_post(__($label, 'woo-checkout-field-editor-pro'));
483
  //$value = wptexturize($value);
484
  $value = THWCFD_Utils::get_option_text($field, $value);
485
+
486
+ $f_type = isset($field['type']) ? $field['type'] : 'text';
487
+ $value = esc_html__($value, 'woo-checkout-field-editor-pro');
488
+ if($f_type == 'textarea'){
489
+ $value = nl2br($value);
490
+ }
491
 
492
  if(is_account_page()){
493
  if(apply_filters( 'thwcfd_view_order_customer_details_table_view', true )){
readme.txt CHANGED
@@ -3,9 +3,9 @@ Contributors: ThemeHigh
3
  Donate link: https://themehigh.com/
4
  Tags: checkout field editor, woocommerce checkout field editor, checkout manager, woocommerce checkout manager, checkout field customizer, checkout form editor, checkout form customizer, checkout, WooCommerce checkout, checkout form designer, woocommerce checkout fields, woocommerce checkout addons
5
  Requires at least: 4.9
6
- Tested up to: 5.7
7
  Requires PHP: 5.6
8
- Stable tag: 1.4.8
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -14,116 +14,157 @@ Checkout Field Editor (Checkout Manager) for WooCommerce - The best WooCommerce
14
  == Description ==
15
 
16
  = Checkout Field Editor for WooCommerce =
17
- If you are wondering how to add custom field in WooCommerce checkout page, you are at the right place. Checkout Field Editor for WooCommerce plugin provides an easy way to customise (add, edit, delete and change display order) your fields displayed on WooCommerce checkout page. This plugin requires WooCommerce to be installed, activated, and configured.
 
 
 
 
18
 
19
  --------------------------------------------
20
  https://www.youtube.com/watch?v=_iKMe5lGIIM
21
  --------------------------------------------
22
 
23
- = Basic Version Features =
24
- = ☞ Add new custom field(s) =
25
- Adding custom fields to the WooCommerce checkout page is a breeze now. You can add custom field(s) in Billing, Shipping and Additional fields sections. New field form contains options to provide values for Type, Name, Label, Placeholder, Class, Label Class etc. It also has the option to choose validations rules from a predefined list.
 
 
 
 
 
 
 
 
26
 
27
  = ☞ Edit field(s) =
28
- You can edit core and custom field(s) in Billing, Shipping and Additional fields sections. In edit form you have the option to provide new values for Name, Type, Label, Placeholder, Class, Label Class, validation rules etc(availability of these options may change based on the field types).
29
 
30
- Available field types are:
 
31
 
32
- * Input Text
33
- * Password
34
- * Email
35
- * Phone
36
- * Select
37
- * Textarea
38
- * Radio
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
- = ☞ Display in Order Details page and Email =
41
- You can decide on a field whether it need to be displayed in Order Details page and Email using the the checkboxes ‘Display in Order Detail Pages’ and ‘Display in Emails’. These checkboxes are available in both the ‘New Field’ and ‘Edit Field’ forms.
42
 
43
- = ☞ Remove field(s) =
44
- You can remove field(s) from displaying in checkout page, order details page and emails. Removing core fields may leads to unexpected results with some plugins. We are not recommending this.
45
 
46
- = ☞ Enable/Disable field(s) =
47
- You can enable/disable field(s)(temporarily remove) from displaying in checkout page, order details page and emails. Disabling core fields may leads to unexpected results with some plugins. We are not recommending this.
48
-
49
- = Change checkout fields order =
50
- You can easily manage the display order of checkout fields from admin side by just moving fields up and down.
51
-
52
- = Reset to default field set =
53
- You can reset all your changes back to the original WooCommerce fields set using the button ‘Reset to default fields’.
54
-
55
- == 💎💎 Premium Features ==
56
- The premium version of [Checkout Field Editor for WooCommerce](https://www.themehigh.com/product/woocommerce-checkout-field-editor-pro/?utm_source=wordpress&utm_medium=referral&utm_content=tracking) plugin offers a wide variety of advanced features that will help you to create the finest checkout page. It is equipped with all demanded options to customize your checkout page.
57
-
58
- [Upgrade to Premium Now!](https://www.themehigh.com/product/woocommerce-checkout-field-editor-pro/?utm_source=wordpress&utm_medium=referral&utm_content=tracking)
59
-
60
- You can check out the demo for a more detailed overview of the features.
61
-
62
- [Live Demo - Front End](https://flydemos.com/wcfe/?utm_source=wordpress&utm_medium=referral&utm_content=tracking)
63
- [Live Demo - Back End](https://flydemos.com/wcfe/wp-admin/?utm_source=wordpress&utm_medium=referral&utm_content=tracking)
64
-
65
- = ☞ 17 field types are available =
66
- In Add New Field form and Edit Field form you can choose field type from a list of 17 including 15 input fields and one field for title/heading and one for label.
67
-
68
- Available field types:
69
-
70
- 1. Input Text
71
- 2. Hidden
72
- 3. Password
73
- 4. Telephone
74
- 5. Email
75
- 6. Number
76
- 7. Textarea
77
- 8. Radio
78
- 9. Checkbox
79
- 10. Checkbox Group
80
- 11. Select
81
- 12. Multi-select
82
- 13. Date picker
83
- 14. Time picker
84
- 15. File Upload
85
- 16. Heading – Display a heading/ title
86
- 17. Label – Display a label/ text
87
-
88
- = ☞ Conditional Fields =
89
- Conditionally display fields & sections based on cart items and other field(s) values.
90
-
91
- = ☞ Custom Validations =
92
- Custom validator feature can be used to define custom validation rules using RegEx.
93
 
94
- = ☞ Price Fields =
95
- Add an extra cost to the cart total based on field selection.
96
 
97
- = ☞ Add new section =
98
- Add new section(s) in predefined positions in checkout page.
99
 
100
- Available positions:
 
101
 
102
- 1. Before customer details
103
- 2. After customer details
104
- 3. Before billing form
105
- 4. After billing form
106
- 5. Before shipping form
107
- 6. After shipping form
108
- 7. Before registration form
109
- 8. After registration form
110
- 9. Before order notes
111
- 10. After order notes
112
- 11. Before terms & conditions
113
- 12. After terms & conditions
114
- 13. Before submit button
115
- 14. After submit button
116
 
117
- = Edit section(s) properties =
118
- Edit custom added section(s) label and display position.
119
 
120
- = Delete section(s) =
121
- Delete custom added section(s).
 
122
 
123
  --------------------------------------------
124
  *For the complete list of features, Please visit [WooCommerce Checkout Field Editor (Checkout Manager)](https://www.themehigh.com/product/woocommerce-checkout-field-editor-pro/?utm_source=wordpress&utm_medium=referral&utm_content=tracking) plugin's official page.*
125
 
126
- Check how it works (Live Demo): 🔗 [Front End](https://flydemos.com/wcfe/?utm_source=wordpress&utm_medium=referral&utm_content=tracking) | 🔗 [Back End](https://flydemos.com/wcfe/wp-admin/?utm_source=wordpress&utm_medium=referral&utm_content=tracking)
127
  --------------------------------------------
128
 
129
  == Why ThemeHigh ==
@@ -146,7 +187,7 @@ Frequent updates are made to improve the plugin with a talented group of develop
146
  For more info on ThemeHigh and WooCommerce Checkout Field Editor plugin in specific, check out the following:
147
 
148
  * The [Checkout Field Editor (Checkout Manager) for WooCommerce](https://www.themehigh.com/product/woocommerce-checkout-field-editor-pro/?utm_source=wordpress&utm_medium=referral&utm_content=tracking) premium plugin homepage.
149
- * The [Knowledgebase](https://www.themehigh.com/doc/woocommerce-checkout-field-editor/?utm_source=wordpress&utm_medium=referral&utm_content=tracking).
150
  * Other [WordPress Plugins](https://www.themehigh.com/plugins/?utm_source=wordpress&utm_medium=referral&utm_content=tracking) by the ThemeHigh team.
151
  * Follow ThemeHigh on [Facebook](https://www.facebook.com/ThemeHigh-319611541768603/?utm_source=wordpress&utm_medium=referral&utm_content=tracking), [LinkedIn](https://www.linkedin.com/company/themehigh/?utm_source=wordpress&utm_medium=referral&utm_content=tracking), [Twitter](https://twitter.com/themehigh/?utm_source=wordpress&utm_medium=referral&utm_content=tracking) & [YouTube](https://www.youtube.com/channel/UC-_uMXaC_21j1Y2_nGjTyvg/?utm_source=wordpress&utm_medium=referral&utm_content=tracking).
152
 
@@ -204,9 +245,16 @@ Yes. There is a button 'reset to default fields' to go back to the WooCommerce d
204
  5. Edit field popup form
205
  6. Rearrange fields (change field's display order)
206
  7. Reset to default settings
207
- 8. Save changes.
 
208
 
209
  == Changelog ==
 
 
 
 
 
 
210
  = 1.4.8 =
211
  * Added backward compatibility with PHP 5.6.
212
 
3
  Donate link: https://themehigh.com/
4
  Tags: checkout field editor, woocommerce checkout field editor, checkout manager, woocommerce checkout manager, checkout field customizer, checkout form editor, checkout form customizer, checkout, WooCommerce checkout, checkout form designer, woocommerce checkout fields, woocommerce checkout addons
5
  Requires at least: 4.9
6
+ Tested up to: 5.8
7
  Requires PHP: 5.6
8
+ Stable tag: 1.4.9
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
14
  == Description ==
15
 
16
  = Checkout Field Editor for WooCommerce =
17
+ WooCommerce Checkout Field Editor (Checkout Manager) Plugin lets you add 7 different types of custom checkout fields to your Checkout page, blended with a simple and user-friendly interface.
18
+
19
+ It enables you to edit the default checkout fields of your WooCommerce platform, add new custom fields in the three sections (namely Billing, Shipping and Additional), edit, hide, or delete the default fields, change labels, rearrange checkout fields, validate the checkout fields, add custom css classes etc.
20
+
21
+ [Try the Demo](https://flydemos.com/wcfe/?utm_source=wordpress&utm_medium=referral&utm_content=tracking) | [Documents](https://help.themehigh.com/hc/en-us/categories/900000285646-Checkout-Field-Editor) | [Pro Version](https://www.themehigh.com/product/woocommerce-checkout-field-editor-pro/)
22
 
23
  --------------------------------------------
24
  https://www.youtube.com/watch?v=_iKMe5lGIIM
25
  --------------------------------------------
26
 
27
+ = Key Features =
28
+ = ☞ Custom Checkout field(s) =
29
+ Add additional fields to your Checkout page using the Checkout Manager plugin. You can add seven different types of checkout fields in your WooCommerce checkout page and collect more information from the end-user. The various field types it supports include:
30
+
31
+ * Text
32
+ * Password
33
+ * Email
34
+ * Phone
35
+ * Select
36
+ * Textarea
37
+ * Radio
38
 
39
  = ☞ Edit field(s) =
40
+ Edit the custom fields as per the varying business requirements, including the default ones.
41
 
42
+ = Delete Field(s) =
43
+ Delete the default WooCommerce checkout fields if needed.
44
 
45
+ = Enable/Disable field(s) =
46
+ Enable/Disable your custom checkout fields with an easy checkbox option.
47
+
48
+ = ☞ Repositioning Checkout fields =
49
+ Display your Checkout fields at different locations with easy-to-handle drag and drop options.
50
+
51
+ = ☞ Add Custom CSS Class =
52
+ Style your checkout form as per your requirements with simple steps, if you wish to improve your customer engagement.
53
+
54
+ = ☞ Display in Emails and Order Details Pages =
55
+ Showcase or hide the custom checkout fields in the Order Details Page or in your emails using the checkbox option.
56
+
57
+ = ☞ Validate the Checkout Fields =
58
+ Validate the custom checkout fields (including the default ones), and never miss any valuable information from the user.
59
+
60
+ = ☞ Override Address Fields =
61
+ By default, WooCommerce will change the address format based on the countries. Using this plugin, you can prevent the override address field properties and use the values set using the Checkout Manager plugin.
62
+
63
+ = ☞ Reset to default fields =
64
+ Using this plugin, you can reset to the original state with the default fields on a single click.
65
+
66
+ == 💎💎 Upgrade to Premium Version Now! ==
67
+ The premium version of WooCommerce Checkout Field Editor (Checkout Manager) Plugin lets you add 17 different types of custom checkout fields and sections to your Checkout page, and make the best out of your Checkout form.
68
+
69
+ A range of advanced features that it delivers include 17 custom checkout field types, display sections and fields conditionally, custom validations, compatibility with third-party plugins, developer friendliness with custom hooks, change address display format, price fields with a set of price types etc.
70
+
71
+ == Premium Features ==
72
+
73
+ = ☞ Custom Checkout Sections =
74
+ Add custom checkout sections apart from the three default sections, viz., Billing, Shipping and Additional sections. The Pro version stands apart from the free version with the same functionality.
75
+
76
+ = ☞ 17 Custom field types with File Upload =
77
+ The Pro version of WooCommerce Checkout Manager supports upto 17 field types, including the File Upload option. The 17 field types it supports are:
78
+
79
+ 1. Text
80
+ 2. Hidden
81
+ 3. Password
82
+ 4. Telephone
83
+ 5. Email
84
+ 6. Number
85
+ 7. Textarea
86
+ 8. Select
87
+ 9. Multi Select
88
+ 10. Radio
89
+ 11. Checkbox
90
+ 12. Checkbox Group
91
+ 13. Date picker
92
+ 14. Time picker
93
+ 15. File Upload
94
+ 16. Heading
95
+ 17. Label
96
+
97
+ = ☞ Display custom fields at 14 different positions =
98
+ The free version of the plugin limits the user to display the custom checkout field at only certain positions. The Premium version allows you to display them at 14 different locations. Following are the positions where these checkout sections can be displayed:
99
+
100
+ 1. Before customer details
101
+ 2. After customer details
102
+ 3. Before billing form
103
+ 4. After billing form
104
+ 5. Before shipping form
105
+ 6. After shipping form
106
+ 7. Before registration form
107
+ 8. After registration form
108
+ 9. Before order notes
109
+ 10. After order notes
110
+ 11. Before terms and conditions
111
+ 12. After terms and conditions
112
+ 13. Before submit button
113
+ 14. After submit button
114
+ 15. Inside a custom step created using WooCommerce MultiStep Checkout
115
+
116
+ = ☞ Display Sections and Fields Conditionally =
117
+ The various custom fields can be displayed only if a set of conditions are met. Following are the conditions with which the fields can be displayed conditionally:
118
+
119
+ * Cart Contents
120
+ * Cart Subtotal
121
+ * Cart Total
122
+ * User Roles
123
+ * Product
124
+ * Product Variation
125
+ * Product Category
126
+ * Based on other field values
127
 
128
+ = ☞ Custom Validations =
129
+ The WooCommerce Checkout Field Editor comes with options to validate the checkout fields before placing the order. Besides the default validations, you can create custom validators to validate your checkout fields.
130
 
131
+ = ☞ Create Confirm Field Validators =
132
+ Using this plugin, you can create confirm field validators and compare the values of two different fields. For example, password and confirm password are the two fields that need to be compared to know whether both the field values match each other.
133
 
134
+ = ☞ Price Fields With A Set of Price Types =
135
+ Add an extra price value to the total price by adding a field with price into the checkout form. You can also add predefined fixed prices using hidden field type in WooCommerce Checkout. Following price types can be added to WooCommerce checkout fields:
136
+
137
+ * *Fixed Price*: Set a fixed price for the addon (Extra Field). This fixed amount will be added to the total product price upon selecting the addon.
138
+ * *Custom Price*: A price entered by the user will be added to the product price. This will help you receive donations, tips and similar things.
139
+ * *Percentage of Cart Total*: Set the addon price in percentage of the cart total. The specificified percentage amount of the product price will be added to the product price.
140
+ * *Percentage of Subtotal*: Set the addon price in percentage of the sub total. The corresponding percentage amount of the product price will be added to the product price.
141
+ * *Percent of Subtotal excluding tax*: Set the addon price in percentage of the subtotal excluding tax price in your locality. So,the corresponding percentage amount of the product price will be added to the subtotal during checkout.
142
+ * *Dynamic Price*: Set the price per ‘n’ number of units. Then the addon price will be calculated for the total number units selected by the customer and added to the product price.
143
+
144
+ = Change Address Display Format =
145
+ With the WooCommerce Checkout Field Editor, change the address formats displayed in the Addresses in My Account page, Thank You page and Transactional Emails. The custom fields created using the plugin can also be included in the addresses using the override feature.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
 
147
+ = ☞ Set Repeat Rules =
148
+ The pro version of the Woocomerce Checkout Manager plugin lets you set repeat rules for the custom fields and sections created based on various criteria like Product Quantity and Cart Count.
149
 
150
+ = ☞ Developer Friendly =
151
+ All the custom fields in the Checkout Field Editor are available through hooks. So, the developers can use the checkout fields to extend the functionality of the fields.
152
 
153
+ = ☞ Compatibility with third-party plugins =
154
+ Pro version of the plugin supports multiple third-party plugins, so as to benefit the user the best from us. Some of them include:
155
 
156
+ *WooCommerce PDF Invoices & Packing Slips*: The custom fields created in your Checkout forms can be included in the PDF invoices and packing slips that you provide to the customers. Thus, it allows you to include a set of valuable information to the customers through bills or invoices.
 
 
 
 
 
 
 
 
 
 
 
 
 
157
 
158
+ *WooCommerce Customer / Order CSV Export*: With this WooCommerce plugin, one can download the orders made by the customer in CSV format. Our plugin allows you to include the custom fields in these data and thus download it.
 
159
 
160
+ *Zapier Support*: Another important aspect of the Pro version of WooCommerce Checkout Manager includes that it supports online automation tool Zapier. Zapier allows you to integrate multiple applications and thus makes your job easier to complete. No worries, we do support Zapier!
161
+
162
+ *Multi-language Support*: Supporting multiple languages has become an important aspect of the present world, since there are still a lot of people who are not comfortable with the English language. Since our plugin is compatible with the WordPress Multilingual Plugin (WPML), we support multiple languages too.
163
 
164
  --------------------------------------------
165
  *For the complete list of features, Please visit [WooCommerce Checkout Field Editor (Checkout Manager)](https://www.themehigh.com/product/woocommerce-checkout-field-editor-pro/?utm_source=wordpress&utm_medium=referral&utm_content=tracking) plugin's official page.*
166
 
167
+ Check how it works: 🔗 [Live Demo](https://flydemos.com/wcfe/?utm_source=wordpress&utm_medium=referral&utm_content=tracking)
168
  --------------------------------------------
169
 
170
  == Why ThemeHigh ==
187
  For more info on ThemeHigh and WooCommerce Checkout Field Editor plugin in specific, check out the following:
188
 
189
  * The [Checkout Field Editor (Checkout Manager) for WooCommerce](https://www.themehigh.com/product/woocommerce-checkout-field-editor-pro/?utm_source=wordpress&utm_medium=referral&utm_content=tracking) premium plugin homepage.
190
+ * The [Knowledgebase](https://help.themehigh.com/hc/en-us/categories/900000285646-Checkout-Field-Editor).
191
  * Other [WordPress Plugins](https://www.themehigh.com/plugins/?utm_source=wordpress&utm_medium=referral&utm_content=tracking) by the ThemeHigh team.
192
  * Follow ThemeHigh on [Facebook](https://www.facebook.com/ThemeHigh-319611541768603/?utm_source=wordpress&utm_medium=referral&utm_content=tracking), [LinkedIn](https://www.linkedin.com/company/themehigh/?utm_source=wordpress&utm_medium=referral&utm_content=tracking), [Twitter](https://twitter.com/themehigh/?utm_source=wordpress&utm_medium=referral&utm_content=tracking) & [YouTube](https://www.youtube.com/channel/UC-_uMXaC_21j1Y2_nGjTyvg/?utm_source=wordpress&utm_medium=referral&utm_content=tracking).
193
 
245
  5. Edit field popup form
246
  6. Rearrange fields (change field's display order)
247
  7. Reset to default settings
248
+ 8. Save changes
249
+ 9. Locale override settings
250
 
251
  == Changelog ==
252
+ = 1.4.9 =
253
+ * Added security improvements.
254
+ * Added compatibility with PHP 8 version.
255
+ * Added WooCommerce version - 5.6.0 compatibility.
256
+ * Added WordPress version - 5.8 compatibility.
257
+
258
  = 1.4.8 =
259
  * Added backward compatibility with PHP 5.6.
260