Easy Digital Downloads - Version 2.7.5

Version Description

Download this release

Release Info

Developer mordauk
Plugin Icon 128x128 Easy Digital Downloads
Version 2.7.5
Comparing to
See all releases

Code changes from version 2.7.4 to 2.7.5

assets/js/admin-scripts.js CHANGED
@@ -421,8 +421,7 @@ jQuery(document).ready(function ($) {
421
  }
422
 
423
  if( confirm( edd_vars.delete_payment_download ) ) {
424
- var key = $(this).data('key');
425
-
426
  var purchase_id = $('.edd-payment-id').val();
427
  var download_id = $('input[name="edd-payment-details-downloads['+key+'][id]"]').val();
428
  var price_id = $('input[name="edd-payment-details-downloads['+key+'][price_id]"]').val();
@@ -591,6 +590,8 @@ jQuery(document).ready(function ($) {
591
  $( this ).attr( 'name', name ).attr( 'id', name );
592
  });
593
 
 
 
594
  // Flag the Downloads section as changed
595
  $('#edd-payment-downloads-changed').val(1);
596
 
421
  }
422
 
423
  if( confirm( edd_vars.delete_payment_download ) ) {
424
+ var key = $(this).data('key');
 
425
  var purchase_id = $('.edd-payment-id').val();
426
  var download_id = $('input[name="edd-payment-details-downloads['+key+'][id]"]').val();
427
  var price_id = $('input[name="edd-payment-details-downloads['+key+'][price_id]"]').val();
590
  $( this ).attr( 'name', name ).attr( 'id', name );
591
  });
592
 
593
+ clone.find('a.edd-order-remove-download').attr( 'data-key', parseInt( count ) );
594
+
595
  // Flag the Downloads section as changed
596
  $('#edd-payment-downloads-changed').val(1);
597
 
assets/js/admin-scripts.min.js CHANGED
@@ -1,2 +1,2 @@
1
- jQuery(document).ready(function(a){a(".edd-help-tip").tooltip({content:function(){return a(this).prop("title")},tooltipClass:"edd-ui-tooltip",position:{my:"center top",at:"center bottom+10",collision:"flipfit"},hide:{duration:200},show:{duration:200}});var b={init:function(){this.add(),this.move(),this.remove(),this.type(),this.prices(),this.files(),this.updatePrices()},clone_repeatable:function(b){var c=highest=1;return b.parent().find("tr.edd_repeatable_row").each(function(){var b=a(this).data("key");parseInt(b)>highest&&(highest=b)}),c=highest+=1,clone=b.clone(),clone.find("select").each(function(){a(this).val(b.find('select[name="'+a(this).attr("name")+'"]').val())}),clone.removeClass("edd_add_blank"),clone.attr("data-key",c),clone.find("td input, td select, textarea").val(""),clone.find("input, select, textarea").each(function(){var b=a(this).attr("name"),d=a(this).attr("id");b&&(b=b.replace(/\[(\d+)\]/,"["+parseInt(c)+"]"),a(this).attr("name",b)),a(this).attr("data-key",c),"undefined"!=typeof d&&(d=d.replace(/(\d+)/,parseInt(c)),a(this).attr("id",d))}),clone.find("span.edd_price_id").each(function(){a(this).text(parseInt(c))}),clone.find("span.edd_file_id").each(function(){a(this).text(parseInt(c))}),clone.find(".edd_repeatable_default_input").each(function(){a(this).val(parseInt(c)).removeAttr("checked")}),clone.find(".edd_repeatable_condition_field").each(function(){a(this).find("option:eq(0)").prop("selected","selected")}),clone.find(".search-choice").remove(),clone.find(".chosen-container").remove(),clone},add:function(){a(document.body).on("click",".submit .edd_add_repeatable",function(c){c.preventDefault();var d=a(this),e=d.parent().parent().prev("tr"),f=b.clone_repeatable(e);f.insertAfter(e).find("input, textarea, select").filter(":visible").eq(0).focus(),f.find(".edd-select-chosen").chosen({inherit_select_classes:!0,placeholder_text_single:edd_vars.one_option,placeholder_text_multiple:edd_vars.one_or_more_option}),f.find(".edd-select-chosen").css("width","100%"),f.find(".edd-select-chosen .chosen-search input").attr("placeholder",edd_vars.search_placeholder)})},move:function(){a(".edd_repeatable_table tbody").sortable({handle:".edd_draghandle",items:".edd_repeatable_row",opacity:.6,cursor:"move",axis:"y",update:function(){var b=0;a(this).find("tr").each(function(){a(this).find("input.edd_repeatable_index").each(function(){a(this).val(b)}),b++})}})},remove:function(){a(document.body).on("click",".edd_remove_repeatable",function(b){b.preventDefault();var g,h,i,c=a(this).parent().parent("tr"),d=c.parent().find("tr").length-1,e=a(this).data("type"),f="tr.edd_repeatable_"+e+"s";if(g=a(this).is(".ui-sortable tr:first-child .edd_remove_repeatable:first-child")?c.next("tr"):c.prev("tr"),h=g.find("select, input, textarea, button").filter(":visible"),i=h.eq(0),"price"===e){var j=c.data("key");a('.edd_repeatable_condition_field option[value="'+j+'"]').remove()}if(d>1)a("input, select",c).val(""),c.fadeOut("fast").remove(),i.focus();else switch(e){case"price":alert(edd_vars.one_price_min);break;case"file":a("input, select",c).val("");break;default:alert(edd_vars.one_field_min)}a(f).each(function(b){a(this).find("input, select").each(function(){var c=a(this).attr("name");c=c.replace(/\[(\d+)\]/,"["+b+"]"),a(this).attr("name",c).attr("id",c)})})})},type:function(){a(document.body).on("change","#_edd_product_type",function(b){var c=a("#edd_products"),d=a("#edd_download_files"),e=a("#edd_download_limit_wrap");"bundle"===a(this).val()?(c.show(),d.hide(),e.hide()):(c.hide(),d.show(),e.show())})},prices:function(){a(document.body).on("change","#edd_variable_pricing",function(b){var c=a(this).is(":checked"),d=a("#edd_regular_price_field"),e=a("#edd_variable_price_fields,.edd_repeatable_table .pricing");c?(d.hide(),e.show()):(d.show(),e.hide())})},files:function(){var c;window.formfield="",a(document.body).on("click",".edd_upload_file_button",function(d){d.preventDefault();var e=a(this);return window.formfield=a(this).closest(".edd_repeatable_upload_wrapper"),c?void c.open():(c=wp.media.frames.file_frame=wp.media({frame:"post",state:"insert",title:e.data("uploader-title"),button:{text:e.data("uploader-button-text")},multiple:"0"!=a(this).data("multiple")}),c.on("menu:render:default",function(a){var b={};a.unset("library-separator"),a.unset("gallery"),a.unset("featured-image"),a.unset("embed"),a.set(b)}),c.on("insert",function(){var d=c.state().get("selection");d.each(function(c,d){c=c.toJSON();var e="image"===c.type&&a(".attachment-display-settings .size option:selected").val(),f=c.url,g=c.title.length>0?c.title:c.filename;if(e&&"undefined"!=typeof c.sizes[e]&&(f=c.sizes[e].url),"image"===c.type&&(g=e&&"undefined"!=typeof c.sizes[e]?g+"-"+c.sizes[e].width+"x"+c.sizes[e].height:g+"-"+c.width+"x"+c.height),0===d)window.formfield.find(".edd_repeatable_attachment_id_field").val(c.id),window.formfield.find(".edd_repeatable_thumbnail_size_field").val(e),window.formfield.find(".edd_repeatable_upload_field").val(f),window.formfield.find(".edd_repeatable_name_field").val(g);else{var h=window.formfield,i=b.clone_repeatable(h);i.find(".edd_repeatable_attachment_id_field").val(c.id),i.find("edd_repeatable_thumbnail_size_field").val(e),i.find(".edd_repeatable_upload_field").val(f),i.find(".edd_repeatable_name_field").val(g),i.insertAfter(h)}})}),void c.open())});var c;window.formfield=""},updatePrices:function(){a("#edd_price_fields").on("keyup",".edd_variable_prices_name",function(){var b=a(this).parents("tr").data("key"),c=a(this).val(),d=a(".edd_repeatable_condition_field option[value="+b+"]");d.length>0?d.text(c):a(".edd_repeatable_condition_field").append(a("<option></option>").attr("value",b).text(c))})}};b.init();var c=a(".edd_datepicker");if(c.length>0){var d="mm/dd/yy";c.datepicker({dateFormat:d})}var e={init:function(){this.edit_address(),this.remove_download(),this.add_download(),this.change_customer(),this.new_customer(),this.edit_price(),this.recalculate_total(),this.variable_prices_check(),this.add_note(),this.remove_note(),this.resend_receipt(),this.copy_download_link()},edit_address:function(){a('select[name="edd-payment-address[0][country]"]').change(function(){var b=a(this);return data={action:"edd_get_shop_states",country:b.val(),field_name:"edd-payment-address[0][state]"},a.post(ajaxurl,data,function(b){var c=a("#edd-order-address-state-wrap select, #edd-order-address-state-wrap input");a("#edd-order-address-state-wrap .chosen-container").remove(),"nostates"==b?c.replaceWith('<input type="text" name="edd-payment-address[0][state]" value="" class="edd-edit-toggles medium-text"/>'):c.replaceWith(b)}),!1})},remove_download:function(){a("#edd-purchased-files").on("click",".edd-order-remove-download",function(){var b=a(document.body).find("#edd-purchased-files > .row").length;if(1===b)return alert(edd_vars.one_download_min),!1;if(confirm(edd_vars.delete_payment_download)){var c=a(this).data("key"),e=(a(".edd-payment-id").val(),a('input[name="edd-payment-details-downloads['+c+'][id]"]').val()),f=a('input[name="edd-payment-details-downloads['+c+'][price_id]"]').val(),g=a('input[name="edd-payment-details-downloads['+c+'][quantity]"]').val(),h=a('input[name="edd-payment-details-downloads['+c+'][amount]"]').val();if(a('input[name="edd-payment-details-downloads['+c+'][tax]"]'))var i=a('input[name="edd-payment-details-downloads['+c+'][tax]"]').val();if(a('input[name="edd-payment-details-downloads['+c+'][fees]"]'))var i=a.parseJSON(a('input[name="edd-payment-details-downloads['+c+'][fees]"]').val());var j=a('input[name="edd-payment-removed"]').val();j=a.parseJSON(j),j.length<1&&(j={});var k=[{id:e,price_id:f,quantity:g,amount:h,cart_index:c}];j[c]=k,a('input[name="edd-payment-removed"]').val(JSON.stringify(j)),a(this).parent().parent().remove(),i&&i.length&&a.each(i,function(b,c){a('*li[data-fee-id="'+c+'"]').remove()}),a("#edd-payment-downloads-changed").val(1),a(".edd-order-payment-recalc-totals").show()}return!1})},change_customer:function(){a("#edd-customer-details").on("click",".edd-payment-change-customer, .edd-payment-change-customer-cancel",function(b){b.preventDefault();var c=a(this).hasClass("edd-payment-change-customer"),d=a(this).hasClass("edd-payment-change-customer-cancel");c?(a(".customer-info").hide(),a(".change-customer").show(),a(".edd-payment-change-customer-input").css("width","auto")):d&&(a(".customer-info").show(),a(".change-customer").hide())})},new_customer:function(){a("#edd-customer-details").on("click",".edd-payment-new-customer, .edd-payment-new-customer-cancel",function(b){b.preventDefault();var c=a(this).hasClass("edd-payment-new-customer"),d=a(this).hasClass("edd-payment-new-customer-cancel");c?(a(".customer-info").hide(),a(".new-customer").show()):d&&(a(".customer-info").show(),a(".new-customer").hide());var c=a("#edd-new-customer");a(".new-customer").is(":visible")?c.val(1):c.val(0)})},add_download:function(){a(".edd-edit-purchase-element").on("click","#edd-order-add-download",function(b){b.preventDefault();var c=a("#edd_order_download_select"),d=a("#edd-order-download-quantity"),e=a("#edd-order-download-price"),f=a("#edd-order-download-tax"),g=a(".edd_price_options_select option:selected"),h=c.val(),i=c.find(":selected").text(),j=d.val(),k=e.val(),l=f.val(),m=g.val(),n=g.text();if(h<1)return!1;if(k||(k=0),k=parseFloat(k),isNaN(k))return alert(edd_vars.numeric_item_price),!1;if(l=parseFloat(l),isNaN(l))return alert(edd_vars.numeric_item_tax),!1;if(isNaN(parseInt(j)))return alert(edd_vars.numeric_quantity),!1;n&&(i=i+" - "+n);var o=a("#edd-purchased-files div.row").length,p=a("#edd-purchased-files div.row:last").clone();p.find(".download span").html('<a href="post.php?post='+h+'&action=edit"></a>'),p.find(".download span a").text(i),p.find(".edd-payment-details-download-item-price").val(k.toFixed(edd_vars.currency_decimals)),p.find(".edd-payment-details-download-item-tax").val(l.toFixed(edd_vars.currency_decimals)),p.find("input.edd-payment-details-download-id").val(h),p.find("input.edd-payment-details-download-price-id").val(m);var q=k*j+l;q=q.toFixed(edd_vars.currency_decimals),p.find("span.edd-payment-details-download-amount").text(q),p.find("input.edd-payment-details-download-amount").val(q),p.find("input.edd-payment-details-download-quantity").val(j),p.find("input.edd-payment-details-download-has-log").val(0),p.find(".edd-copy-download-link-wrapper").remove(),p.find("input").each(function(){var b=a(this).attr("name");b=b.replace(/\[(\d+)\]/,"["+parseInt(o)+"]"),a(this).attr("name",b).attr("id",b)}),a("#edd-payment-downloads-changed").val(1),a(p).insertAfter("#edd-purchased-files div.row:last"),a(".edd-order-payment-recalc-totals").show(),a(".edd-add-download-field").val("")})},edit_price:function(){a(document.body).on("change keyup",".edd-payment-item-input",function(){var b=a(this).parents("ul.edd-purchased-files-list-wrapper");a(".edd-order-payment-recalc-totals").show();var c=b.find("input.edd-payment-details-download-quantity").val(),d=b.find("input.edd-payment-details-download-item-price").val(),e=b.find("input.edd-payment-details-download-item-tax").val();if(d=parseFloat(d),isNaN(d))return alert(edd_vars.numeric_item_price),!1;e=parseFloat(e),isNaN(e)&&(e=0),isNaN(parseInt(c))&&(c=1);var f=d*c+e;f=f.toFixed(edd_vars.currency_decimals),b.find("input.edd-payment-details-download-amount").val(f),b.find("span.edd-payment-details-download-amount").text(f)})},recalculate_total:function(){a("#edd-order-recalc-total").on("click",function(b){b.preventDefault();var c=0,d=0,e=a("#edd-purchased-files .row input.edd-payment-details-download-amount"),f=a("#edd-purchased-files .row input.edd-payment-details-download-item-tax");e.length&&e.each(function(){c+=parseFloat(a(this).val())}),f.length&&f.each(function(){d+=parseFloat(a(this).val())}),a(".edd-payment-fees").length&&a(".edd-payment-fees span.fee-amount").each(function(){c+=parseFloat(a(this).data("fee"))}),a("input[name=edd-payment-total]").val(c.toFixed(edd_vars.currency_decimals)),a("input[name=edd-payment-tax]").val(d.toFixed(edd_vars.currency_decimals))})},variable_prices_check:function(){a(".edd-edit-purchase-element").on("change","select#edd_order_download_select",function(){var b=a(this),c=b.val();if(parseInt(c)>0){var d={action:"edd_check_for_download_price_variations",download_id:c};a.ajax({type:"POST",data:d,url:ajaxurl,success:function(c){a(".edd_price_options_select").remove(),a(c).insertAfter(b.next())}}).fail(function(a){window.console&&window.console.log&&console.log(a)})}})},add_note:function(){a("#edd-add-payment-note").on("click",function(b){b.preventDefault();var c={action:"edd_insert_payment_note",payment_id:a(this).data("payment-id"),note:a("#edd-payment-note").val()};if(c.note)a.ajax({type:"POST",data:c,url:ajaxurl,success:function(b){a("#edd-payment-notes-inner").append(b),a(".edd-no-payment-notes").hide(),a("#edd-payment-note").val("")}}).fail(function(a){window.console&&window.console.log&&console.log(a)});else{var d=a("#edd-payment-note").css("border-color");a("#edd-payment-note").css("border-color","red"),setTimeout(function(){a("#edd-payment-note").css("border-color",d)},500)}})},remove_note:function(){a(document.body).on("click",".edd-delete-payment-note",function(b){if(b.preventDefault(),confirm(edd_vars.delete_payment_note)){var c={action:"edd_delete_payment_note",payment_id:a(this).data("payment-id"),note_id:a(this).data("note-id")};return a.ajax({type:"POST",data:c,url:ajaxurl,success:function(b){return a("#edd-payment-note-"+c.note_id).remove(),a(".edd-payment-note").length||a(".edd-no-payment-notes").show(),!1}}).fail(function(a){window.console&&window.console.log&&console.log(a)}),!0}})},resend_receipt:function(){var b=a(".edd-order-resend-receipt-addresses");a(document.body).on("click","#edd-select-receipt-email",function(a){a.preventDefault(),b.slideDown()}),a(document.body).on("change",".edd-order-resend-receipt-email",function(){var b=a("#edd-select-receipt-email").prop("href")+"&email="+a(this).val();confirm(edd_vars.resend_receipt)&&(window.location=b)}),a(document.body).on("click","#edd-resend-receipt",function(a){return confirm(edd_vars.resend_receipt)})},copy_download_link:function(){a(document.body).on("click",".edd-copy-download-link",function(b){b.preventDefault();var c=a(this),d={action:"edd_get_file_download_link",payment_id:a('input[name="edd_payment_id"]').val(),download_id:c.data("download-id"),price_id:c.data("price-id")};a.ajax({type:"POST",data:d,url:ajaxurl,success:function(b){return a("#edd-download-link").dialog({width:400}).html('<textarea rows="10" cols="40" id="edd-download-link-textarea">'+b+"</textarea>"),a("#edd-download-link-textarea").focus().select(),!1}}).fail(function(a){window.console&&window.console.log&&console.log(a)})})}};e.init();var f={init:function(){this.type_select(),this.product_requirements()},type_select:function(){a("#edd-edit-discount #edd-type, #edd-add-discount #edd-type").change(function(){var b=a(this).val();a(".edd-amount-description").hide(),a(".edd-amount-description."+b+"-discount").show()})},product_requirements:function(){a("#products").change(function(){var b=a("#edd-discount-product-conditions");a(this).val()?b.show():b.hide()})}};f.init();var g={init:function(){this.date_options(),this.customers_export()},date_options:function(){a("#edd-graphs-date-options").change(function(){var b=a(this),c=a("#edd-date-range-options");"other"===b.val()?c.show():c.hide()})},customers_export:function(){a("#edd_customer_export_download").change(function(){var b=a(this),c=a("option:selected",b).val(),d=a("#edd_customer_export_option");if("0"===b.val()?d.show():d.hide(),0!=parseInt(c)){var e={action:"edd_check_for_download_price_variations",download_id:c,all_prices:!0},f=a(".edd_price_options_select");a.post(ajaxurl,e,function(b){f.remove(),a("#edd_customer_export_download_chosen").after(b)})}else f.remove()})}};g.init();var h={init:function(){this.general(),this.taxes(),this.emails(),this.misc()},general:function(){var b=a(".edd-color-picker");if(b.length&&b.wpColorPicker(),"undefined"==typeof wp||"1"!==edd_vars.new_media_ui){var c=a(".edd_settings_upload_button");c.length>0&&(window.formfield="",a(document.body).on("click",c,function(b){b.preventDefault(),window.formfield=a(this).parent().prev(),window.tbframe_interval=setInterval(function(){jQuery("#TB_iframeContent").contents().find(".savesend .button").val(edd_vars.use_this_file).end().find("#insert-gallery, .wp-post-thumbnail").hide()},2e3),tb_show(edd_vars.add_new_download,"media-upload.php?TB_iframe=true")}),window.edd_send_to_editor=window.send_to_editor,window.send_to_editor=function(b){window.formfield?(imgurl=a("a","<div>"+b+"</div>").attr("href"),window.formfield.val(imgurl),window.clearInterval(window.tbframe_interval),tb_remove()):window.edd_send_to_editor(b),window.send_to_editor=window.edd_send_to_editor,window.formfield="",window.imagefield=!1})}else{var d;window.formfield="",a(document.body).on("click",".edd_settings_upload_button",function(b){b.preventDefault();var c=a(this);return window.formfield=a(this).parent().prev(),d?void d.open():(d=wp.media.frames.file_frame=wp.media({frame:"post",state:"insert",title:c.data("uploader_title"),button:{text:c.data("uploader_button_text")},multiple:!1}),d.on("menu:render:default",function(a){var b={};a.unset("library-separator"),a.unset("gallery"),a.unset("featured-image"),a.unset("embed"),a.set(b)}),d.on("insert",function(){var a=d.state().get("selection");a.each(function(a,b){a=a.toJSON(),window.formfield.val(a.url)})}),void d.open())});var d;window.formfield=""}},taxes:function(){var b=a("select.edd-no-states");b.length&&b.closest("tr").hide(),a('select[name="edd_settings[base_country]"]').change(function(){var b=a(this),c=b.closest("tr");return data={action:"edd_get_shop_states",country:a(this).val(),field_name:"edd_settings[base_state]"},a.post(ajaxurl,data,function(a){"nostates"==a?c.next().hide():(c.next().show(),c.next().find("select").replaceWith(a))}),!1}),a(document.body).on("change","#edd_tax_rates select.edd-tax-country",function(){var b=a(this);return data={action:"edd_get_shop_states",country:a(this).val(),field_name:b.attr("name").replace("country","state")},a.post(ajaxurl,data,function(a){if("nostates"==a){var c='<input type="text" name="'+data.field_name+'" value=""/>';b.parent().next().find("select").replaceWith(c)}else b.parent().next().find("input,select").show(),b.parent().next().find("input,select").replaceWith(a)}),!1}),a("#edd_add_tax_rate").on("click",function(){var b=a("#edd_tax_rates tr:last"),c=b.clone(),d=b.parent().find("tr").length;return c.find("td input").not(":input[type=checkbox]").val(""),c.find('td [type="checkbox"]').attr("checked",!1),c.find("input, select").each(function(){var b=a(this).attr("name");b=b.replace(/\[(\d+)\]/,"["+parseInt(d)+"]"),a(this).attr("name",b).attr("id",b)}),c.find("label").each(function(){var b=a(this).attr("for");b=b.replace(/\[(\d+)\]/,"["+parseInt(d)+"]"),a(this).attr("for",b)}),c.insertAfter(b),!1}),a(document.body).on("click","#edd_tax_rates .edd_remove_tax_rate",function(){if(confirm(edd_vars.delete_tax_rate)){var b=a("#edd_tax_rates tr:visible"),c=b.length;2===c?(a("#edd_tax_rates select").val(""),a('#edd_tax_rates input[type="text"]').val(""),a('#edd_tax_rates input[type="number"]').val(""),a('#edd_tax_rates input[type="checkbox"]').attr("checked",!1)):a(this).closest("tr").remove(),a("#edd_tax_rates tr").each(function(b){a(this).children().find("input, select").each(function(){var c=a(this).attr("name");c=c.replace(/\[(\d+)\]/,"["+(b-1)+"]"),a(this).attr("name",c).attr("id",c)})})}return!1})},emails:function(){var b=a("#email-preview-wrap");if(b.length){var c=a("#email-preview");b.colorbox({inline:!0,href:c,width:"80%",height:"auto"})}},misc:function(){var b=a('select[name="edd_settings[download_method]"]'),c=b.parent().parent().next();"direct"==b.val()&&(c.hide(),c.find("input").prop("checked",!1)),b.on("change",function(){"direct"==a(this).val()?(c.hide(),c.find("input").prop("checked",!1)):c.show()})}};h.init(),a(".download_page_edd-payment-history .row-actions .delete a, a.edd-delete-payment").on("click",function(){return!!confirm(edd_vars.delete_payment)}),a("#the-list").on("click",".editinline",function(){var b=a(this).closest("tr").attr("id");b=b.replace("post-","");var c=a("#post-"+b),d=c.find(".column-price .downloadprice-"+b).val();d!=a("#post-"+b+".column-price .downloadprice-"+b).val()?a(".regprice","#edd-download-data").val(d).attr("disabled",!1):a(".regprice","#edd-download-data").val(edd_vars.quick_edit_warning).attr("disabled","disabled")}),a(document.body).on("click","#bulk_edit",function(){var b=a("#bulk-edit"),c=new Array;b.find("#bulk-titles").children().each(function(){c.push(a(this).attr("id").replace(/^(ttle)/i,""))});var d=a('#edd-download-data input[name="_edd_regprice"]').val(),e={action:"edd_save_bulk_edit",edd_bulk_nonce:c,post_ids:c,price:d};a.post(ajaxurl,e)}),a(".edd-select-chosen").chosen({inherit_select_classes:!0,placeholder_text_single:edd_vars.one_option,placeholder_text_multiple:edd_vars.one_or_more_option}),a(".edd-select-chosen .chosen-search input").each(function(){var b=a(this).parent().parent().parent().prev("select.edd-select-chosen").data("search-type"),c="";if("download"===b)c=edd_vars.search_placeholder;else{var b="search_placeholder_"+b;edd_vars[b]&&(c=edd_vars[b])}a(this).attr("placeholder",c)}),a(".chosen-choices").on("click",function(){a(this).children("li").children("input").attr("placeholder",edd_vars.type_to_search)});var i,j=342;a(document.body).on("keyup",".edd-select.chosen-container .chosen-search input, .edd-select.chosen-container .search-field input",function(b){var c=a(this).val(),d=a(this).closest(".edd-select-chosen"),e=d.attr("id").replace("_chosen",""),f=d.hasClass("no-bundles"),g=d.hasClass("variations"),h=b.which,k="edd_download_search";if(d.prev().data("search-type")){if("no_ajax"==d.prev().data("search-type"))return;k="edd_"+d.prev().data("search-type")+"_search"}c.length<=3&&"edd_download_search"==k||16==h||13==h||91==h||17==h||37==h||38==h||39==h||40==h||(clearTimeout(i),i=setTimeout(function(){a.ajax({type:"GET",url:ajaxurl,data:{action:k,s:c,no_bundles:f,variations:g},dataType:"json",beforeSend:function(){a("ul.chosen-results").empty()},success:function(b){a("#"+e+" option:not(:selected)").remove(),a.each(b,function(b,c){a("#"+e+' option[value="'+c.id+'"]').length||a("#"+e).prepend('<option value="'+c.id+'">'+c.name+"</option>")}),a(".edd-select-chosen").trigger("chosen:updated"),a("#"+e).next().find("input").val(c)}}).fail(function(a){window.console&&window.console.log&&console.log(a)}).done(function(a){})},j))}),a("#post").on("click",".edd-thickbox",function(){a(".edd-select-chosen","#choose-download").css("width","100%")});var k={init:function(){this.revoke_api_key(),this.regenerate_api_key(),this.create_api_key(),this.recount_stats()},revoke_api_key:function(){a(document.body).on("click",".edd-revoke-api-key",function(a){return confirm(edd_vars.revoke_api_key)})},regenerate_api_key:function(){a(document.body).on("click",".edd-regenerate-api-key",function(a){return confirm(edd_vars.regenerate_api_key)})},create_api_key:function(){a(document.body).on("submit","#api-key-generate-form",function(b){var c=a('input[type="text"][name="user_id"]');c.css("border-color","#ddd");var d=c.val();if(d.length<1||0==d)return c.css("border-color","#ff0000"),!1})},recount_stats:function(){a("body").on("change","#recount-stats-type",function(){var b=a("#edd-tools-recount-form"),c=a("option:selected",this).data("type"),d=a("#recount-stats-submit"),e=a("#tools-product-dropdown");if(b.find(".notice-wrap").remove(),d.removeClass("button-disabled").attr("disabled",!1),e.hide(),a(".edd-recount-stats-descriptions span").hide(),"recount-download"===c)e.show(),e.find(".edd-select-chosen").css("width","auto");else if("reset-stats"===c){b.append('<div class="notice-wrap"></div>');var f=b.find(".notice-wrap");f.html('<div class="notice notice-warning"><p><input type="checkbox" id="confirm-reset" name="confirm_reset_store" value="1" /> <label for="confirm-reset">'+edd_vars.reset_stats_warn+"</label></p></div>"),a("#recount-stats-submit").addClass("button-disabled").attr("disabled","disabled")}else e.hide(),e.val(0);a("#"+c).show()}),a("body").on("change","#confirm-reset",function(){var b=a(this).is(":checked");b?a("#recount-stats-submit").removeClass("button-disabled").removeAttr("disabled"):a("#recount-stats-submit").addClass("button-disabled").attr("disabled","disabled")}),a("#edd-tools-recount-form").submit(function(b){var c=a("#recount-stats-type").val(),d=a(this),e=a("option:selected",this).data("type");if("reset-stats"===e){var f=a("#confirm-reset").is(":checked");if(f)return!0;h=!0}d.find(".notice-wrap").remove(),d.append('<div class="notice-wrap"></div>');var g=d.find(".notice-wrap"),h=!1;if(null!==c&&0!==c||(g.html('<div class="updated error"><p>'+edd_vars.batch_export_no_class+"</p></div>"),h=!0),"recount-download"===e){var i=a('select[name="download_id"]').val();0==i&&(g.html('<div class="updated error"><p>'+edd_vars.batch_export_no_reqs+"</p></div>"),h=!0)}if(h)return d.find(".button-disabled").removeClass("button-disabled"),!1})}};k.init();var l={init:function(){this.submit(),this.dismiss_message()},submit:function(){var b=this;a(document.body).on("submit",".edd-export-form",function(c){c.preventDefault();var d=a(this).find('input[type="submit"]');if(!d.hasClass("button-disabled")){var e=a(this).serialize();d.addClass("button-disabled"),a(this).find(".notice-wrap").remove(),a(this).append('<div class="notice-wrap"><span class="spinner is-active"></span><div class="edd-progress"><div></div></div></div>'),b.process_step(1,e,b)}})},process_step:function(b,c,d){a.ajax({type:"POST",url:ajaxurl,data:{form:c,action:"edd_do_ajax_export",step:b},dataType:"json",success:function(b){if("done"==b.step||b.error||b.success){var e=a(".edd-export-form").find(".edd-progress").parent().parent(),f=e.find(".notice-wrap");if(e.find(".button-disabled").removeClass("button-disabled"),b.error){var g=b.message;f.html('<div class="updated error"><p>'+g+"</p></div>")}else if(b.success){var h=b.message;f.html('<div id="edd-batch-success" class="updated notice is-dismissible"><p>'+h+'<span class="notice-dismiss"></span></p></div>')}else f.remove(),window.location=b.url}else a(".edd-progress div").animate({width:b.percentage+"%"},50,function(){}),d.process_step(parseInt(b.step),c,d)}}).fail(function(a){window.console&&window.console.log&&console.log(a)})},dismiss_message:function(){a("body").on("click","#edd-batch-success .notice-dismiss",function(){a("#edd-batch-success").parent().slideUp("fast")})}};l.init();var m={init:function(){this.submit()},submit:function(){var b=this;a(".edd-import-form").ajaxForm({beforeSubmit:b.before_submit,success:b.success,complete:b.complete,dataType:"json",error:b.error})},before_submit:function(b,c,d){if(c.find(".notice-wrap").remove(),c.append('<div class="notice-wrap"><span class="spinner is-active"></span><div class="edd-progress"><div></div></div></div>'),!(window.File&&window.FileReader&&window.FileList&&window.Blob)){var e=a(".edd-import-form").find(".edd-progress").parent().parent(),f=e.find(".notice-wrap");return e.find(".button-disabled").removeClass("button-disabled"),f.html('<div class="update error"><p>'+edd_vars.unsupported_browser+"</p></div>"),!1}},success:function(a,b,c,d){},complete:function(b){var c=jQuery.parseJSON(b.responseText);if(c.success){var d=a(".edd-import-form .notice-wrap").parent();d.find(".edd-import-file-wrap,.notice-wrap").remove(),d.find(".edd-import-options").slideDown();var e=d.find("select.edd-import-csv-column"),g=(e.parent().parent(),""),h=c.data.columns.sort(function(a,b){return a<b?-1:a>b?1:0});a.each(h,function(a,b){g+='<option value="'+b+'">'+b+"</option>"}),e.append(g),e.on("change",function(){var b=a(this).val();b&&0!=c.data.first_row[b]?a(this).parent().next().html(c.data.first_row[b]):a(this).parent().next().html("")}),a("body").on("click",".edd-import-proceed",function(a){a.preventDefault(),d.append('<div class="notice-wrap"><span class="spinner is-active"></span><div class="edd-progress"><div></div></div></div>'),c.data.mapping=d.serialize(),m.process_step(1,c.data,self)})}else m.error(b)},error:function(b){var c=jQuery.parseJSON(b.responseText),d=a(".edd-import-form").find(".edd-progress").parent().parent(),e=d.find(".notice-wrap");d.find(".button-disabled").removeClass("button-disabled"),c.data.error?e.html('<div class="update error"><p>'+c.data.error+"</p></div>"):e.remove()},process_step:function(b,c,d){a.ajax({type:"POST",url:ajaxurl,data:{form:c.form,nonce:c.nonce,class:c.class,upload:c.upload,mapping:c.mapping,action:"edd_do_ajax_import",step:b},dataType:"json",success:function(b){if("done"==b.data.step||b.data.error){var e=a(".edd-import-form").find(".edd-progress").parent().parent(),f=e.find(".notice-wrap");e.find(".button-disabled").removeClass("button-disabled"),b.data.error?f.html('<div class="update error"><p>'+b.data.error+"</p></div>"):(e.find(".edd-import-options").hide(),a("html, body").animate({scrollTop:e.parent().offset().top},500),f.html('<div class="updated"><p>'+b.data.message+"</p></div>"))}else a(".edd-progress div").animate({width:b.data.percentage+"%"},50,function(){}),m.process_step(parseInt(b.data.step),c,d)}}).fail(function(a){window.console&&window.console.log&&console.log(a)})}};m.init();var n={vars:{customer_card_wrap_editable:a(".edd-customer-card-wrapper .editable"),customer_card_wrap_edit_item:a(".edd-customer-card-wrapper .edit-item"),user_id:a('input[name="customerinfo[user_id]"]'),state_input:a(':input[name="customerinfo[state]"]'),note:a("#customer-note")},init:function(){this.edit_customer(),this.add_email(),this.user_search(),this.remove_user(),this.cancel_edit(),this.change_country(),this.add_note(),this.delete_checked()},edit_customer:function(){a(document.body).on("click","#edit-customer",function(a){a.preventDefault(),n.vars.customer_card_wrap_editable.hide(),n.vars.customer_card_wrap_edit_item.fadeIn().css("display","block")})},add_email:function(){a(document.body).on("click","#add-customer-email",function(b){b.preventDefault();var c=a(this),d=c.parent();d.parent().find(".notice-wrap").remove(),d.find(".spinner").css("visibility","visible"),c.attr("disabled",!0);var e=d.find('input[name="customer-id"]').val(),f=d.find('input[name="additional-email"]').val(),g=d.find('input[name="make-additional-primary"]').is(":checked"),h=d.find('input[name="add_email_nonce"]').val(),i={edd_action:"customer-add-email",customer_id:e,email:f,primary:g,_wpnonce:h};a.post(ajaxurl,i,function(a){!0===a.success?window.location.href=a.redirect:(c.attr("disabled",!1),d.after('<div class="notice-wrap"><div class="notice notice-error inline"><p>'+a.message+"</p></div></div>"),d.find(".spinner").css("visibility","hidden"))},"json")})},user_search:function(){a(document.body).on("click.eddSelectUser",".edd_user_search_results a",function(b){b.preventDefault();var c=a(this).data("userid");n.vars.user_id.val(c)})},remove_user:function(){a(document.body).on("click","#disconnect-customer",function(b){b.preventDefault();var c=a('input[name="customerinfo[id]"]').val(),d={edd_action:"disconnect-userid",customer_id:c,_wpnonce:a("#edit-customer-info #_wpnonce").val()};a.post(ajaxurl,d,function(a){window.location.href=window.location.href},"json")})},cancel_edit:function(){a(document.body).on("click","#edd-edit-customer-cancel",function(b){b.preventDefault(),n.vars.customer_card_wrap_edit_item.hide(),n.vars.customer_card_wrap_editable.show(),a(".edd_user_search_results").html("")})},change_country:function(){a('select[name="customerinfo[country]"]').change(function(){var b=a(this);return data={action:"edd_get_shop_states",country:b.val(),field_name:"customerinfo[state]"},a.post(ajaxurl,data,function(a){"nostates"==a?n.vars.state_input.replaceWith('<input type="text" name="'+data.field_name+'" value="" class="edd-edit-toggles medium-text"/>'):n.vars.state_input.replaceWith(a);
2
  }),!1})},add_note:function(){a(document.body).on("click","#add-customer-note",function(b){b.preventDefault();var c={edd_action:"add-customer-note",customer_id:a("#customer-id").val(),customer_note:n.vars.note.val(),add_customer_note_nonce:a("#add_customer_note_nonce").val()};if(c.customer_note)a.ajax({type:"POST",data:c,url:ajaxurl,success:function(b){a("#edd-customer-notes").prepend(b),a(".edd-no-customer-notes").hide(),n.vars.note.val("")}}).fail(function(a){window.console&&window.console.log&&console.log(a)});else{var d=n.vars.note.css("border-color");n.vars.note.css("border-color","red"),setTimeout(function(){n.vars.note.css("border-color",d)},500)}})},delete_checked:function(){a("#edd-customer-delete-confirm").change(function(){var b=a("#edd-customer-delete-records"),c=a("#edd-delete-customer");a(this).prop("checked")?(b.attr("disabled",!1),c.attr("disabled",!1)):(b.attr("disabled",!0),b.prop("checked",!1),c.attr("disabled",!0))})}};n.init(),a(".edd-ajax-user-search").keyup(function(){var b=a(this).val(),c="";a(this).data("exclude")&&(c=a(this).data("exclude")),a(".edd-ajax").show(),data={action:"edd_search_users",user_name:b,exclude:c},document.body.style.cursor="wait",a.ajax({type:"POST",data:data,dataType:"json",url:ajaxurl,success:function(b){a(".edd-ajax").hide(),a(".edd_user_search_results").removeClass("hidden"),a(".edd_user_search_results span").html(""),a(b.results).appendTo(".edd_user_search_results span"),document.body.style.cursor="default"}})}),a(document.body).on("click.eddSelectUser",".edd_user_search_results span a",function(b){b.preventDefault();var c=a(this).data("login");a(".edd-ajax-user-search").val(c),a(".edd_user_search_results").addClass("hidden"),a(".edd_user_search_results span").html("")}),a(document.body).on("click.eddCancelUserSearch",".edd_user_search_results a.edd-ajax-user-cancel",function(b){b.preventDefault(),a(".edd-ajax-user-search").val(""),a(".edd_user_search_results").addClass("hidden"),a(".edd_user_search_results span").html("")}),a("#edd_dashboard_sales").length&&a.ajax({type:"GET",data:{action:"edd_load_dashboard_widget"},url:ajaxurl,success:function(b){a("#edd_dashboard_sales .inside").html(b)}}),a(document).on("keydown",".customer-note-input",function(b){13==b.keyCode&&(b.metaKey||b.ctrlKey)&&a("#add-customer-note").click()})});var eddFormatCurrency=function(a){var b=parseFloat(a),c=edd_vars.currency,d=edd_vars.currency_decimals;return b.toLocaleString(c,{style:"currency",currency:c,minimumFractionDigits:d,maximumFractionDigits:d})},eddFormatNumber=function(a){var b=parseFloat(a),c=edd_vars.currency;edd_vars.currency_decimals;return b.toLocaleString(c,{style:"decimal",minimumFractionDigits:0,maximumFractionDigits:0})},eddLabelFormatter=function(a,b){return'<div style="font-size:12px; text-align:center; padding:2px">'+a+"</div>"},eddLegendFormatterSales=function(a,b){var c=a.toLowerCase().replace(/\s/g,"-"),d='<div class="edd-legend-color" style="background-color: '+b.color+'"></div>',e='<div class="edd-pie-legend-item">'+a+": "+Math.round(b.percent)+"% ("+eddFormatNumber(b.data[0][1])+")</div>",f='<div id="'+b.edd_vars.id+c+'" class="edd-legend-item-wrapper">'+d+e+"</div>";return jQuery("#edd-pie-legend-"+b.edd_vars.id).append(f),f},eddLegendFormatterEarnings=function(a,b){var c=a.toLowerCase().replace(/\s/g,"-"),d='<div class="edd-legend-color" style="background-color: '+b.color+'"></div>',e='<div class="edd-pie-legend-item">'+a+": "+Math.round(b.percent)+"% ("+eddFormatCurrency(b.data[0][1])+")</div>",f='<div id="'+b.edd_vars.id+c+'" class="edd-legend-item-wrapper">'+d+e+"</div>";return jQuery("#edd-pie-legend-"+b.edd_vars.id).append(f),f};
1
+ jQuery(document).ready(function(a){a(".edd-help-tip").tooltip({content:function(){return a(this).prop("title")},tooltipClass:"edd-ui-tooltip",position:{my:"center top",at:"center bottom+10",collision:"flipfit"},hide:{duration:200},show:{duration:200}});var b={init:function(){this.add(),this.move(),this.remove(),this.type(),this.prices(),this.files(),this.updatePrices()},clone_repeatable:function(b){var c=highest=1;return b.parent().find("tr.edd_repeatable_row").each(function(){var b=a(this).data("key");parseInt(b)>highest&&(highest=b)}),c=highest+=1,clone=b.clone(),clone.find("select").each(function(){a(this).val(b.find('select[name="'+a(this).attr("name")+'"]').val())}),clone.removeClass("edd_add_blank"),clone.attr("data-key",c),clone.find("td input, td select, textarea").val(""),clone.find("input, select, textarea").each(function(){var b=a(this).attr("name"),d=a(this).attr("id");b&&(b=b.replace(/\[(\d+)\]/,"["+parseInt(c)+"]"),a(this).attr("name",b)),a(this).attr("data-key",c),"undefined"!=typeof d&&(d=d.replace(/(\d+)/,parseInt(c)),a(this).attr("id",d))}),clone.find("span.edd_price_id").each(function(){a(this).text(parseInt(c))}),clone.find("span.edd_file_id").each(function(){a(this).text(parseInt(c))}),clone.find(".edd_repeatable_default_input").each(function(){a(this).val(parseInt(c)).removeAttr("checked")}),clone.find(".edd_repeatable_condition_field").each(function(){a(this).find("option:eq(0)").prop("selected","selected")}),clone.find(".search-choice").remove(),clone.find(".chosen-container").remove(),clone},add:function(){a(document.body).on("click",".submit .edd_add_repeatable",function(c){c.preventDefault();var d=a(this),e=d.parent().parent().prev("tr"),f=b.clone_repeatable(e);f.insertAfter(e).find("input, textarea, select").filter(":visible").eq(0).focus(),f.find(".edd-select-chosen").chosen({inherit_select_classes:!0,placeholder_text_single:edd_vars.one_option,placeholder_text_multiple:edd_vars.one_or_more_option}),f.find(".edd-select-chosen").css("width","100%"),f.find(".edd-select-chosen .chosen-search input").attr("placeholder",edd_vars.search_placeholder)})},move:function(){a(".edd_repeatable_table tbody").sortable({handle:".edd_draghandle",items:".edd_repeatable_row",opacity:.6,cursor:"move",axis:"y",update:function(){var b=0;a(this).find("tr").each(function(){a(this).find("input.edd_repeatable_index").each(function(){a(this).val(b)}),b++})}})},remove:function(){a(document.body).on("click",".edd_remove_repeatable",function(b){b.preventDefault();var g,h,i,c=a(this).parent().parent("tr"),d=c.parent().find("tr").length-1,e=a(this).data("type"),f="tr.edd_repeatable_"+e+"s";if(g=a(this).is(".ui-sortable tr:first-child .edd_remove_repeatable:first-child")?c.next("tr"):c.prev("tr"),h=g.find("select, input, textarea, button").filter(":visible"),i=h.eq(0),"price"===e){var j=c.data("key");a('.edd_repeatable_condition_field option[value="'+j+'"]').remove()}if(d>1)a("input, select",c).val(""),c.fadeOut("fast").remove(),i.focus();else switch(e){case"price":alert(edd_vars.one_price_min);break;case"file":a("input, select",c).val("");break;default:alert(edd_vars.one_field_min)}a(f).each(function(b){a(this).find("input, select").each(function(){var c=a(this).attr("name");c=c.replace(/\[(\d+)\]/,"["+b+"]"),a(this).attr("name",c).attr("id",c)})})})},type:function(){a(document.body).on("change","#_edd_product_type",function(b){var c=a("#edd_products"),d=a("#edd_download_files"),e=a("#edd_download_limit_wrap");"bundle"===a(this).val()?(c.show(),d.hide(),e.hide()):(c.hide(),d.show(),e.show())})},prices:function(){a(document.body).on("change","#edd_variable_pricing",function(b){var c=a(this).is(":checked"),d=a("#edd_regular_price_field"),e=a("#edd_variable_price_fields,.edd_repeatable_table .pricing");c?(d.hide(),e.show()):(d.show(),e.hide())})},files:function(){var c;window.formfield="",a(document.body).on("click",".edd_upload_file_button",function(d){d.preventDefault();var e=a(this);return window.formfield=a(this).closest(".edd_repeatable_upload_wrapper"),c?void c.open():(c=wp.media.frames.file_frame=wp.media({frame:"post",state:"insert",title:e.data("uploader-title"),button:{text:e.data("uploader-button-text")},multiple:"0"!=a(this).data("multiple")}),c.on("menu:render:default",function(a){var b={};a.unset("library-separator"),a.unset("gallery"),a.unset("featured-image"),a.unset("embed"),a.set(b)}),c.on("insert",function(){var d=c.state().get("selection");d.each(function(c,d){c=c.toJSON();var e="image"===c.type&&a(".attachment-display-settings .size option:selected").val(),f=c.url,g=c.title.length>0?c.title:c.filename;if(e&&"undefined"!=typeof c.sizes[e]&&(f=c.sizes[e].url),"image"===c.type&&(g=e&&"undefined"!=typeof c.sizes[e]?g+"-"+c.sizes[e].width+"x"+c.sizes[e].height:g+"-"+c.width+"x"+c.height),0===d)window.formfield.find(".edd_repeatable_attachment_id_field").val(c.id),window.formfield.find(".edd_repeatable_thumbnail_size_field").val(e),window.formfield.find(".edd_repeatable_upload_field").val(f),window.formfield.find(".edd_repeatable_name_field").val(g);else{var h=window.formfield,i=b.clone_repeatable(h);i.find(".edd_repeatable_attachment_id_field").val(c.id),i.find("edd_repeatable_thumbnail_size_field").val(e),i.find(".edd_repeatable_upload_field").val(f),i.find(".edd_repeatable_name_field").val(g),i.insertAfter(h)}})}),void c.open())});var c;window.formfield=""},updatePrices:function(){a("#edd_price_fields").on("keyup",".edd_variable_prices_name",function(){var b=a(this).parents("tr").data("key"),c=a(this).val(),d=a(".edd_repeatable_condition_field option[value="+b+"]");d.length>0?d.text(c):a(".edd_repeatable_condition_field").append(a("<option></option>").attr("value",b).text(c))})}};b.init();var c=a(".edd_datepicker");if(c.length>0){var d="mm/dd/yy";c.datepicker({dateFormat:d})}var e={init:function(){this.edit_address(),this.remove_download(),this.add_download(),this.change_customer(),this.new_customer(),this.edit_price(),this.recalculate_total(),this.variable_prices_check(),this.add_note(),this.remove_note(),this.resend_receipt(),this.copy_download_link()},edit_address:function(){a('select[name="edd-payment-address[0][country]"]').change(function(){var b=a(this);return data={action:"edd_get_shop_states",country:b.val(),field_name:"edd-payment-address[0][state]"},a.post(ajaxurl,data,function(b){var c=a("#edd-order-address-state-wrap select, #edd-order-address-state-wrap input");a("#edd-order-address-state-wrap .chosen-container").remove(),"nostates"==b?c.replaceWith('<input type="text" name="edd-payment-address[0][state]" value="" class="edd-edit-toggles medium-text"/>'):c.replaceWith(b)}),!1})},remove_download:function(){a("#edd-purchased-files").on("click",".edd-order-remove-download",function(){var b=a(document.body).find("#edd-purchased-files > .row").length;if(1===b)return alert(edd_vars.one_download_min),!1;if(confirm(edd_vars.delete_payment_download)){var c=a(this).data("key"),e=(a(".edd-payment-id").val(),a('input[name="edd-payment-details-downloads['+c+'][id]"]').val()),f=a('input[name="edd-payment-details-downloads['+c+'][price_id]"]').val(),g=a('input[name="edd-payment-details-downloads['+c+'][quantity]"]').val(),h=a('input[name="edd-payment-details-downloads['+c+'][amount]"]').val();if(a('input[name="edd-payment-details-downloads['+c+'][tax]"]'))var i=a('input[name="edd-payment-details-downloads['+c+'][tax]"]').val();if(a('input[name="edd-payment-details-downloads['+c+'][fees]"]'))var i=a.parseJSON(a('input[name="edd-payment-details-downloads['+c+'][fees]"]').val());var j=a('input[name="edd-payment-removed"]').val();j=a.parseJSON(j),j.length<1&&(j={});var k=[{id:e,price_id:f,quantity:g,amount:h,cart_index:c}];j[c]=k,a('input[name="edd-payment-removed"]').val(JSON.stringify(j)),a(this).parent().parent().remove(),i&&i.length&&a.each(i,function(b,c){a('*li[data-fee-id="'+c+'"]').remove()}),a("#edd-payment-downloads-changed").val(1),a(".edd-order-payment-recalc-totals").show()}return!1})},change_customer:function(){a("#edd-customer-details").on("click",".edd-payment-change-customer, .edd-payment-change-customer-cancel",function(b){b.preventDefault();var c=a(this).hasClass("edd-payment-change-customer"),d=a(this).hasClass("edd-payment-change-customer-cancel");c?(a(".customer-info").hide(),a(".change-customer").show(),a(".edd-payment-change-customer-input").css("width","auto")):d&&(a(".customer-info").show(),a(".change-customer").hide())})},new_customer:function(){a("#edd-customer-details").on("click",".edd-payment-new-customer, .edd-payment-new-customer-cancel",function(b){b.preventDefault();var c=a(this).hasClass("edd-payment-new-customer"),d=a(this).hasClass("edd-payment-new-customer-cancel");c?(a(".customer-info").hide(),a(".new-customer").show()):d&&(a(".customer-info").show(),a(".new-customer").hide());var c=a("#edd-new-customer");a(".new-customer").is(":visible")?c.val(1):c.val(0)})},add_download:function(){a(".edd-edit-purchase-element").on("click","#edd-order-add-download",function(b){b.preventDefault();var c=a("#edd_order_download_select"),d=a("#edd-order-download-quantity"),e=a("#edd-order-download-price"),f=a("#edd-order-download-tax"),g=a(".edd_price_options_select option:selected"),h=c.val(),i=c.find(":selected").text(),j=d.val(),k=e.val(),l=f.val(),m=g.val(),n=g.text();if(h<1)return!1;if(k||(k=0),k=parseFloat(k),isNaN(k))return alert(edd_vars.numeric_item_price),!1;if(l=parseFloat(l),isNaN(l))return alert(edd_vars.numeric_item_tax),!1;if(isNaN(parseInt(j)))return alert(edd_vars.numeric_quantity),!1;n&&(i=i+" - "+n);var o=a("#edd-purchased-files div.row").length,p=a("#edd-purchased-files div.row:last").clone();p.find(".download span").html('<a href="post.php?post='+h+'&action=edit"></a>'),p.find(".download span a").text(i),p.find(".edd-payment-details-download-item-price").val(k.toFixed(edd_vars.currency_decimals)),p.find(".edd-payment-details-download-item-tax").val(l.toFixed(edd_vars.currency_decimals)),p.find("input.edd-payment-details-download-id").val(h),p.find("input.edd-payment-details-download-price-id").val(m);var q=k*j+l;q=q.toFixed(edd_vars.currency_decimals),p.find("span.edd-payment-details-download-amount").text(q),p.find("input.edd-payment-details-download-amount").val(q),p.find("input.edd-payment-details-download-quantity").val(j),p.find("input.edd-payment-details-download-has-log").val(0),p.find(".edd-copy-download-link-wrapper").remove(),p.find("input").each(function(){var b=a(this).attr("name");b=b.replace(/\[(\d+)\]/,"["+parseInt(o)+"]"),a(this).attr("name",b).attr("id",b)}),p.find("a.edd-order-remove-download").attr("data-key",parseInt(o)),a("#edd-payment-downloads-changed").val(1),a(p).insertAfter("#edd-purchased-files div.row:last"),a(".edd-order-payment-recalc-totals").show(),a(".edd-add-download-field").val("")})},edit_price:function(){a(document.body).on("change keyup",".edd-payment-item-input",function(){var b=a(this).parents("ul.edd-purchased-files-list-wrapper");a(".edd-order-payment-recalc-totals").show();var c=b.find("input.edd-payment-details-download-quantity").val(),d=b.find("input.edd-payment-details-download-item-price").val(),e=b.find("input.edd-payment-details-download-item-tax").val();if(d=parseFloat(d),isNaN(d))return alert(edd_vars.numeric_item_price),!1;e=parseFloat(e),isNaN(e)&&(e=0),isNaN(parseInt(c))&&(c=1);var f=d*c+e;f=f.toFixed(edd_vars.currency_decimals),b.find("input.edd-payment-details-download-amount").val(f),b.find("span.edd-payment-details-download-amount").text(f)})},recalculate_total:function(){a("#edd-order-recalc-total").on("click",function(b){b.preventDefault();var c=0,d=0,e=a("#edd-purchased-files .row input.edd-payment-details-download-amount"),f=a("#edd-purchased-files .row input.edd-payment-details-download-item-tax");e.length&&e.each(function(){c+=parseFloat(a(this).val())}),f.length&&f.each(function(){d+=parseFloat(a(this).val())}),a(".edd-payment-fees").length&&a(".edd-payment-fees span.fee-amount").each(function(){c+=parseFloat(a(this).data("fee"))}),a("input[name=edd-payment-total]").val(c.toFixed(edd_vars.currency_decimals)),a("input[name=edd-payment-tax]").val(d.toFixed(edd_vars.currency_decimals))})},variable_prices_check:function(){a(".edd-edit-purchase-element").on("change","select#edd_order_download_select",function(){var b=a(this),c=b.val();if(parseInt(c)>0){var d={action:"edd_check_for_download_price_variations",download_id:c};a.ajax({type:"POST",data:d,url:ajaxurl,success:function(c){a(".edd_price_options_select").remove(),a(c).insertAfter(b.next())}}).fail(function(a){window.console&&window.console.log&&console.log(a)})}})},add_note:function(){a("#edd-add-payment-note").on("click",function(b){b.preventDefault();var c={action:"edd_insert_payment_note",payment_id:a(this).data("payment-id"),note:a("#edd-payment-note").val()};if(c.note)a.ajax({type:"POST",data:c,url:ajaxurl,success:function(b){a("#edd-payment-notes-inner").append(b),a(".edd-no-payment-notes").hide(),a("#edd-payment-note").val("")}}).fail(function(a){window.console&&window.console.log&&console.log(a)});else{var d=a("#edd-payment-note").css("border-color");a("#edd-payment-note").css("border-color","red"),setTimeout(function(){a("#edd-payment-note").css("border-color",d)},500)}})},remove_note:function(){a(document.body).on("click",".edd-delete-payment-note",function(b){if(b.preventDefault(),confirm(edd_vars.delete_payment_note)){var c={action:"edd_delete_payment_note",payment_id:a(this).data("payment-id"),note_id:a(this).data("note-id")};return a.ajax({type:"POST",data:c,url:ajaxurl,success:function(b){return a("#edd-payment-note-"+c.note_id).remove(),a(".edd-payment-note").length||a(".edd-no-payment-notes").show(),!1}}).fail(function(a){window.console&&window.console.log&&console.log(a)}),!0}})},resend_receipt:function(){var b=a(".edd-order-resend-receipt-addresses");a(document.body).on("click","#edd-select-receipt-email",function(a){a.preventDefault(),b.slideDown()}),a(document.body).on("change",".edd-order-resend-receipt-email",function(){var b=a("#edd-select-receipt-email").prop("href")+"&email="+a(this).val();confirm(edd_vars.resend_receipt)&&(window.location=b)}),a(document.body).on("click","#edd-resend-receipt",function(a){return confirm(edd_vars.resend_receipt)})},copy_download_link:function(){a(document.body).on("click",".edd-copy-download-link",function(b){b.preventDefault();var c=a(this),d={action:"edd_get_file_download_link",payment_id:a('input[name="edd_payment_id"]').val(),download_id:c.data("download-id"),price_id:c.data("price-id")};a.ajax({type:"POST",data:d,url:ajaxurl,success:function(b){return a("#edd-download-link").dialog({width:400}).html('<textarea rows="10" cols="40" id="edd-download-link-textarea">'+b+"</textarea>"),a("#edd-download-link-textarea").focus().select(),!1}}).fail(function(a){window.console&&window.console.log&&console.log(a)})})}};e.init();var f={init:function(){this.type_select(),this.product_requirements()},type_select:function(){a("#edd-edit-discount #edd-type, #edd-add-discount #edd-type").change(function(){var b=a(this).val();a(".edd-amount-description").hide(),a(".edd-amount-description."+b+"-discount").show()})},product_requirements:function(){a("#products").change(function(){var b=a("#edd-discount-product-conditions");a(this).val()?b.show():b.hide()})}};f.init();var g={init:function(){this.date_options(),this.customers_export()},date_options:function(){a("#edd-graphs-date-options").change(function(){var b=a(this),c=a("#edd-date-range-options");"other"===b.val()?c.show():c.hide()})},customers_export:function(){a("#edd_customer_export_download").change(function(){var b=a(this),c=a("option:selected",b).val(),d=a("#edd_customer_export_option");if("0"===b.val()?d.show():d.hide(),0!=parseInt(c)){var e={action:"edd_check_for_download_price_variations",download_id:c,all_prices:!0},f=a(".edd_price_options_select");a.post(ajaxurl,e,function(b){f.remove(),a("#edd_customer_export_download_chosen").after(b)})}else f.remove()})}};g.init();var h={init:function(){this.general(),this.taxes(),this.emails(),this.misc()},general:function(){var b=a(".edd-color-picker");if(b.length&&b.wpColorPicker(),"undefined"==typeof wp||"1"!==edd_vars.new_media_ui){var c=a(".edd_settings_upload_button");c.length>0&&(window.formfield="",a(document.body).on("click",c,function(b){b.preventDefault(),window.formfield=a(this).parent().prev(),window.tbframe_interval=setInterval(function(){jQuery("#TB_iframeContent").contents().find(".savesend .button").val(edd_vars.use_this_file).end().find("#insert-gallery, .wp-post-thumbnail").hide()},2e3),tb_show(edd_vars.add_new_download,"media-upload.php?TB_iframe=true")}),window.edd_send_to_editor=window.send_to_editor,window.send_to_editor=function(b){window.formfield?(imgurl=a("a","<div>"+b+"</div>").attr("href"),window.formfield.val(imgurl),window.clearInterval(window.tbframe_interval),tb_remove()):window.edd_send_to_editor(b),window.send_to_editor=window.edd_send_to_editor,window.formfield="",window.imagefield=!1})}else{var d;window.formfield="",a(document.body).on("click",".edd_settings_upload_button",function(b){b.preventDefault();var c=a(this);return window.formfield=a(this).parent().prev(),d?void d.open():(d=wp.media.frames.file_frame=wp.media({frame:"post",state:"insert",title:c.data("uploader_title"),button:{text:c.data("uploader_button_text")},multiple:!1}),d.on("menu:render:default",function(a){var b={};a.unset("library-separator"),a.unset("gallery"),a.unset("featured-image"),a.unset("embed"),a.set(b)}),d.on("insert",function(){var a=d.state().get("selection");a.each(function(a,b){a=a.toJSON(),window.formfield.val(a.url)})}),void d.open())});var d;window.formfield=""}},taxes:function(){var b=a("select.edd-no-states");b.length&&b.closest("tr").hide(),a('select[name="edd_settings[base_country]"]').change(function(){var b=a(this),c=b.closest("tr");return data={action:"edd_get_shop_states",country:a(this).val(),field_name:"edd_settings[base_state]"},a.post(ajaxurl,data,function(a){"nostates"==a?c.next().hide():(c.next().show(),c.next().find("select").replaceWith(a))}),!1}),a(document.body).on("change","#edd_tax_rates select.edd-tax-country",function(){var b=a(this);return data={action:"edd_get_shop_states",country:a(this).val(),field_name:b.attr("name").replace("country","state")},a.post(ajaxurl,data,function(a){if("nostates"==a){var c='<input type="text" name="'+data.field_name+'" value=""/>';b.parent().next().find("select").replaceWith(c)}else b.parent().next().find("input,select").show(),b.parent().next().find("input,select").replaceWith(a)}),!1}),a("#edd_add_tax_rate").on("click",function(){var b=a("#edd_tax_rates tr:last"),c=b.clone(),d=b.parent().find("tr").length;return c.find("td input").not(":input[type=checkbox]").val(""),c.find('td [type="checkbox"]').attr("checked",!1),c.find("input, select").each(function(){var b=a(this).attr("name");b=b.replace(/\[(\d+)\]/,"["+parseInt(d)+"]"),a(this).attr("name",b).attr("id",b)}),c.find("label").each(function(){var b=a(this).attr("for");b=b.replace(/\[(\d+)\]/,"["+parseInt(d)+"]"),a(this).attr("for",b)}),c.insertAfter(b),!1}),a(document.body).on("click","#edd_tax_rates .edd_remove_tax_rate",function(){if(confirm(edd_vars.delete_tax_rate)){var b=a("#edd_tax_rates tr:visible"),c=b.length;2===c?(a("#edd_tax_rates select").val(""),a('#edd_tax_rates input[type="text"]').val(""),a('#edd_tax_rates input[type="number"]').val(""),a('#edd_tax_rates input[type="checkbox"]').attr("checked",!1)):a(this).closest("tr").remove(),a("#edd_tax_rates tr").each(function(b){a(this).children().find("input, select").each(function(){var c=a(this).attr("name");c=c.replace(/\[(\d+)\]/,"["+(b-1)+"]"),a(this).attr("name",c).attr("id",c)})})}return!1})},emails:function(){var b=a("#email-preview-wrap");if(b.length){var c=a("#email-preview");b.colorbox({inline:!0,href:c,width:"80%",height:"auto"})}},misc:function(){var b=a('select[name="edd_settings[download_method]"]'),c=b.parent().parent().next();"direct"==b.val()&&(c.hide(),c.find("input").prop("checked",!1)),b.on("change",function(){"direct"==a(this).val()?(c.hide(),c.find("input").prop("checked",!1)):c.show()})}};h.init(),a(".download_page_edd-payment-history .row-actions .delete a, a.edd-delete-payment").on("click",function(){return!!confirm(edd_vars.delete_payment)}),a("#the-list").on("click",".editinline",function(){var b=a(this).closest("tr").attr("id");b=b.replace("post-","");var c=a("#post-"+b),d=c.find(".column-price .downloadprice-"+b).val();d!=a("#post-"+b+".column-price .downloadprice-"+b).val()?a(".regprice","#edd-download-data").val(d).attr("disabled",!1):a(".regprice","#edd-download-data").val(edd_vars.quick_edit_warning).attr("disabled","disabled")}),a(document.body).on("click","#bulk_edit",function(){var b=a("#bulk-edit"),c=new Array;b.find("#bulk-titles").children().each(function(){c.push(a(this).attr("id").replace(/^(ttle)/i,""))});var d=a('#edd-download-data input[name="_edd_regprice"]').val(),e={action:"edd_save_bulk_edit",edd_bulk_nonce:c,post_ids:c,price:d};a.post(ajaxurl,e)}),a(".edd-select-chosen").chosen({inherit_select_classes:!0,placeholder_text_single:edd_vars.one_option,placeholder_text_multiple:edd_vars.one_or_more_option}),a(".edd-select-chosen .chosen-search input").each(function(){var b=a(this).parent().parent().parent().prev("select.edd-select-chosen").data("search-type"),c="";if("download"===b)c=edd_vars.search_placeholder;else{var b="search_placeholder_"+b;edd_vars[b]&&(c=edd_vars[b])}a(this).attr("placeholder",c)}),a(".chosen-choices").on("click",function(){a(this).children("li").children("input").attr("placeholder",edd_vars.type_to_search)});var i,j=342;a(document.body).on("keyup",".edd-select.chosen-container .chosen-search input, .edd-select.chosen-container .search-field input",function(b){var c=a(this).val(),d=a(this).closest(".edd-select-chosen"),e=d.attr("id").replace("_chosen",""),f=d.hasClass("no-bundles"),g=d.hasClass("variations"),h=b.which,k="edd_download_search";if(d.prev().data("search-type")){if("no_ajax"==d.prev().data("search-type"))return;k="edd_"+d.prev().data("search-type")+"_search"}c.length<=3&&"edd_download_search"==k||16==h||13==h||91==h||17==h||37==h||38==h||39==h||40==h||(clearTimeout(i),i=setTimeout(function(){a.ajax({type:"GET",url:ajaxurl,data:{action:k,s:c,no_bundles:f,variations:g},dataType:"json",beforeSend:function(){a("ul.chosen-results").empty()},success:function(b){a("#"+e+" option:not(:selected)").remove(),a.each(b,function(b,c){a("#"+e+' option[value="'+c.id+'"]').length||a("#"+e).prepend('<option value="'+c.id+'">'+c.name+"</option>")}),a(".edd-select-chosen").trigger("chosen:updated"),a("#"+e).next().find("input").val(c)}}).fail(function(a){window.console&&window.console.log&&console.log(a)}).done(function(a){})},j))}),a("#post").on("click",".edd-thickbox",function(){a(".edd-select-chosen","#choose-download").css("width","100%")});var k={init:function(){this.revoke_api_key(),this.regenerate_api_key(),this.create_api_key(),this.recount_stats()},revoke_api_key:function(){a(document.body).on("click",".edd-revoke-api-key",function(a){return confirm(edd_vars.revoke_api_key)})},regenerate_api_key:function(){a(document.body).on("click",".edd-regenerate-api-key",function(a){return confirm(edd_vars.regenerate_api_key)})},create_api_key:function(){a(document.body).on("submit","#api-key-generate-form",function(b){var c=a('input[type="text"][name="user_id"]');c.css("border-color","#ddd");var d=c.val();if(d.length<1||0==d)return c.css("border-color","#ff0000"),!1})},recount_stats:function(){a("body").on("change","#recount-stats-type",function(){var b=a("#edd-tools-recount-form"),c=a("option:selected",this).data("type"),d=a("#recount-stats-submit"),e=a("#tools-product-dropdown");if(b.find(".notice-wrap").remove(),d.removeClass("button-disabled").attr("disabled",!1),e.hide(),a(".edd-recount-stats-descriptions span").hide(),"recount-download"===c)e.show(),e.find(".edd-select-chosen").css("width","auto");else if("reset-stats"===c){b.append('<div class="notice-wrap"></div>');var f=b.find(".notice-wrap");f.html('<div class="notice notice-warning"><p><input type="checkbox" id="confirm-reset" name="confirm_reset_store" value="1" /> <label for="confirm-reset">'+edd_vars.reset_stats_warn+"</label></p></div>"),a("#recount-stats-submit").addClass("button-disabled").attr("disabled","disabled")}else e.hide(),e.val(0);a("#"+c).show()}),a("body").on("change","#confirm-reset",function(){var b=a(this).is(":checked");b?a("#recount-stats-submit").removeClass("button-disabled").removeAttr("disabled"):a("#recount-stats-submit").addClass("button-disabled").attr("disabled","disabled")}),a("#edd-tools-recount-form").submit(function(b){var c=a("#recount-stats-type").val(),d=a(this),e=a("option:selected",this).data("type");if("reset-stats"===e){var f=a("#confirm-reset").is(":checked");if(f)return!0;h=!0}d.find(".notice-wrap").remove(),d.append('<div class="notice-wrap"></div>');var g=d.find(".notice-wrap"),h=!1;if(null!==c&&0!==c||(g.html('<div class="updated error"><p>'+edd_vars.batch_export_no_class+"</p></div>"),h=!0),"recount-download"===e){var i=a('select[name="download_id"]').val();0==i&&(g.html('<div class="updated error"><p>'+edd_vars.batch_export_no_reqs+"</p></div>"),h=!0)}if(h)return d.find(".button-disabled").removeClass("button-disabled"),!1})}};k.init();var l={init:function(){this.submit(),this.dismiss_message()},submit:function(){var b=this;a(document.body).on("submit",".edd-export-form",function(c){c.preventDefault();var d=a(this).find('input[type="submit"]');if(!d.hasClass("button-disabled")){var e=a(this).serialize();d.addClass("button-disabled"),a(this).find(".notice-wrap").remove(),a(this).append('<div class="notice-wrap"><span class="spinner is-active"></span><div class="edd-progress"><div></div></div></div>'),b.process_step(1,e,b)}})},process_step:function(b,c,d){a.ajax({type:"POST",url:ajaxurl,data:{form:c,action:"edd_do_ajax_export",step:b},dataType:"json",success:function(b){if("done"==b.step||b.error||b.success){var e=a(".edd-export-form").find(".edd-progress").parent().parent(),f=e.find(".notice-wrap");if(e.find(".button-disabled").removeClass("button-disabled"),b.error){var g=b.message;f.html('<div class="updated error"><p>'+g+"</p></div>")}else if(b.success){var h=b.message;f.html('<div id="edd-batch-success" class="updated notice is-dismissible"><p>'+h+'<span class="notice-dismiss"></span></p></div>')}else f.remove(),window.location=b.url}else a(".edd-progress div").animate({width:b.percentage+"%"},50,function(){}),d.process_step(parseInt(b.step),c,d)}}).fail(function(a){window.console&&window.console.log&&console.log(a)})},dismiss_message:function(){a("body").on("click","#edd-batch-success .notice-dismiss",function(){a("#edd-batch-success").parent().slideUp("fast")})}};l.init();var m={init:function(){this.submit()},submit:function(){var b=this;a(".edd-import-form").ajaxForm({beforeSubmit:b.before_submit,success:b.success,complete:b.complete,dataType:"json",error:b.error})},before_submit:function(b,c,d){if(c.find(".notice-wrap").remove(),c.append('<div class="notice-wrap"><span class="spinner is-active"></span><div class="edd-progress"><div></div></div></div>'),!(window.File&&window.FileReader&&window.FileList&&window.Blob)){var e=a(".edd-import-form").find(".edd-progress").parent().parent(),f=e.find(".notice-wrap");return e.find(".button-disabled").removeClass("button-disabled"),f.html('<div class="update error"><p>'+edd_vars.unsupported_browser+"</p></div>"),!1}},success:function(a,b,c,d){},complete:function(b){var c=jQuery.parseJSON(b.responseText);if(c.success){var d=a(".edd-import-form .notice-wrap").parent();d.find(".edd-import-file-wrap,.notice-wrap").remove(),d.find(".edd-import-options").slideDown();var e=d.find("select.edd-import-csv-column"),g=(e.parent().parent(),""),h=c.data.columns.sort(function(a,b){return a<b?-1:a>b?1:0});a.each(h,function(a,b){g+='<option value="'+b+'">'+b+"</option>"}),e.append(g),e.on("change",function(){var b=a(this).val();b&&0!=c.data.first_row[b]?a(this).parent().next().html(c.data.first_row[b]):a(this).parent().next().html("")}),a("body").on("click",".edd-import-proceed",function(a){a.preventDefault(),d.append('<div class="notice-wrap"><span class="spinner is-active"></span><div class="edd-progress"><div></div></div></div>'),c.data.mapping=d.serialize(),m.process_step(1,c.data,self)})}else m.error(b)},error:function(b){var c=jQuery.parseJSON(b.responseText),d=a(".edd-import-form").find(".edd-progress").parent().parent(),e=d.find(".notice-wrap");d.find(".button-disabled").removeClass("button-disabled"),c.data.error?e.html('<div class="update error"><p>'+c.data.error+"</p></div>"):e.remove()},process_step:function(b,c,d){a.ajax({type:"POST",url:ajaxurl,data:{form:c.form,nonce:c.nonce,class:c.class,upload:c.upload,mapping:c.mapping,action:"edd_do_ajax_import",step:b},dataType:"json",success:function(b){if("done"==b.data.step||b.data.error){var e=a(".edd-import-form").find(".edd-progress").parent().parent(),f=e.find(".notice-wrap");e.find(".button-disabled").removeClass("button-disabled"),b.data.error?f.html('<div class="update error"><p>'+b.data.error+"</p></div>"):(e.find(".edd-import-options").hide(),a("html, body").animate({scrollTop:e.parent().offset().top},500),f.html('<div class="updated"><p>'+b.data.message+"</p></div>"))}else a(".edd-progress div").animate({width:b.data.percentage+"%"},50,function(){}),m.process_step(parseInt(b.data.step),c,d)}}).fail(function(a){window.console&&window.console.log&&console.log(a)})}};m.init();var n={vars:{customer_card_wrap_editable:a(".edd-customer-card-wrapper .editable"),customer_card_wrap_edit_item:a(".edd-customer-card-wrapper .edit-item"),user_id:a('input[name="customerinfo[user_id]"]'),state_input:a(':input[name="customerinfo[state]"]'),note:a("#customer-note")},init:function(){this.edit_customer(),this.add_email(),this.user_search(),this.remove_user(),this.cancel_edit(),this.change_country(),this.add_note(),this.delete_checked()},edit_customer:function(){a(document.body).on("click","#edit-customer",function(a){a.preventDefault(),n.vars.customer_card_wrap_editable.hide(),n.vars.customer_card_wrap_edit_item.fadeIn().css("display","block")})},add_email:function(){a(document.body).on("click","#add-customer-email",function(b){b.preventDefault();var c=a(this),d=c.parent();d.parent().find(".notice-wrap").remove(),d.find(".spinner").css("visibility","visible"),c.attr("disabled",!0);var e=d.find('input[name="customer-id"]').val(),f=d.find('input[name="additional-email"]').val(),g=d.find('input[name="make-additional-primary"]').is(":checked"),h=d.find('input[name="add_email_nonce"]').val(),i={edd_action:"customer-add-email",customer_id:e,email:f,primary:g,_wpnonce:h};a.post(ajaxurl,i,function(a){!0===a.success?window.location.href=a.redirect:(c.attr("disabled",!1),d.after('<div class="notice-wrap"><div class="notice notice-error inline"><p>'+a.message+"</p></div></div>"),d.find(".spinner").css("visibility","hidden"))},"json")})},user_search:function(){a(document.body).on("click.eddSelectUser",".edd_user_search_results a",function(b){b.preventDefault();var c=a(this).data("userid");n.vars.user_id.val(c)})},remove_user:function(){a(document.body).on("click","#disconnect-customer",function(b){b.preventDefault();var c=a('input[name="customerinfo[id]"]').val(),d={edd_action:"disconnect-userid",customer_id:c,_wpnonce:a("#edit-customer-info #_wpnonce").val()};a.post(ajaxurl,d,function(a){window.location.href=window.location.href},"json")})},cancel_edit:function(){a(document.body).on("click","#edd-edit-customer-cancel",function(b){b.preventDefault(),n.vars.customer_card_wrap_edit_item.hide(),n.vars.customer_card_wrap_editable.show(),a(".edd_user_search_results").html("")})},change_country:function(){a('select[name="customerinfo[country]"]').change(function(){var b=a(this);return data={action:"edd_get_shop_states",country:b.val(),field_name:"customerinfo[state]"},a.post(ajaxurl,data,function(a){"nostates"==a?n.vars.state_input.replaceWith('<input type="text" name="'+data.field_name+'" value="" class="edd-edit-toggles medium-text"/>'):n.vars.state_input.replaceWith(a);
2
  }),!1})},add_note:function(){a(document.body).on("click","#add-customer-note",function(b){b.preventDefault();var c={edd_action:"add-customer-note",customer_id:a("#customer-id").val(),customer_note:n.vars.note.val(),add_customer_note_nonce:a("#add_customer_note_nonce").val()};if(c.customer_note)a.ajax({type:"POST",data:c,url:ajaxurl,success:function(b){a("#edd-customer-notes").prepend(b),a(".edd-no-customer-notes").hide(),n.vars.note.val("")}}).fail(function(a){window.console&&window.console.log&&console.log(a)});else{var d=n.vars.note.css("border-color");n.vars.note.css("border-color","red"),setTimeout(function(){n.vars.note.css("border-color",d)},500)}})},delete_checked:function(){a("#edd-customer-delete-confirm").change(function(){var b=a("#edd-customer-delete-records"),c=a("#edd-delete-customer");a(this).prop("checked")?(b.attr("disabled",!1),c.attr("disabled",!1)):(b.attr("disabled",!0),b.prop("checked",!1),c.attr("disabled",!0))})}};n.init(),a(".edd-ajax-user-search").keyup(function(){var b=a(this).val(),c="";a(this).data("exclude")&&(c=a(this).data("exclude")),a(".edd-ajax").show(),data={action:"edd_search_users",user_name:b,exclude:c},document.body.style.cursor="wait",a.ajax({type:"POST",data:data,dataType:"json",url:ajaxurl,success:function(b){a(".edd-ajax").hide(),a(".edd_user_search_results").removeClass("hidden"),a(".edd_user_search_results span").html(""),a(b.results).appendTo(".edd_user_search_results span"),document.body.style.cursor="default"}})}),a(document.body).on("click.eddSelectUser",".edd_user_search_results span a",function(b){b.preventDefault();var c=a(this).data("login");a(".edd-ajax-user-search").val(c),a(".edd_user_search_results").addClass("hidden"),a(".edd_user_search_results span").html("")}),a(document.body).on("click.eddCancelUserSearch",".edd_user_search_results a.edd-ajax-user-cancel",function(b){b.preventDefault(),a(".edd-ajax-user-search").val(""),a(".edd_user_search_results").addClass("hidden"),a(".edd_user_search_results span").html("")}),a("#edd_dashboard_sales").length&&a.ajax({type:"GET",data:{action:"edd_load_dashboard_widget"},url:ajaxurl,success:function(b){a("#edd_dashboard_sales .inside").html(b)}}),a(document).on("keydown",".customer-note-input",function(b){13==b.keyCode&&(b.metaKey||b.ctrlKey)&&a("#add-customer-note").click()})});var eddFormatCurrency=function(a){var b=parseFloat(a),c=edd_vars.currency,d=edd_vars.currency_decimals;return b.toLocaleString(c,{style:"currency",currency:c,minimumFractionDigits:d,maximumFractionDigits:d})},eddFormatNumber=function(a){var b=parseFloat(a),c=edd_vars.currency;edd_vars.currency_decimals;return b.toLocaleString(c,{style:"decimal",minimumFractionDigits:0,maximumFractionDigits:0})},eddLabelFormatter=function(a,b){return'<div style="font-size:12px; text-align:center; padding:2px">'+a+"</div>"},eddLegendFormatterSales=function(a,b){var c=a.toLowerCase().replace(/\s/g,"-"),d='<div class="edd-legend-color" style="background-color: '+b.color+'"></div>',e='<div class="edd-pie-legend-item">'+a+": "+Math.round(b.percent)+"% ("+eddFormatNumber(b.data[0][1])+")</div>",f='<div id="'+b.edd_vars.id+c+'" class="edd-legend-item-wrapper">'+d+e+"</div>";return jQuery("#edd-pie-legend-"+b.edd_vars.id).append(f),f},eddLegendFormatterEarnings=function(a,b){var c=a.toLowerCase().replace(/\s/g,"-"),d='<div class="edd-legend-color" style="background-color: '+b.color+'"></div>',e='<div class="edd-pie-legend-item">'+a+": "+Math.round(b.percent)+"% ("+eddFormatCurrency(b.data[0][1])+")</div>",f='<div id="'+b.edd_vars.id+c+'" class="edd-legend-item-wrapper">'+d+e+"</div>";return jQuery("#edd-pie-legend-"+b.edd_vars.id).append(f),f};
easy-digital-downloads.php CHANGED
@@ -5,7 +5,7 @@
5
  * Description: The easiest way to sell digital products with WordPress.
6
  * Author: Easy Digital Downloads
7
  * Author URI: https://easydigitaldownloads.com
8
- * Version: 2.7.4
9
  * Text Domain: easy-digital-downloads
10
  * Domain Path: languages
11
  *
@@ -25,7 +25,7 @@
25
  * @package EDD
26
  * @category Core
27
  * @author Pippin Williamson
28
- * @version 2.7.4
29
  */
30
 
31
  // Exit if accessed directly.
@@ -206,7 +206,7 @@ final class Easy_Digital_Downloads {
206
 
207
  // Plugin version.
208
  if ( ! defined( 'EDD_VERSION' ) ) {
209
- define( 'EDD_VERSION', '2.7.4' );
210
  }
211
 
212
  // Plugin Folder Path.
5
  * Description: The easiest way to sell digital products with WordPress.
6
  * Author: Easy Digital Downloads
7
  * Author URI: https://easydigitaldownloads.com
8
+ * Version: 2.7.5
9
  * Text Domain: easy-digital-downloads
10
  * Domain Path: languages
11
  *
25
  * @package EDD
26
  * @category Core
27
  * @author Pippin Williamson
28
+ * @version 2.7.5
29
  */
30
 
31
  // Exit if accessed directly.
206
 
207
  // Plugin version.
208
  if ( ! defined( 'EDD_VERSION' ) ) {
209
+ define( 'EDD_VERSION', '2.7.5' );
210
  }
211
 
212
  // Plugin Folder Path.
includes/EDD_SL_Plugin_Updater.php CHANGED
@@ -7,7 +7,7 @@ if ( ! defined( 'ABSPATH' ) ) exit;
7
  * Allows plugins to use their own update API.
8
  *
9
  * @author Easy Digital Downloads
10
- * @version 1.6.10
11
  */
12
  class EDD_SL_Plugin_Updater {
13
 
@@ -367,7 +367,7 @@ class EDD_SL_Plugin_Updater {
367
  $request->banners = maybe_unserialize( $request->banners );
368
  }
369
 
370
- if( ! empty( $request ) ) {
371
  foreach( $request->sections as $key => $section ) {
372
  $request->$key = (array) $section;
373
  }
7
  * Allows plugins to use their own update API.
8
  *
9
  * @author Easy Digital Downloads
10
+ * @version 1.6.11
11
  */
12
  class EDD_SL_Plugin_Updater {
13
 
367
  $request->banners = maybe_unserialize( $request->banners );
368
  }
369
 
370
+ if( ! empty( $request->sections ) ) {
371
  foreach( $request->sections as $key => $section ) {
372
  $request->$key = (array) $section;
373
  }
includes/admin/import/class-batch-import.php CHANGED
@@ -229,7 +229,7 @@ class EDD_Batch_Import {
229
 
230
  $delimiter = ';';
231
 
232
- } elseif( false !== strpos( $str, '/' ) && ! filter_var( $str, FILTER_VALIDATE_URL ) ) {
233
 
234
  $delimiter = '/';
235
 
229
 
230
  $delimiter = ';';
231
 
232
+ } elseif( false !== strpos( $str, '/' ) && ! filter_var( str_replace( ' ', '%20', $str ), FILTER_VALIDATE_URL ) ) {
233
 
234
  $delimiter = '/';
235
 
includes/admin/reporting/class-file-downloads-logs-list-table.php CHANGED
@@ -123,8 +123,8 @@ class EDD_File_Downloads_Log_Table extends WP_List_Table {
123
  switch ( $column_name ) {
124
  case 'download' :
125
  return '<a href="' . add_query_arg( 'download', $item[ $column_name ] ) . '" >' . get_the_title( $item[ $column_name ] ) . '</a>';
126
- case 'user_id' :
127
- return $item[ $column_name ] ? '<a href="' . add_query_arg( 'user', $item[ $column_name ] ) . '">' . $item['user_name'] . '</a>' : $item['user_name'];
128
  case 'payment_id' :
129
  return $item['payment_id'] !== false ? '<a href="' . admin_url( 'edit.php?post_type=download&page=edd-payment-history&view=view-order-details&id=' . $item['payment_id'] ) . '">' . edd_get_payment_number( $item['payment_id'] ) . '</a>' : '';
130
  default:
@@ -143,7 +143,7 @@ class EDD_File_Downloads_Log_Table extends WP_List_Table {
143
  $columns = array(
144
  'ID' => __( 'Log ID', 'easy-digital-downloads' ),
145
  'download' => edd_get_label_singular(),
146
- 'user_id' => __( 'User', 'easy-digital-downloads' ),
147
  'payment_id' => __( 'Payment ID', 'easy-digital-downloads' ),
148
  'file' => __( 'File', 'easy-digital-downloads' ),
149
  'ip' => __( 'IP Address', 'easy-digital-downloads' ),
@@ -385,11 +385,12 @@ class EDD_File_Downloads_Log_Table extends WP_List_Table {
385
  if ( $logs ) {
386
  foreach ( $logs as $log ) {
387
 
388
- $meta = get_post_custom( $log->ID );
389
- $user_info = isset( $meta['_edd_log_user_info'] ) ? maybe_unserialize( $meta['_edd_log_user_info'][0] ) : array();
390
- $payment_id = isset( $meta['_edd_log_payment_id'] ) ? $meta['_edd_log_payment_id'][0] : false;
391
- $ip = $meta['_edd_log_ip'][0];
392
- $user_id = isset( $user_info['id'] ) ? $user_info['id'] : false;
 
393
 
394
  if( ! array_key_exists( $log->post_parent, $this->queried_files ) ) {
395
  $files = maybe_unserialize( $wpdb->get_var( $wpdb->prepare( "SELECT meta_value from $wpdb->postmeta WHERE post_id = %d and meta_key = 'edd_download_files'", $log->post_parent ) ) );
@@ -406,9 +407,8 @@ class EDD_File_Downloads_Log_Table extends WP_List_Table {
406
  $logs_data[] = array(
407
  'ID' => $log->ID,
408
  'download' => $log->post_parent,
 
409
  'payment_id' => $payment_id,
410
- 'user_id' => $user_id ? $user_id : ( isset( $user_info['email'] ) ? $user_info['email'] : null ),
411
- 'user_name' => isset( $user_info['email'] ) ? $user_info['email'] : ( isset( $user_info['name'] ) ? $user_info['name'] : '' ),
412
  'file' => $file_name,
413
  'ip' => $ip,
414
  'date' => $log->post_date,
123
  switch ( $column_name ) {
124
  case 'download' :
125
  return '<a href="' . add_query_arg( 'download', $item[ $column_name ] ) . '" >' . get_the_title( $item[ $column_name ] ) . '</a>';
126
+ case 'customer' :
127
+ return '<a href="' . add_query_arg( 'user', $item[ 'customer' ]->email ) . '">' . $item['customer']->name . '</a>';
128
  case 'payment_id' :
129
  return $item['payment_id'] !== false ? '<a href="' . admin_url( 'edit.php?post_type=download&page=edd-payment-history&view=view-order-details&id=' . $item['payment_id'] ) . '">' . edd_get_payment_number( $item['payment_id'] ) . '</a>' : '';
130
  default:
143
  $columns = array(
144
  'ID' => __( 'Log ID', 'easy-digital-downloads' ),
145
  'download' => edd_get_label_singular(),
146
+ 'customer' => __( 'Customer', 'easy-digital-downloads' ),
147
  'payment_id' => __( 'Payment ID', 'easy-digital-downloads' ),
148
  'file' => __( 'File', 'easy-digital-downloads' ),
149
  'ip' => __( 'IP Address', 'easy-digital-downloads' ),
385
  if ( $logs ) {
386
  foreach ( $logs as $log ) {
387
 
388
+ $meta = get_post_custom( $log->ID );
389
+ $user_info = isset( $meta['_edd_log_user_info'] ) ? maybe_unserialize( $meta['_edd_log_user_info'][0] ) : array();
390
+ $payment_id = isset( $meta['_edd_log_payment_id'] ) ? $meta['_edd_log_payment_id'][0] : false;
391
+ $ip = $meta['_edd_log_ip'][0];
392
+ $user_id = isset( $user_info['id'] ) ? $user_info['id'] : false;
393
+ $customer_id = edd_get_payment_customer_id( $payment_id );
394
 
395
  if( ! array_key_exists( $log->post_parent, $this->queried_files ) ) {
396
  $files = maybe_unserialize( $wpdb->get_var( $wpdb->prepare( "SELECT meta_value from $wpdb->postmeta WHERE post_id = %d and meta_key = 'edd_download_files'", $log->post_parent ) ) );
407
  $logs_data[] = array(
408
  'ID' => $log->ID,
409
  'download' => $log->post_parent,
410
+ 'customer' => new EDD_Customer( $customer_id ),
411
  'payment_id' => $payment_id,
 
 
412
  'file' => $file_name,
413
  'ip' => $ip,
414
  'date' => $log->post_date,
includes/admin/reporting/class-sales-logs-list-table.php CHANGED
@@ -94,9 +94,8 @@ class EDD_Sales_Log_Table extends WP_List_Table {
94
  $return = '<a href="' . add_query_arg( 'download', $item[ $column_name ] ) . '" >' . $title . '</a>';
95
  break;
96
 
97
- case 'user_id' :
98
- $user = ! empty( $item['user_id'] ) ? $item['user_id'] : edd_get_payment_user_email( $item['payment_id'] );
99
- $return = '<a href="' . admin_url( 'edit.php?post_type=download&page=edd-payment-history&user=' . urlencode( $user ) ) . '">' . $item['user_name'] . '</a>';
100
  break;
101
 
102
  case 'item_price' :
@@ -129,7 +128,7 @@ class EDD_Sales_Log_Table extends WP_List_Table {
129
  public function get_columns() {
130
  $columns = array(
131
  'ID' => __( 'Log ID', 'easy-digital-downloads' ),
132
- 'user_id' => __( 'User', 'easy-digital-downloads' ),
133
  'download' => edd_get_label_singular(),
134
  'amount' => __( 'Item Amount', 'easy-digital-downloads' ),
135
  'payment_id' => __( 'Payment ID', 'easy-digital-downloads' ),
@@ -360,12 +359,11 @@ class EDD_Sales_Log_Table extends WP_List_Table {
360
  $logs_data[] = array(
361
  'ID' => $log->ID,
362
  'payment_id' => $payment->ID,
 
363
  'download' => $log->post_parent,
364
  'price_id' => isset( $log_price_id ) ? $log_price_id : null,
365
  'item_price' => isset( $item['item_price'] ) ? $item['item_price'] : $item['price'],
366
  'amount' => $amount,
367
- 'user_id' => $customer->user_id,
368
- 'user_name' => $customer->name,
369
  'date' => get_post_field( 'post_date', $payment_id ),
370
  'quantity' => $item['quantity'],
371
  // Keep track of the currency. Vital to produce the correct report
94
  $return = '<a href="' . add_query_arg( 'download', $item[ $column_name ] ) . '" >' . $title . '</a>';
95
  break;
96
 
97
+ case 'customer' :
98
+ $return = '<a href="' . admin_url( 'edit.php?post_type=download&page=edd-customers&view=overview&id=' . absint( $item['customer']->id ) ) . '">' . $item['customer']->name . '</a>';
 
99
  break;
100
 
101
  case 'item_price' :
128
  public function get_columns() {
129
  $columns = array(
130
  'ID' => __( 'Log ID', 'easy-digital-downloads' ),
131
+ 'customer' => __( 'Customer', 'easy-digital-downloads' ),
132
  'download' => edd_get_label_singular(),
133
  'amount' => __( 'Item Amount', 'easy-digital-downloads' ),
134
  'payment_id' => __( 'Payment ID', 'easy-digital-downloads' ),
359
  $logs_data[] = array(
360
  'ID' => $log->ID,
361
  'payment_id' => $payment->ID,
362
+ 'customer' => $customer,
363
  'download' => $log->post_parent,
364
  'price_id' => isset( $log_price_id ) ? $log_price_id : null,
365
  'item_price' => isset( $item['item_price'] ) ? $item['item_price'] : $item['price'],
366
  'amount' => $amount,
 
 
367
  'date' => get_post_field( 'post_date', $payment_id ),
368
  'quantity' => $item['quantity'],
369
  // Keep track of the currency. Vital to produce the correct report
includes/api/class-edd-api.php CHANGED
@@ -1632,8 +1632,9 @@ class EDD_API {
1632
  public function get_download_logs( $customer_id = 0 ) {
1633
  global $edd_logs;
1634
 
1635
- $downloads = array();
1636
- $errors = array();
 
1637
 
1638
  $paged = $this->get_paged();
1639
  $per_page = $this->per_page();
@@ -1642,8 +1643,7 @@ class EDD_API {
1642
  $meta_query = array();
1643
  if ( ! empty( $customer_id ) ) {
1644
 
1645
- $customer = new EDD_Customer( $customer_id );
1646
- $invalid_customer = false;
1647
 
1648
  if ( $customer->id > 0 ) {
1649
  $meta_query['relation'] = 'OR';
1632
  public function get_download_logs( $customer_id = 0 ) {
1633
  global $edd_logs;
1634
 
1635
+ $downloads = array();
1636
+ $errors = array();
1637
+ $invalid_customer = false;
1638
 
1639
  $paged = $this->get_paged();
1640
  $per_page = $this->per_page();
1643
  $meta_query = array();
1644
  if ( ! empty( $customer_id ) ) {
1645
 
1646
+ $customer = new EDD_Customer( $customer_id );
 
1647
 
1648
  if ( $customer->id > 0 ) {
1649
  $meta_query['relation'] = 'OR';
includes/checkout/template.php CHANGED
@@ -173,38 +173,38 @@ function edd_user_info_fields() {
173
  $customer = array_map( 'sanitize_text_field', $customer );
174
  ?>
175
  <fieldset id="edd_checkout_user_info">
176
- <legend><?php echo apply_filters( 'edd_checkout_personal_info_text', __( 'Personal Info', 'easy-digital-downloads' ) ); ?></legend>
177
  <?php do_action( 'edd_purchase_form_before_email' ); ?>
178
  <p id="edd-email-wrap">
179
  <label class="edd-label" for="edd-email">
180
- <?php _e( 'Email Address', 'easy-digital-downloads' ); ?>
181
  <?php if( edd_field_is_required( 'edd_email' ) ) { ?>
182
  <span class="edd-required-indicator">*</span>
183
  <?php } ?>
184
  </label>
185
- <span class="edd-description"><?php _e( 'We will send the purchase receipt to this address.', 'easy-digital-downloads' ); ?></span>
186
- <input class="edd-input required" type="email" name="edd_email" placeholder="<?php _e( 'Email address', 'easy-digital-downloads' ); ?>" id="edd-email" value="<?php echo esc_attr( $customer['email'] ); ?>"<?php if( edd_field_is_required( 'edd_email' ) ) { echo ' required '; } ?>/>
187
  </p>
188
  <?php do_action( 'edd_purchase_form_after_email' ); ?>
189
  <p id="edd-first-name-wrap">
190
  <label class="edd-label" for="edd-first">
191
- <?php _e( 'First Name', 'easy-digital-downloads' ); ?>
192
  <?php if( edd_field_is_required( 'edd_first' ) ) { ?>
193
  <span class="edd-required-indicator">*</span>
194
  <?php } ?>
195
  </label>
196
- <span class="edd-description"><?php _e( 'We will use this to personalize your account experience.', 'easy-digital-downloads' ); ?></span>
197
- <input class="edd-input required" type="text" name="edd_first" placeholder="<?php _e( 'First name', 'easy-digital-downloads' ); ?>" id="edd-first" value="<?php echo esc_attr( $customer['first_name'] ); ?>"<?php if( edd_field_is_required( 'edd_first' ) ) { echo ' required '; } ?>/>
198
  </p>
199
  <p id="edd-last-name-wrap">
200
  <label class="edd-label" for="edd-last">
201
- <?php _e( 'Last Name', 'easy-digital-downloads' ); ?>
202
  <?php if( edd_field_is_required( 'edd_last' ) ) { ?>
203
  <span class="edd-required-indicator">*</span>
204
  <?php } ?>
205
  </label>
206
- <span class="edd-description"><?php _e( 'We will use this as well to personalize your account experience.', 'easy-digital-downloads' ); ?></span>
207
- <input class="edd-input<?php if( edd_field_is_required( 'edd_last' ) ) { echo ' required'; } ?>" type="text" name="edd_last" id="edd-last" placeholder="<?php _e( 'Last name', 'easy-digital-downloads' ); ?>" value="<?php echo esc_attr( $customer['last_name'] ); ?>"<?php if( edd_field_is_required( 'edd_last' ) ) { echo ' required '; } ?>/>
208
  </p>
209
  <?php do_action( 'edd_purchase_form_user_info' ); ?>
210
  <?php do_action( 'edd_purchase_form_user_info_fields' ); ?>
@@ -581,47 +581,49 @@ function edd_payment_mode_select() {
581
  $gateways = edd_get_enabled_payment_gateways( true );
582
  $page_URL = edd_get_current_page_url();
583
  $chosen_gateway = edd_get_chosen_gateway();
584
- do_action('edd_payment_mode_top'); ?>
585
- <?php if( edd_is_ajax_disabled() ) { ?>
586
- <form id="edd_payment_mode" action="<?php echo $page_URL; ?>" method="GET">
587
- <?php } ?>
588
- <fieldset id="edd_payment_mode_select">
589
- <?php do_action( 'edd_payment_mode_before_gateways_wrap' ); ?>
590
- <div id="edd-payment-mode-wrap">
591
- <span class="edd-payment-mode-label"><?php _e( 'Select Payment Method', 'easy-digital-downloads' ); ?></span><br/>
592
- <?php
 
 
593
 
594
- do_action( 'edd_payment_mode_before_gateways' );
595
 
596
- foreach ( $gateways as $gateway_id => $gateway ) :
597
 
598
- $label = apply_filters( 'edd_gateway_checkout_label_' . $gateway_id, $gateway['checkout_label'] );
599
- $checked = checked( $gateway_id, $chosen_gateway, false );
600
- $checked_class = $checked ? ' edd-gateway-option-selected' : '';
601
 
602
- echo '<label for="edd-gateway-' . esc_attr( $gateway_id ) . '" class="edd-gateway-option' . $checked_class . '" id="edd-gateway-option-' . esc_attr( $gateway_id ) . '">';
603
- echo '<input type="radio" name="payment-mode" class="edd-gateway" id="edd-gateway-' . esc_attr( $gateway_id ) . '" value="' . esc_attr( $gateway_id ) . '"' . $checked . '>' . esc_html( $label );
604
- echo '</label>';
605
 
606
- endforeach;
607
 
608
- do_action( 'edd_payment_mode_after_gateways' );
609
 
610
- ?>
611
- </div>
612
- <?php do_action( 'edd_payment_mode_after_gateways_wrap' ); ?>
613
- </fieldset>
614
- <fieldset id="edd_payment_mode_submit" class="edd-no-js">
615
- <p id="edd-next-submit-wrap">
616
- <?php echo edd_checkout_button_next(); ?>
617
- </p>
618
- </fieldset>
619
- <?php if( edd_is_ajax_disabled() ) { ?>
620
- </form>
621
- <?php } ?>
 
622
  <div id="edd_purchase_form_wrap"></div><!-- the checkout fields are loaded into this-->
623
 
624
- <div id="edd_purchase_form_wrap"></div><!-- the checkout fields are loaded into this-->
625
  <?php do_action('edd_payment_mode_bottom');
626
  }
627
  add_action( 'edd_payment_mode_select', 'edd_payment_mode_select' );
173
  $customer = array_map( 'sanitize_text_field', $customer );
174
  ?>
175
  <fieldset id="edd_checkout_user_info">
176
+ <legend><?php echo apply_filters( 'edd_checkout_personal_info_text', esc_html__( 'Personal Info', 'easy-digital-downloads' ) ); ?></legend>
177
  <?php do_action( 'edd_purchase_form_before_email' ); ?>
178
  <p id="edd-email-wrap">
179
  <label class="edd-label" for="edd-email">
180
+ <?php esc_html_e( 'Email Address', 'easy-digital-downloads' ); ?>
181
  <?php if( edd_field_is_required( 'edd_email' ) ) { ?>
182
  <span class="edd-required-indicator">*</span>
183
  <?php } ?>
184
  </label>
185
+ <span class="edd-description" id="edd-email-description"><?php esc_html_e( 'We will send the purchase receipt to this address.', 'easy-digital-downloads' ); ?></span>
186
+ <input class="edd-input required" type="email" name="edd_email" placeholder="<?php esc_html_e( 'Email address', 'easy-digital-downloads' ); ?>" id="edd-email" value="<?php echo esc_attr( $customer['email'] ); ?>" aria-describedby="edd-email-description"<?php if( edd_field_is_required( 'edd_email' ) ) { echo ' required '; } ?>/>
187
  </p>
188
  <?php do_action( 'edd_purchase_form_after_email' ); ?>
189
  <p id="edd-first-name-wrap">
190
  <label class="edd-label" for="edd-first">
191
+ <?php esc_html_e( 'First Name', 'easy-digital-downloads' ); ?>
192
  <?php if( edd_field_is_required( 'edd_first' ) ) { ?>
193
  <span class="edd-required-indicator">*</span>
194
  <?php } ?>
195
  </label>
196
+ <span class="edd-description" id="edd-first-description"><?php esc_html_e( 'We will use this to personalize your account experience.', 'easy-digital-downloads' ); ?></span>
197
+ <input class="edd-input required" type="text" name="edd_first" placeholder="<?php esc_html_e( 'First name', 'easy-digital-downloads' ); ?>" id="edd-first" value="<?php echo esc_attr( $customer['first_name'] ); ?>"<?php if( edd_field_is_required( 'edd_first' ) ) { echo ' required '; } ?> aria-describedby="edd-first-description" />
198
  </p>
199
  <p id="edd-last-name-wrap">
200
  <label class="edd-label" for="edd-last">
201
+ <?php esc_html_e( 'Last Name', 'easy-digital-downloads' ); ?>
202
  <?php if( edd_field_is_required( 'edd_last' ) ) { ?>
203
  <span class="edd-required-indicator">*</span>
204
  <?php } ?>
205
  </label>
206
+ <span class="edd-description" id="edd-last-description"><?php esc_html_e( 'We will use this as well to personalize your account experience.', 'easy-digital-downloads' ); ?></span>
207
+ <input class="edd-input<?php if( edd_field_is_required( 'edd_last' ) ) { echo ' required'; } ?>" type="text" name="edd_last" id="edd-last" placeholder="<?php esc_html_e( 'Last name', 'easy-digital-downloads' ); ?>" value="<?php echo esc_attr( $customer['last_name'] ); ?>"<?php if( edd_field_is_required( 'edd_last' ) ) { echo ' required '; } ?> aria-describedby="edd-last-description"/>
208
  </p>
209
  <?php do_action( 'edd_purchase_form_user_info' ); ?>
210
  <?php do_action( 'edd_purchase_form_user_info_fields' ); ?>
581
  $gateways = edd_get_enabled_payment_gateways( true );
582
  $page_URL = edd_get_current_page_url();
583
  $chosen_gateway = edd_get_chosen_gateway();
584
+ ?>
585
+ <div id="edd_payment_mode_select_wrap">
586
+ <?php do_action('edd_payment_mode_top'); ?>
587
+ <?php if( edd_is_ajax_disabled() ) { ?>
588
+ <form id="edd_payment_mode" action="<?php echo $page_URL; ?>" method="GET">
589
+ <?php } ?>
590
+ <fieldset id="edd_payment_mode_select">
591
+ <legend><?php _e( 'Select Payment Method', 'easy-digital-downloads' ); ?></legend>
592
+ <?php do_action( 'edd_payment_mode_before_gateways_wrap' ); ?>
593
+ <div id="edd-payment-mode-wrap">
594
+ <?php
595
 
596
+ do_action( 'edd_payment_mode_before_gateways' );
597
 
598
+ foreach ( $gateways as $gateway_id => $gateway ) :
599
 
600
+ $label = apply_filters( 'edd_gateway_checkout_label_' . $gateway_id, $gateway['checkout_label'] );
601
+ $checked = checked( $gateway_id, $chosen_gateway, false );
602
+ $checked_class = $checked ? ' edd-gateway-option-selected' : '';
603
 
604
+ echo '<label for="edd-gateway-' . esc_attr( $gateway_id ) . '" class="edd-gateway-option' . $checked_class . '" id="edd-gateway-option-' . esc_attr( $gateway_id ) . '">';
605
+ echo '<input type="radio" name="payment-mode" class="edd-gateway" id="edd-gateway-' . esc_attr( $gateway_id ) . '" value="' . esc_attr( $gateway_id ) . '"' . $checked . '>' . esc_html( $label );
606
+ echo '</label>';
607
 
608
+ endforeach;
609
 
610
+ do_action( 'edd_payment_mode_after_gateways' );
611
 
612
+ ?>
613
+ </div>
614
+ <?php do_action( 'edd_payment_mode_after_gateways_wrap' ); ?>
615
+ </fieldset>
616
+ <fieldset id="edd_payment_mode_submit" class="edd-no-js">
617
+ <p id="edd-next-submit-wrap">
618
+ <?php echo edd_checkout_button_next(); ?>
619
+ </p>
620
+ </fieldset>
621
+ <?php if( edd_is_ajax_disabled() ) { ?>
622
+ </form>
623
+ <?php } ?>
624
+ </div>
625
  <div id="edd_purchase_form_wrap"></div><!-- the checkout fields are loaded into this-->
626
 
 
627
  <?php do_action('edd_payment_mode_bottom');
628
  }
629
  add_action( 'edd_payment_mode_select', 'edd_payment_mode_select' );
includes/class-edd-db.php CHANGED
@@ -149,10 +149,11 @@ abstract class EDD_DB {
149
  $column_formats = array_merge( array_flip( $data_keys ), $column_formats );
150
 
151
  $wpdb->insert( $this->table_name, $data, $column_formats );
 
152
 
153
- do_action( 'edd_post_insert_' . $type, $wpdb->insert_id, $data );
154
 
155
- return $wpdb->insert_id;
156
  }
157
 
158
  /**
149
  $column_formats = array_merge( array_flip( $data_keys ), $column_formats );
150
 
151
  $wpdb->insert( $this->table_name, $data, $column_formats );
152
+ $wpdb_insert_id = $wpdb->insert_id;
153
 
154
+ do_action( 'edd_post_insert_' . $type, $wpdb_insert_id, $data );
155
 
156
+ return $wpdb_insert_id;
157
  }
158
 
159
  /**
includes/class-edd-discount.php CHANGED
@@ -1093,11 +1093,19 @@ class EDD_Discount {
1093
  $discount_id = wp_insert_post( $args );
1094
 
1095
  if ( ! empty( $discount_id ) ) {
 
1096
  $this->ID = $discount_id;
1097
 
1098
  foreach ( $discount_data as $key => $value ) {
1099
- $this->update_meta( $key, $value );
 
 
 
 
 
 
1100
  }
 
1101
  }
1102
 
1103
  return $this->ID;
@@ -1586,11 +1594,11 @@ class EDD_Discount {
1586
  // First absint the items, then sort, and reset the array keys
1587
  $product_reqs = array_map( 'absint', $product_reqs );
1588
  asort( $product_reqs );
1589
- $product_reqs = array_values( $product_reqs );
1590
 
1591
  $excluded_ps = array_map( 'absint', $excluded_ps );
1592
  asort( $excluded_ps );
1593
- $excluded_ps = array_values( $excluded_ps );
1594
 
1595
  $cart_ids = array_map( 'absint', $cart_ids );
1596
  asort( $cart_ids );
@@ -1598,39 +1606,63 @@ class EDD_Discount {
1598
 
1599
  // Ensure we have requirements before proceeding
1600
  if ( ! $return && ! empty( $product_reqs ) ) {
 
1601
  switch( $this->product_condition ) {
 
1602
  case 'all' :
 
1603
  // Default back to true
1604
  $return = true;
1605
 
1606
  foreach ( $product_reqs as $download_id ) {
 
 
 
 
 
1607
  if ( ! edd_item_in_cart( $download_id ) ) {
 
1608
  if ( $set_error ) {
1609
  edd_set_error( 'edd-discount-error', __( 'The product requirements for this discount are not met.', 'easy-digital-downloads' ) );
1610
  }
1611
 
1612
  $return = false;
 
1613
  break;
 
1614
  }
 
1615
  }
1616
 
1617
  break;
1618
 
1619
  default :
 
1620
  foreach ( $product_reqs as $download_id ) {
 
 
 
 
 
1621
  if ( edd_item_in_cart( $download_id ) ) {
1622
  $return = true;
1623
  break;
1624
  }
 
1625
  }
1626
 
1627
  if ( ! $return && $set_error ) {
1628
  edd_set_error( 'edd-discount-error', __( 'The product requirements for this discount are not met.', 'easy-digital-downloads' ) );
1629
  }
 
1630
  break;
 
1631
  }
 
1632
  } else {
 
1633
  $return = true;
 
1634
  }
1635
 
1636
  if ( ! empty( $excluded_ps ) ) {
1093
  $discount_id = wp_insert_post( $args );
1094
 
1095
  if ( ! empty( $discount_id ) ) {
1096
+
1097
  $this->ID = $discount_id;
1098
 
1099
  foreach ( $discount_data as $key => $value ) {
1100
+
1101
+ if( ! empty( $value ) ) {
1102
+
1103
+ $this->update_meta( $key, $value );
1104
+
1105
+ }
1106
+
1107
  }
1108
+
1109
  }
1110
 
1111
  return $this->ID;
1594
  // First absint the items, then sort, and reset the array keys
1595
  $product_reqs = array_map( 'absint', $product_reqs );
1596
  asort( $product_reqs );
1597
+ $product_reqs = array_filter( array_values( $product_reqs ) );
1598
 
1599
  $excluded_ps = array_map( 'absint', $excluded_ps );
1600
  asort( $excluded_ps );
1601
+ $excluded_ps = array_filter( array_values( $excluded_ps ) );
1602
 
1603
  $cart_ids = array_map( 'absint', $cart_ids );
1604
  asort( $cart_ids );
1606
 
1607
  // Ensure we have requirements before proceeding
1608
  if ( ! $return && ! empty( $product_reqs ) ) {
1609
+
1610
  switch( $this->product_condition ) {
1611
+
1612
  case 'all' :
1613
+
1614
  // Default back to true
1615
  $return = true;
1616
 
1617
  foreach ( $product_reqs as $download_id ) {
1618
+
1619
+ if( empty( $download_id ) ) {
1620
+ continue;
1621
+ }
1622
+
1623
  if ( ! edd_item_in_cart( $download_id ) ) {
1624
+
1625
  if ( $set_error ) {
1626
  edd_set_error( 'edd-discount-error', __( 'The product requirements for this discount are not met.', 'easy-digital-downloads' ) );
1627
  }
1628
 
1629
  $return = false;
1630
+
1631
  break;
1632
+
1633
  }
1634
+
1635
  }
1636
 
1637
  break;
1638
 
1639
  default :
1640
+
1641
  foreach ( $product_reqs as $download_id ) {
1642
+
1643
+ if( empty( $download_id ) ) {
1644
+ continue;
1645
+ }
1646
+
1647
  if ( edd_item_in_cart( $download_id ) ) {
1648
  $return = true;
1649
  break;
1650
  }
1651
+
1652
  }
1653
 
1654
  if ( ! $return && $set_error ) {
1655
  edd_set_error( 'edd-discount-error', __( 'The product requirements for this discount are not met.', 'easy-digital-downloads' ) );
1656
  }
1657
+
1658
  break;
1659
+
1660
  }
1661
+
1662
  } else {
1663
+
1664
  $return = true;
1665
+
1666
  }
1667
 
1668
  if ( ! empty( $excluded_ps ) ) {
includes/emails/class-edd-email-tags.php CHANGED
@@ -411,7 +411,7 @@ function edd_email_tag_download_list( $payment_id ) {
411
  $title .= "&nbsp;&ndash;&nbsp;" . __( 'SKU', 'easy-digital-downloads' ) . ': ' . $sku;
412
  }
413
 
414
- if ( $price_id !== null ) {
415
  $title .= "&nbsp;&ndash;&nbsp;" . edd_get_price_option_name( $item['id'], $price_id, $payment_id );
416
  }
417
 
@@ -460,6 +460,16 @@ function edd_email_tag_download_list( $payment_id ) {
460
  }
461
  }
462
  }
 
 
 
 
 
 
 
 
 
 
463
  }
464
 
465
 
411
  $title .= "&nbsp;&ndash;&nbsp;" . __( 'SKU', 'easy-digital-downloads' ) . ': ' . $sku;
412
  }
413
 
414
+ if( ! empty( $price_id ) && 0 !== $price_id ){
415
  $title .= "&nbsp;&ndash;&nbsp;" . edd_get_price_option_name( $item['id'], $price_id, $payment_id );
416
  }
417
 
460
  }
461
  }
462
  }
463
+ }else{
464
+
465
+ $no_downloads_message = apply_filters( 'edd_receipt_no_files_found_text', __( 'No downloadable files found.', 'easy-digital-downloads' ), $item['id'] );
466
+ $no_downloads_message = apply_filters( 'edd_email_receipt_no_downloads_message', $no_downloads_message, $item['id'], $price_id, $payment_id );
467
+
468
+ if ( ! empty( $no_downloads_message ) ){
469
+ $download_list .= '<div>';
470
+ $download_list .= $no_downloads_message;
471
+ $download_list .= '</div>';
472
+ }
473
  }
474
 
475
 
includes/error-tracking.php CHANGED
@@ -41,6 +41,7 @@ function edd_print_errors() {
41
  }
42
  add_action( 'edd_purchase_form_before_submit', 'edd_print_errors' );
43
  add_action( 'edd_ajax_checkout_errors', 'edd_print_errors' );
 
44
 
45
  /**
46
  * Get Errors
41
  }
42
  add_action( 'edd_purchase_form_before_submit', 'edd_print_errors' );
43
  add_action( 'edd_ajax_checkout_errors', 'edd_print_errors' );
44
+ add_action( 'edd_print_errors', 'edd_print_errors' );
45
 
46
  /**
47
  * Get Errors
includes/gateways/actions.php CHANGED
@@ -50,9 +50,12 @@ add_action( 'wp_ajax_nopriv_edd_load_gateway', 'edd_load_ajax_gateway' );
50
  function edd_no_gateway_error() {
51
  $gateways = edd_get_enabled_payment_gateways();
52
 
53
- if ( empty( $gateways ) && edd_get_cart_total() > 0 )
 
 
54
  edd_set_error( 'no_gateways', __( 'You must enable a payment gateway to use Easy Digital Downloads', 'easy-digital-downloads' ) );
55
- else
56
  edd_unset_error( 'no_gateways' );
 
57
  }
58
  add_action( 'init', 'edd_no_gateway_error' );
50
  function edd_no_gateway_error() {
51
  $gateways = edd_get_enabled_payment_gateways();
52
 
53
+ if ( empty( $gateways ) && edd_get_cart_total() > 0 ) {
54
+ remove_action( 'edd_after_cc_fields', 'edd_default_cc_address_fields' );
55
+ remove_action( 'edd_cc_form', 'edd_get_cc_form' );
56
  edd_set_error( 'no_gateways', __( 'You must enable a payment gateway to use Easy Digital Downloads', 'easy-digital-downloads' ) );
57
+ } else {
58
  edd_unset_error( 'no_gateways' );
59
+ }
60
  }
61
  add_action( 'init', 'edd_no_gateway_error' );
includes/gateways/paypal-standard.php CHANGED
@@ -259,7 +259,7 @@ function edd_process_paypal_purchase( $purchase_data ) {
259
  if ( ! empty( $purchase_data['fees'] ) ) {
260
  $i = empty( $i ) ? 1 : $i;
261
  foreach ( $purchase_data['fees'] as $fee ) {
262
- if ( floatval( $fee['amount'] ) > '0' ) {
263
  // this is a positive fee
264
  $paypal_args['item_name_' . $i ] = stripslashes_deep( html_entity_decode( wp_strip_all_tags( $fee['label'] ), ENT_COMPAT, 'UTF-8' ) );
265
  $paypal_args['quantity_' . $i ] = '1';
259
  if ( ! empty( $purchase_data['fees'] ) ) {
260
  $i = empty( $i ) ? 1 : $i;
261
  foreach ( $purchase_data['fees'] as $fee ) {
262
+ if ( empty( $fee['download_id'] ) && floatval( $fee['amount'] ) > '0' ) {
263
  // this is a positive fee
264
  $paypal_args['item_name_' . $i ] = stripslashes_deep( html_entity_decode( wp_strip_all_tags( $fee['label'] ), ENT_COMPAT, 'UTF-8' ) );
265
  $paypal_args['quantity_' . $i ] = '1';
includes/payments/functions.php CHANGED
@@ -168,6 +168,8 @@ function edd_insert_payment( $payment_data = array() ) {
168
 
169
  if ( $resume_payment ) {
170
 
 
 
171
  $payment->add_note( __( 'Payment recovery processed', 'easy-digital-downloads' ) );
172
 
173
  // Since things could have been added/removed since we first crated this...rebuild the cart details.
168
 
169
  if ( $resume_payment ) {
170
 
171
+ $payment->date = date( 'Y-m-d G:i:s', current_time( 'timestamp' ) );
172
+
173
  $payment->add_note( __( 'Payment recovery processed', 'easy-digital-downloads' ) );
174
 
175
  // Since things could have been added/removed since we first crated this...rebuild the cart details.
includes/scripts.php CHANGED
@@ -254,7 +254,7 @@ function edd_load_admin_scripts( $hook ) {
254
  wp_enqueue_script( 'thickbox' );
255
  wp_enqueue_style( 'thickbox' );
256
 
257
- wp_register_style( 'edd-admin', $css_dir . 'edd-admin' . $suffix . '.css', EDD_VERSION );
258
  wp_enqueue_style( 'edd-admin' );
259
  }
260
  add_action( 'admin_enqueue_scripts', 'edd_load_admin_scripts', 100 );
254
  wp_enqueue_script( 'thickbox' );
255
  wp_enqueue_style( 'thickbox' );
256
 
257
+ wp_register_style( 'edd-admin', $css_dir . 'edd-admin' . $suffix . '.css', array(), EDD_VERSION );
258
  wp_enqueue_style( 'edd-admin' );
259
  }
260
  add_action( 'admin_enqueue_scripts', 'edd_load_admin_scripts', 100 );
includes/user-functions.php CHANGED
@@ -827,7 +827,12 @@ function edd_validate_user_verification_token( $url = '' ) {
827
 
828
  do_action( 'edd_user_verification_token_expired' );
829
 
830
- wp_die( apply_filters( 'edd_verification_link_expired_text', __( 'Sorry but your account verification link has expired. <a href="#">Click here</a> to request a new verification URL.', 'easy-digital-downloads' ) ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );
 
 
 
 
 
831
 
832
  }
833
 
827
 
828
  do_action( 'edd_user_verification_token_expired' );
829
 
830
+ $link_text = sprintf(
831
+ __( 'Sorry but your account verification link has expired. <a href="%s">Click here</a> to request a new verification URL.', 'easy-digital-downloads' ),
832
+ edd_get_user_verification_request_url()
833
+ );
834
+
835
+ wp_die( apply_filters( 'edd_verification_link_expired_text', $link_text ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );
836
 
837
  }
838
 
readme.txt CHANGED
@@ -6,7 +6,7 @@ Donate link: https://easydigitaldownloads.com/donate/
6
  Tags: download, downloads, e-store, eshop, digital downloads, e-commerce, wp-ecommerce, wp ecommerce
7
  Requires at least: 4.0
8
  Tested up to: 4.8
9
- Stable Tag: 2.7.4
10
 
11
  License: GNU Version 2 or Any Later Version
12
 
@@ -194,6 +194,27 @@ Yes, through the addition of one or more of the add-on payment gateways, you can
194
 
195
  == Changelog ==
196
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
197
  = 2.7.4, February 22, 2017 =
198
 
199
  * Fix: "Loading" text shown on add to cart buttons for sites without screen ready text CSS.
6
  Tags: download, downloads, e-store, eshop, digital downloads, e-commerce, wp-ecommerce, wp ecommerce
7
  Requires at least: 4.0
8
  Tested up to: 4.8
9
+ Stable Tag: 2.7.5
10
 
11
  License: GNU Version 2 or Any Later Version
12
 
194
 
195
  == Changelog ==
196
 
197
+ = 2.7.5, March 6, 2017 =
198
+
199
+ * Tweak: Added a new filter that allows for the message shown in the email receipt when there are no download files to be controlled
200
+ * Tweak: Renamed "User" to "Customer" on sales and file downloads logs view and updated the columns to always show the customer name
201
+ * Fix: No error messages shown on [edd_register] shortcode
202
+ * Fix: Product Requirements check for discount codes fail if database value contains an empty string
203
+ * Fix: Empty metadata values get stored when creating discount codes
204
+ * Fix: Recovered payments do not store the correct purchase date
205
+ * Fix: "Click here to request a new verification URL" link does not contain a real URL
206
+ * Fix: Browser cache not flushed when EDD CSS is updated
207
+ * Fix: Spaces in URLs for files and featured images can result in import problems
208
+ * Fix: Positive fees should not be added to PayPal Standard when assigned a Download ID
209
+ * Fix: Extra dash output in email receipt and purchase history when no price option is present
210
+ * Fix: It is possible for the ID returned from EDD_DB::insert() to be returned incorrectly
211
+ * Fix: Invalid customer error shown in file downloads log endpoint of the REST API
212
+ * Fix: Removing items from an order can result in the wrong item being removed after save
213
+ * Fix: Credit Card and billing address fields shown on checkout even when no payment gateways are enabled
214
+ * Fix: Personal Info section of checkout missing the aria-describedby attribute
215
+ * Fix: Payment mode fieldset does not have a legend tag
216
+ * Fix: Duplicate DIV tag on checkout
217
+
218
  = 2.7.4, February 22, 2017 =
219
 
220
  * Fix: "Loading" text shown on add to cart buttons for sites without screen ready text CSS.
templates/history-downloads.php CHANGED
@@ -40,7 +40,7 @@ if ( $purchases ) :
40
  $name = get_the_title( $download['id'] );
41
 
42
  // Retrieve and append the price option name
43
- if ( is_numeric( $price_id ) ) {
44
  $name .= ' - ' . edd_get_price_option_name( $download['id'], $price_id, $payment->ID );
45
  }
46
 
40
  $name = get_the_title( $download['id'] );
41
 
42
  // Retrieve and append the price option name
43
+ if ( ! empty( $price_id ) && 0 !== $price_id ) {
44
  $name .= ' - ' . edd_get_price_option_name( $download['id'], $price_id, $payment->ID );
45
  }
46