Easy Digital Downloads - Version 2.7.9

Version Description

Download this release

Release Info

Developer cklosows
Plugin Icon 128x128 Easy Digital Downloads
Version 2.7.9
Comparing to
See all releases

Code changes from version 2.7.8 to 2.7.9

assets/js/admin-scripts.js CHANGED
@@ -387,7 +387,7 @@ jQuery(document).ready(function ($) {
387
  // Update base state field based on selected base country
388
  $('select[name="edd-payment-address[0][country]"]').change(function() {
389
  var $this = $(this);
390
- data = {
391
  action: 'edd_get_shop_states',
392
  country: $this.val(),
393
  field_name: 'edd-payment-address[0][state]'
@@ -1075,7 +1075,7 @@ jQuery(document).ready(function ($) {
1075
  // Update base state field based on selected base country
1076
  $('select[name="edd_settings[base_country]"]').change(function() {
1077
  var $this = $(this), $tr = $this.closest('tr');
1078
- data = {
1079
  action: 'edd_get_shop_states',
1080
  country: $(this).val(),
1081
  field_name: 'edd_settings[base_state]'
@@ -1095,7 +1095,7 @@ jQuery(document).ready(function ($) {
1095
  // Update tax rate state field based on selected rate country
1096
  $( document.body ).on('change', '#edd_tax_rates select.edd-tax-country', function() {
1097
  var $this = $(this);
1098
- data = {
1099
  action: 'edd_get_shop_states',
1100
  country: $(this).val(),
1101
  field_name: $this.attr('name').replace('country', 'state')
@@ -1296,6 +1296,7 @@ jQuery(document).ready(function ($) {
1296
  var val = $(this).val()
1297
  var container = $(this).closest( '.edd-select-chosen' );
1298
  var menu_id = container.attr('id').replace( '_chosen', '' );
 
1299
  var no_bundles = container.hasClass( 'no-bundles' );
1300
  var variations = container.hasClass( 'variations' );
1301
  var lastKey = e.which;
@@ -1305,11 +1306,11 @@ jQuery(document).ready(function ($) {
1305
  if ( container.prev().data('search-type') ) {
1306
 
1307
  // Don't trigger AJAX if this select has all options loaded
1308
- if ( 'no_ajax' == container.prev().data('search-type') ) {
1309
  return;
1310
  }
1311
 
1312
- search_type = 'edd_' + container.prev().data('search-type') + '_search';
1313
  }
1314
 
1315
  // Don't fire if short or is a modifier key (shift, ctrl, apple command key, or arrow keys)
@@ -1342,20 +1343,20 @@ jQuery(document).ready(function ($) {
1342
  },
1343
  dataType: "json",
1344
  beforeSend: function(){
1345
- $('ul.chosen-results').empty();
1346
  },
1347
  success: function( data ) {
1348
  // Remove all options but those that are selected
1349
- $('#' + menu_id + ' option:not(:selected)').remove();
1350
  $.each( data, function( key, item ) {
1351
  // Add any option that doesn't already exist
1352
- if( ! $('#' + menu_id + ' option[value="' + item.id + '"]').length ) {
1353
- $('#' + menu_id).prepend( '<option value="' + item.id + '">' + item.name + '</option>' );
1354
  }
1355
  });
1356
  // Update the options
1357
  $('.edd-select-chosen').trigger('chosen:updated');
1358
- $('#' + menu_id).next().find('input').val(val);
1359
  }
1360
  }).fail(function (response) {
1361
  if ( window.console && window.console.log ) {
@@ -1908,7 +1909,7 @@ jQuery(document).ready(function ($) {
1908
  change_country: function() {
1909
  $('select[name="customerinfo[country]"]').change(function() {
1910
  var $this = $(this);
1911
- data = {
1912
  action: 'edd_get_shop_states',
1913
  country: $this.val(),
1914
  field_name: 'customerinfo[state]'
@@ -1989,7 +1990,7 @@ jQuery(document).ready(function ($) {
1989
  }
1990
 
1991
  $('.edd-ajax').show();
1992
- data = {
1993
  action: 'edd_search_users',
1994
  user_name: user_search,
1995
  exclude: exclude
387
  // Update base state field based on selected base country
388
  $('select[name="edd-payment-address[0][country]"]').change(function() {
389
  var $this = $(this);
390
+ var data = {
391
  action: 'edd_get_shop_states',
392
  country: $this.val(),
393
  field_name: 'edd-payment-address[0][state]'
1075
  // Update base state field based on selected base country
1076
  $('select[name="edd_settings[base_country]"]').change(function() {
1077
  var $this = $(this), $tr = $this.closest('tr');
1078
+ var data = {
1079
  action: 'edd_get_shop_states',
1080
  country: $(this).val(),
1081
  field_name: 'edd_settings[base_state]'
1095
  // Update tax rate state field based on selected rate country
1096
  $( document.body ).on('change', '#edd_tax_rates select.edd-tax-country', function() {
1097
  var $this = $(this);
1098
+ var data = {
1099
  action: 'edd_get_shop_states',
1100
  country: $(this).val(),
1101
  field_name: $this.attr('name').replace('country', 'state')
1296
  var val = $(this).val()
1297
  var container = $(this).closest( '.edd-select-chosen' );
1298
  var menu_id = container.attr('id').replace( '_chosen', '' );
1299
+ var select = container.prev();
1300
  var no_bundles = container.hasClass( 'no-bundles' );
1301
  var variations = container.hasClass( 'variations' );
1302
  var lastKey = e.which;
1306
  if ( container.prev().data('search-type') ) {
1307
 
1308
  // Don't trigger AJAX if this select has all options loaded
1309
+ if ( 'no_ajax' == select.data('search-type') ) {
1310
  return;
1311
  }
1312
 
1313
+ search_type = 'edd_' + select.data('search-type') + '_search';
1314
  }
1315
 
1316
  // Don't fire if short or is a modifier key (shift, ctrl, apple command key, or arrow keys)
1343
  },
1344
  dataType: "json",
1345
  beforeSend: function(){
1346
+ select.closest('ul.chosen-results').empty();
1347
  },
1348
  success: function( data ) {
1349
  // Remove all options but those that are selected
1350
+ $('option:not(:selected)', select).remove();
1351
  $.each( data, function( key, item ) {
1352
  // Add any option that doesn't already exist
1353
+ if( ! $('option[value="' + item.id + '"]', select).length ) {
1354
+ select.prepend( '<option value="' + item.id + '">' + item.name + '</option>' );
1355
  }
1356
  });
1357
  // Update the options
1358
  $('.edd-select-chosen').trigger('chosen:updated');
1359
+ select.next().find('input').val(val);
1360
  }
1361
  }).fail(function (response) {
1362
  if ( window.console && window.console.log ) {
1909
  change_country: function() {
1910
  $('select[name="customerinfo[country]"]').change(function() {
1911
  var $this = $(this);
1912
+ var data = {
1913
  action: 'edd_get_shop_states',
1914
  country: $this.val(),
1915
  field_name: 'customerinfo[state]'
1990
  }
1991
 
1992
  $('.edd-ajax').show();
1993
+ var data = {
1994
  action: 'edd_search_users',
1995
  user_name: user_search,
1996
  exclude: exclude
assets/js/admin-scripts.min.js CHANGED
@@ -1,2 +1 @@
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};
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),void 0!==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);if(window.formfield=a(this).closest(".edd_repeatable_upload_wrapper"),c)return 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(){c.state().get("selection").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&&void 0!==c.sizes[e]&&(f=c.sizes[e].url),"image"===c.type&&(g=e&&void 0!==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)}})}),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){c.datepicker({dateFormat:"mm/dd/yy"})}({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),c={action:"edd_get_shop_states",country:b.val(),field_name:"edd-payment-address[0][state]"};return a.post(ajaxurl,c,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(){if(1===a(document.body).find("#edd-purchased-files > .row").length)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)})})}}).init(),{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()})}}.init(),{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()})}}.init(),{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);if(window.formfield=a(this).parent().prev(),d)return 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(){d.state().get("selection").each(function(a,b){a=a.toJSON(),window.formfield.val(a.url)})}),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"),d={action:"edd_get_shop_states",country:a(this).val(),field_name:"edd_settings[base_state]"};return a.post(ajaxurl,d,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),c={action:"edd_get_shop_states",country:a(this).val(),field_name:b.attr("name").replace("country","state")};return a.post(ajaxurl,c,function(a){if("nostates"==a){var d='<input type="text" name="'+c.field_name+'" value=""/>';b.parent().next().find("select").replaceWith(d)}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)){2===a("#edd_tax_rates tr:visible").length?(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()})}}.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;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"),f=(d.attr("id").replace("_chosen",""),d.prev()),g=d.hasClass("no-bundles"),h=d.hasClass("variations"),k=b.which,l="edd_download_search";if(d.prev().data("search-type")){if("no_ajax"==f.data("search-type"))return;l="edd_"+f.data("search-type")+"_search"}c.length<=3&&"edd_download_search"==l||16==k||13==k||91==k||17==k||37==k||38==k||39==k||40==k||(clearTimeout(i),i=setTimeout(function(){a.ajax({type:"GET",url:ajaxurl,data:{action:l,s:c,no_bundles:g,variations:h},dataType:"json",beforeSend:function(){f.closest("ul.chosen-results").empty()},success:function(b){a("option:not(:selected)",f).remove(),a.each(b,function(b,c){a('option[value="'+c.id+'"]',f).length||f.prepend('<option value="'+c.id+'">'+c.name+"</option>")}),a(".edd-select-chosen").trigger("chosen:updated"),f.next().find("input").val(c)}}).fail(function(a){window.console&&window.console.log&&console.log(a)}).done(function(a){})},342))}),a("#post").on("click",".edd-thickbox",function(){a(".edd-select-chosen","#choose-download").css("width","100%")}),{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(){a(this).is(":checked")?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){if(a("#confirm-reset").is(":checked"))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){0==a('select[name="download_id"]').val()&&(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})}}.init(),{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")})}}.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),c={action:"edd_get_shop_states",country:b.val(),field_name:"customerinfo[state]"};return a.post(ajaxurl,c,function(a){"nostates"==a?n.vars.state_input.replaceWith('<input type="text" name="'+c.field_name+'" value="" class="edd-edit-toggles medium-text"/>'):n.vars.state_input.replaceWith(a)}),!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();var d={action:"edd_search_users",user_name:b,exclude:c};document.body.style.cursor="wait",a.ajax({type:"POST",data:d,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.8
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.8
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.8' );
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.9
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.9
29
  */
30
 
31
  // Exit if accessed directly.
206
 
207
  // Plugin version.
208
  if ( ! defined( 'EDD_VERSION' ) ) {
209
+ define( 'EDD_VERSION', '2.7.9' );
210
  }
211
 
212
  // Plugin Folder Path.
includes/admin/reporting/graphing.php CHANGED
@@ -772,7 +772,7 @@ function edd_get_report_dates() {
772
 
773
  $current_time = current_time( 'timestamp' );
774
 
775
- $dates['range'] = isset( $_GET['range'] ) ? $_GET['range'] : 'last_30_days';
776
 
777
  if ( 'custom' !== $dates['range'] ) {
778
  $dates['year'] = isset( $_GET['year'] ) ? $_GET['year'] : date( 'Y' );
772
 
773
  $current_time = current_time( 'timestamp' );
774
 
775
+ $dates['range'] = isset( $_GET['range'] ) ? $_GET['range'] : apply_filters( 'edd_get_report_dates_default_range', 'last_30_days' );
776
 
777
  if ( 'custom' !== $dates['range'] ) {
778
  $dates['year'] = isset( $_GET['year'] ) ? $_GET['year'] : date( 'Y' );
includes/payments/actions.php CHANGED
@@ -449,7 +449,7 @@ function edd_recovery_force_login_fields() {
449
  $resuming_payment = EDD()->session->get( 'edd_resume_payment' );
450
  if ( $resuming_payment ) {
451
  $payment = new EDD_Payment( $resuming_payment );
452
- if ( ! empty( $payment->user_id ) && ( ! is_user_logged_in() ) ) {
453
  ?>
454
  <div class="edd-alert edd-alert-info">
455
  <p><?php _e( 'To complete this payment, please login to your account.', 'easy-digital-downloads' ); ?></p>
449
  $resuming_payment = EDD()->session->get( 'edd_resume_payment' );
450
  if ( $resuming_payment ) {
451
  $payment = new EDD_Payment( $resuming_payment );
452
+ if ( $payment->user_id > 0 && ( ! is_user_logged_in() ) ) {
453
  ?>
454
  <div class="edd-alert edd-alert-info">
455
  <p><?php _e( 'To complete this payment, please login to your account.', 'easy-digital-downloads' ); ?></p>
includes/payments/class-edd-payment.php CHANGED
@@ -2067,7 +2067,7 @@ class EDD_Payment {
2067
  return false; // This payment was never completed
2068
  }
2069
 
2070
- $date = ( $date = $this->get_meta( '_edd_completed_date', true ) ) ? $date : $payment->modified_date;
2071
 
2072
  return $date;
2073
  }
2067
  return false; // This payment was never completed
2068
  }
2069
 
2070
+ $date = ( $date = $this->get_meta( '_edd_completed_date', true ) ) ? $date : $payment->date;
2071
 
2072
  return $date;
2073
  }
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, ecommerce, ebook
7
  Requires at least: 4.0
8
  Tested up to: 4.8
9
- Stable Tag: 2.7.8
10
  License: GNU Version 2 or Any Later Version
11
 
12
  The easiest way to sell digital products with WordPress.
@@ -213,6 +213,13 @@ Yes. Easy Digital Downloads also includes default support for Amazon Payments an
213
 
214
  == Changelog ==
215
 
 
 
 
 
 
 
 
216
  = 2.7.8, May 2, 2017 =
217
 
218
  * Fix: Products sometimes duplicated in CSV product export
@@ -243,7 +250,7 @@ Yes. Easy Digital Downloads also includes default support for Amazon Payments an
243
  * Tweak: Added new filter and action to edd_has_user_purchased()
244
  * Tweak: Renamed Czech Republic to Czechia
245
  * Tweak: Log in form on checkout now accepts log-in by email
246
- * Tweak: Addewd new edd_download_inner_class filter
247
 
248
  = 2.7.6, March 24, 2017 =
249
 
6
  Tags: download, downloads, e-store, eshop, digital downloads, e-commerce, wp-ecommerce, wp ecommerce, ecommerce, ebook
7
  Requires at least: 4.0
8
  Tested up to: 4.8
9
+ Stable Tag: 2.7.9
10
  License: GNU Version 2 or Any Later Version
11
 
12
  The easiest way to sell digital products with WordPress.
213
 
214
  == Changelog ==
215
 
216
+ = 2.7.9, May 11, 2017 =
217
+
218
+ * Fix: Chosen search had incorrect select element targeting.
219
+ * Fix: EDD_Payment was using invalid modified_date instead of date.
220
+ * Fix: Recovering a guest payment prompted user to login to complete the purchase.
221
+ * New: Add edd_get_report_dates_default_range filter to report date range.
222
+
223
  = 2.7.8, May 2, 2017 =
224
 
225
  * Fix: Products sometimes duplicated in CSV product export
250
  * Tweak: Added new filter and action to edd_has_user_purchased()
251
  * Tweak: Renamed Czech Republic to Czechia
252
  * Tweak: Log in form on checkout now accepts log-in by email
253
+ * Tweak: Added new edd_download_inner_class filter
254
 
255
  = 2.7.6, March 24, 2017 =
256