Easy Digital Downloads - Version 2.4.6

Version Description

Download this release

Release Info

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

Code changes from version 2.4.5 to 2.4.6

assets/js/admin-scripts.js CHANGED
@@ -1054,7 +1054,6 @@ jQuery(document).ready(function ($) {
1054
 
1055
 
1056
  $('#the-list').on('click', '.editinline', function() {
1057
- inlineEditPost.revert();
1058
 
1059
  var post_id = $(this).closest('tr').attr('id');
1060
 
1054
 
1055
 
1056
  $('#the-list').on('click', '.editinline', function() {
 
1057
 
1058
  var post_id = $(this).closest('tr').attr('id');
1059
 
assets/js/admin-scripts.min.js CHANGED
@@ -1 +1 @@
1
- jQuery(document).ready(function(e){var t={init:function(){this.add(),this.move(),this.remove(),this.type(),this.prices(),this.files(),this.updatePrices()},clone_repeatable:function(t){var d=highest=1;return t.parent().find("tr.edd_repeatable_row").each(function(){var t=e(this).data("key");parseInt(t)>highest&&(highest=t)}),d=highest+=1,clone=t.clone(),clone.find("select").each(function(){e(this).val(t.find('select[name="'+e(this).attr("name")+'"]').val())}),clone.removeClass("edd_add_blank"),clone.attr("data-key",d),clone.find("td input, td select, textarea").val(""),clone.find("input, select, textarea").each(function(){var t=e(this).attr("name");t&&(t=t.replace(/\[(\d+)\]/,"["+parseInt(d)+"]"),e(this).attr("name",t).attr("id",t))}),clone.find("span.edd_price_id").each(function(){e(this).text(parseInt(d))}),clone.find(".edd_repeatable_default_input").each(function(){e(this).val(parseInt(d)).removeAttr("checked")}),clone.find(".search-choice").remove(),clone.find(".chosen-container").remove(),clone},add:function(){e(document.body).on("click",".submit .edd_add_repeatable",function(d){d.preventDefault();var n=e(this),a=n.parent().parent().prev("tr"),i=t.clone_repeatable(a);i.insertAfter(a).find("input, textarea, select").filter(":visible").eq(0).focus(),i.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}),i.find(".edd-select-chosen").css("width","100%")})},move:function(){e(".edd_repeatable_table tbody").sortable({handle:".edd_draghandle",items:".edd_repeatable_row",opacity:.6,cursor:"move",axis:"y",update:function(){var t=0;e(this).find("tr").each(function(){e(this).find("input.edd_repeatable_index").each(function(){e(this).val(t)}),t++})}})},remove:function(){e(document.body).on("click",".edd_remove_repeatable",function(t){t.preventDefault();var d=e(this).parent().parent("tr"),n=d.parent().find("tr").length-1,a=e(this).data("type"),i="tr.edd_repeatable_"+a+"s";if("price"===a){var o=d.data("key");e('.edd_repeatable_condition_field option[value="'+o+'"]').remove()}if(n>1)e("input, select",d).val(""),d.fadeOut("fast").remove();else switch(a){case"price":alert(edd_vars.one_price_min);break;case"file":e("input, select",d).val("");break;default:alert(edd_vars.one_field_min)}e(i).each(function(t){e(this).find("input, select").each(function(){var d=e(this).attr("name");d=d.replace(/\[(\d+)\]/,"["+t+"]"),e(this).attr("name",d).attr("id",d)})})})},type:function(){e(document.body).on("change","#_edd_product_type",function(){var t=e("#edd_products"),d=e("#edd_download_files"),n=e("#edd_download_limit_wrap");"bundle"===e(this).val()?(t.show(),d.hide(),n.hide()):(t.hide(),d.show(),n.show())})},prices:function(){e(document.body).on("change","#edd_variable_pricing",function(){e(".edd_pricing_fields,.edd_repeatable_table .pricing").toggle()})},files:function(){if("undefined"==typeof wp||"1"!==edd_vars.new_media_ui)e(".edd_upload_file_button").length>0&&(window.formfield="",e(document.body).on("click",".edd_upload_file_button",function(t){if(t.preventDefault(),window.formfield=e(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),null!=edd_vars.post_id)var d="post_id="+edd_vars.post_id+"&";tb_show(edd_vars.add_new_download,"media-upload.php?"+d+"TB_iframe=true")}),window.edd_send_to_editor=window.send_to_editor,window.send_to_editor=function(t){window.formfield?(imgurl=e("a","<div>"+t+"</div>").attr("href"),window.formfield.val(imgurl),window.clearInterval(window.tbframe_interval),tb_remove()):window.edd_send_to_editor(t),window.send_to_editor=window.edd_send_to_editor,window.formfield="",window.imagefield=!1});else{var d;window.formfield="",e(document.body).on("click",".edd_upload_file_button",function(n){n.preventDefault();var a=e(this);return window.formfield=e(this).closest(".edd_repeatable_upload_wrapper"),d?void d.open():(d=wp.media.frames.file_frame=wp.media({frame:"post",state:"insert",title:a.data("uploader-title"),button:{text:a.data("uploader-button-text")},multiple:"0"==e(this).data("multiple")?!1:!0}),d.on("menu:render:default",function(e){var t={};e.unset("library-separator"),e.unset("gallery"),e.unset("featured-image"),e.unset("embed"),e.set(t)}),d.on("insert",function(){var e=d.state().get("selection");e.each(function(e,d){if(e=e.toJSON(),0===d)window.formfield.find(".edd_repeatable_attachment_id_field").val(e.id),window.formfield.find(".edd_repeatable_upload_field").val(e.url),window.formfield.find(".edd_repeatable_name_field").val(e.title);else{var n=window.formfield,a=t.clone_repeatable(n);a.find(".edd_repeatable_attachment_id_field").val(e.id),a.find(".edd_repeatable_upload_field").val(e.url),a.find(".edd_repeatable_name_field").val(e.title.length>0?e.title:e.filename),a.insertAfter(n)}})}),void d.open())});var d;window.formfield=""}},updatePrices:function(){e("#edd_price_fields").on("keyup",".edd_variable_prices_name",function(){var t=e(this).parents("tr").data("key"),d=e(this).val(),n=e(".edd_repeatable_condition_field option[value="+t+"]");n.length>0?n.text(d):e(".edd_repeatable_condition_field").append(e("<option></option>").attr("value",t).text(d))})}};t.init();var d=e(".edd_datepicker");if(d.length>0){var n="mm/dd/yy";d.datepicker({dateFormat:n})}var a={init:function(){this.edit_address(),this.remove_download(),this.add_download(),this.new_customer(),this.recalculate_total(),this.variable_prices_check(),this.add_note(),this.remove_note(),this.resend_receipt(),this.copy_download_link()},edit_address:function(){e('select[name="edd-payment-address[0][country]"]').change(function(){var t=e(this);return data={action:"edd_get_shop_states",country:t.val(),field_name:"edd-payment-address[0][state]"},e.post(ajaxurl,data,function(t){var d=e("#edd-order-address-state-wrap select, #edd-order-address-state-wrap input");d.replaceWith("nostates"==t?'<input type="text" name="edd-payment-address[0][state]" value="" class="edd-edit-toggles medium-text"/>':t)}),!1})},remove_download:function(){e("#edd-purchased-files").on("click",".edd-order-remove-download",function(){var t=e(document.body).find("#edd-purchased-files > .row").length;if(1===t)return alert(edd_vars.one_download_min),!1;if(confirm(edd_vars.delete_payment_download)){var d=e(this).data("key"),n=(e(".edd-payment-id").val(),e('input[name="edd-payment-details-downloads['+d+'][id]"]').val()),a=e('input[name="edd-payment-details-downloads['+d+'][price_id]"]').val(),i=e('input[name="edd-payment-details-downloads['+d+'][quantity]"]').val(),o=e('input[name="edd-payment-details-downloads['+d+'][amount]"]').val(),r=e('input[name="edd-payment-removed"]').val();r=e.parseJSON(r),r.length<1&&(r={});var s=[{id:n,price_id:a,quantity:i,amount:o}];r[d]=s,e('input[name="edd-payment-removed"]').val(JSON.stringify(r)),e(this).parent().parent().parent().remove(),e("#edd-payment-downloads-changed").val(1),e(".edd-order-payment-recalc-totals").show()}return!1})},new_customer:function(){e("#edd-customer-details").on("click",".edd-payment-new-customer, .edd-payment-new-customer-cancel",function(t){t.preventDefault(),e(".customer-info").toggle(),e(".new-customer").toggle();var d=e("#edd-new-customer");d.val(e(".new-customer").is(":visible")?1:0)})},add_download:function(){e("#edd-purchased-files").on("click","#edd-order-add-download",function(t){t.preventDefault();var d=e("#edd_order_download_select"),n=e("#edd-order-download-quantity"),a=e("#edd-order-download-amount"),i=e(".edd_price_options_select option:selected"),o=d.val(),r=d.find(":selected").text(),s=n.val(),c=a.val(),l=i.val(),u=i.text();if(1>o)return!1;if(c||(c=0),c=parseFloat(c),isNaN(c))return alert(edd_vars.numeric_item_price),!1;if("1"===edd_vars.quantities_enabled){if(isNaN(parseInt(s)))return alert(edd_vars.numeric_quantity),!1;c*=s}c=c.toFixed(edd_vars.currency_decimals);var _=c+edd_vars.currency_sign;"before"===edd_vars.currency_pos&&(_=edd_vars.currency_sign+c),u&&(r=r+" - "+u);var p=e("#edd-purchased-files div.row").length,f=e("#edd-purchased-files div.row:last").clone();f.find(".download span").html('<a href="post.php?post='+o+'&action=edit"></a>'),f.find(".download span a").text(r),f.find(".price-text").text(_),f.find(".item-quantity").text(s),f.find(".item-price").text(edd_vars.currency_sign+(c/s).toFixed(edd_vars.currency_decimals)),f.find("input.edd-payment-details-download-id").val(o),f.find("input.edd-payment-details-download-price-id").val(l),f.find("input.edd-payment-details-download-amount").val(c),f.find("input.edd-payment-details-download-quantity").val(s),f.find("input.edd-payment-details-download-has-log").val(0),f.find("input").each(function(){var t=e(this).attr("name");t=t.replace(/\[(\d+)\]/,"["+parseInt(p)+"]"),e(this).attr("name",t).attr("id",t)}),e("#edd-payment-downloads-changed").val(1),e(f).insertAfter("#edd-purchased-files div.row:last"),e(".edd-order-payment-recalc-totals").show()})},recalculate_total:function(){e("#edd-order-recalc-total").on("click",function(t){t.preventDefault();var d=0,n=e("#edd-purchased-files .row .edd-payment-details-download-amount");n.length&&n.each(function(){d+=parseFloat(e(this).val())}),e(".edd-payment-fees").length&&e(".edd-payment-fees span.fee-amount").each(function(){d+=parseFloat(e(this).data("fee"))}),e("input[name=edd-payment-total]").val(d)})},variable_prices_check:function(){e("#edd-purchased-files").on("change","select#edd_order_download_select",function(){var t=e(this),d=t.val();if(parseInt(d)>0){var n={action:"edd_check_for_download_price_variations",download_id:d};e.ajax({type:"POST",data:n,url:ajaxurl,success:function(d){e(".edd_price_options_select").remove(),e(d).insertAfter(t.next())}}).fail(function(e){window.console&&window.console.log&&console.log(e)})}})},add_note:function(){e("#edd-add-payment-note").on("click",function(t){t.preventDefault();var d={action:"edd_insert_payment_note",payment_id:e(this).data("payment-id"),note:e("#edd-payment-note").val()};if(d.note)e.ajax({type:"POST",data:d,url:ajaxurl,success:function(t){e("#edd-payment-notes-inner").append(t),e(".edd-no-payment-notes").hide(),e("#edd-payment-note").val("")}}).fail(function(e){window.console&&window.console.log&&console.log(e)});else{var n=e("#edd-payment-note").css("border-color");e("#edd-payment-note").css("border-color","red"),setTimeout(function(){e("#edd-payment-note").css("border-color",n)},500)}})},remove_note:function(){e(document.body).on("click",".edd-delete-payment-note",function(t){if(t.preventDefault(),confirm(edd_vars.delete_payment_note)){var d={action:"edd_delete_payment_note",payment_id:e(this).data("payment-id"),note_id:e(this).data("note-id")};return e.ajax({type:"POST",data:d,url:ajaxurl,success:function(){return e("#edd-payment-note-"+d.note_id).remove(),e(".edd-payment-note").length||e(".edd-no-payment-notes").show(),!1}}).fail(function(e){window.console&&window.console.log&&console.log(e)}),!0}})},resend_receipt:function(){e(document.body).on("click","#edd-resend-receipt",function(){return confirm(edd_vars.resend_receipt)})},copy_download_link:function(){e(document.body).on("click",".edd-copy-download-link",function(t){t.preventDefault();var d=e(this),n={action:"edd_get_file_download_link",payment_id:e('input[name="edd_payment_id"]').val(),download_id:d.data("download-id"),price_id:d.data("price-id")};e.ajax({type:"POST",data:n,url:ajaxurl,success:function(t){return e("#edd-download-link").dialog({width:400}).html('<textarea rows="10" cols="40" id="edd-download-link-textarea">'+t+"</textarea>"),e("#edd-download-link-textarea").focus().select(),!1}}).fail(function(e){window.console&&window.console.log&&console.log(e)})})}};a.init();var i={init:function(){this.type_select(),this.product_requirements()},type_select:function(){e("#edd-edit-discount #edd-type, #edd-add-discount #edd-type").change(function(){e(".edd-amount-description").toggle()})},product_requirements:function(){e("#products").change(function(){var t=e("#edd-discount-product-conditions");e(this).val()?t.show():t.hide()})}};i.init();var o={init:function(){this.date_options(),this.customers_export()},date_options:function(){e("#edd-graphs-date-options").change(function(){var t=e(this),d=e("#edd-date-range-options");"other"===t.val()?d.show():d.hide()})},customers_export:function(){e("#edd_customer_export_download").change(function(){var t=e(this),d=e("option:selected",t).val(),n=e("#edd_customer_export_option");if("0"===t.val()?n.show():n.hide(),0!=parseInt(d)){var a={action:"edd_check_for_download_price_variations",download_id:d},i=e(".edd_price_options_select");e.post(ajaxurl,a,function(e){i.remove(),t.after(e)})}else i.remove()})}};o.init();var r={init:function(){this.general(),this.taxes(),this.emails(),this.misc()},general:function(){var t=e(".edd-color-picker");if(t.length&&t.wpColorPicker(),"undefined"==typeof wp||"1"!==edd_vars.new_media_ui){var d=e(".edd_settings_upload_button");d.length>0&&(window.formfield="",e(document.body).on("click",d,function(t){t.preventDefault(),window.formfield=e(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(t){window.formfield?(imgurl=e("a","<div>"+t+"</div>").attr("href"),window.formfield.val(imgurl),window.clearInterval(window.tbframe_interval),tb_remove()):window.edd_send_to_editor(t),window.send_to_editor=window.edd_send_to_editor,window.formfield="",window.imagefield=!1})}else{var n;window.formfield="",e(document.body).on("click",".edd_settings_upload_button",function(t){t.preventDefault();var d=e(this);return window.formfield=e(this).parent().prev(),n?void n.open():(n=wp.media.frames.file_frame=wp.media({frame:"post",state:"insert",title:d.data("uploader_title"),button:{text:d.data("uploader_button_text")},multiple:!1}),n.on("menu:render:default",function(e){var t={};e.unset("library-separator"),e.unset("gallery"),e.unset("featured-image"),e.unset("embed"),e.set(t)}),n.on("insert",function(){var e=n.state().get("selection");e.each(function(e){e=e.toJSON(),window.formfield.val(e.url)})}),void n.open())});var n;window.formfield=""}},taxes:function(){var t=e("select.edd-no-states");t.length&&t.closest("tr").hide(),e('select[name="edd_settings[base_country]"]').change(function(){var t=e(this),d=t.closest("tr");return data={action:"edd_get_shop_states",country:e(this).val(),field_name:"edd_settings[base_state]"},e.post(ajaxurl,data,function(e){"nostates"==e?d.next().hide():(d.next().show(),d.next().find("select").replaceWith(e))}),!1}),e(document.body).on("change","#edd_tax_rates select.edd-tax-country",function(){var t=e(this);return data={action:"edd_get_shop_states",country:e(this).val(),field_name:t.attr("name").replace("country","state")},e.post(ajaxurl,data,function(e){if("nostates"==e){var d='<input type="text" name="'+data.field_name+'" value=""/>';t.parent().next().find("select").replaceWith(d)}else t.parent().next().find("input,select").show(),t.parent().next().find("input,select").replaceWith(e)}),!1}),e("#edd_add_tax_rate").on("click",function(){var t=e("#edd_tax_rates tr:last"),d=t.clone(),n=t.parent().find("tr").length;return d.find("td input").not(":input[type=checkbox]").val(""),d.find('td [type="checkbox"]').attr("checked",!1),d.find("input, select").each(function(){var t=e(this).attr("name");t=t.replace(/\[(\d+)\]/,"["+parseInt(n)+"]"),e(this).attr("name",t).attr("id",t)}),d.find("label").each(function(){var t=e(this).attr("for");t=t.replace(/\[(\d+)\]/,"["+parseInt(n)+"]"),e(this).attr("for",t)}),d.insertAfter(t),!1}),e(document.body).on("click","#edd_tax_rates .edd_remove_tax_rate",function(){if(confirm(edd_vars.delete_tax_rate)){var t=e("#edd_tax_rates tr:visible"),d=t.length;2===d?(e("#edd_tax_rates select").val(""),e('#edd_tax_rates input[type="text"]').val(""),e('#edd_tax_rates input[type="number"]').val(""),e('#edd_tax_rates input[type="checkbox"]').attr("checked",!1)):e(this).closest("tr").remove(),e("#edd_tax_rates tr").each(function(t){e(this).children().find("input, select").each(function(){var d=e(this).attr("name");d=d.replace(/\[(\d+)\]/,"["+(t-1)+"]"),e(this).attr("name",d).attr("id",d)})})}return!1})},emails:function(){var t=e("#email-preview-wrap");if(t.length){var d=e("#email-preview");t.colorbox({inline:!0,href:d,width:"80%",height:"auto"})}},misc:function(){var t=e('select[name="edd_settings[download_method]"]'),d=t.parent().parent().next();"direct"==t.val()&&(d.hide(),d.find("input").prop("checked",!1)),t.on("change",function(){"direct"==e(this).val()?(d.hide(),d.find("input").prop("checked",!1)):d.show()})}};r.init(),e(".download_page_edd-payment-history .row-actions .delete a").on("click",function(){return confirm(edd_vars.delete_payment)?!0:!1}),e("#the-list").on("click",".editinline",function(){inlineEditPost.revert();var t=e(this).closest("tr").attr("id");t=t.replace("post-","");var d=e("#post-"+t),n=d.find(".column-price .downloadprice-"+t).val();n!=e("#post-"+t+".column-price .downloadprice-"+t).val()?e(".regprice","#edd-download-data").val(n).attr("disabled",!1):e(".regprice","#edd-download-data").val(edd_vars.quick_edit_warning).attr("disabled","disabled")}),e(document.body).on("click","#bulk_edit",function(){var t=e("#bulk-edit"),d=new Array;t.find("#bulk-titles").children().each(function(){d.push(e(this).attr("id").replace(/^(ttle)/i,""))});var n=e('#edd-download-data input[name="_edd_regprice"]').val(),a={action:"edd_save_bulk_edit",edd_bulk_nonce:d,post_ids:d,price:n};e.post(ajaxurl,a)}),e(".edd-select-chosen").chosen({inherit_select_classes:!0,placeholder_text_single:edd_vars.one_option,placeholder_text_multiple:edd_vars.one_or_more_option}),e(".chosen-choices").on("click",function(){e(this).children("li").children("input").attr("placeholder",edd_vars.type_to_search)});var s,c=342;e(".edd-select.chosen-container .chosen-search input, .edd-select.chosen-container .search-field input").keyup(function(t){var d=e(this).val(),n=e(this).closest(".edd-select-chosen"),a=n.attr("id").replace("_chosen",""),i=(t.which,"edd_download_search");n.attr("id").indexOf("customer")>=0&&(i="edd_customer_search"),d.length<=3&&"edd_download_search"==i||16==t.which||13==t.which||91==t.which||17==t.which||37==t.which||38==t.which||39==t.which||40==t.which||(clearTimeout(s),s=setTimeout(function(){e.ajax({type:"GET",url:ajaxurl,data:{action:i,s:d,current_id:edd_vars.post_id},dataType:"json",beforeSend:function(){e("ul.chosen-results").empty()},success:function(t){e("#"+a+" option:not(:selected)").remove(),e.each(t,function(t,d){e("#"+a+' option[value="'+d.id+'"]').length||e("#"+a).prepend('<option value="'+d.id+'">'+d.name+"</option>")}),e(".edd-select-chosen").trigger("chosen:updated"),e("#"+a).next().find("input").val(d)}}).fail(function(e){window.console&&window.console.log&&console.log(e)}).done(function(){})},c))}),e("#post").on("click",".edd-thickbox",function(){e(".edd-select-chosen","#choose-download").css("width","100%")});var l={init:function(){this.revoke_api_key(),this.regenerate_api_key()},revoke_api_key:function(){e(document.body).on("click",".edd-revoke-api-key",function(){return confirm(edd_vars.revoke_api_key)})},regenerate_api_key:function(){e(document.body).on("click",".edd-regenerate-api-key",function(){return confirm(edd_vars.regenerate_api_key)})}};l.init();var u={init:function(){this.submit()},submit:function(){var t=this;e(document.body).on("submit",".edd-export-form",function(d){d.preventDefault();var n=e(this).find('input[type="submit"]');if(!n.hasClass("button-disabled")){var a=e(this).serialize();n.addClass("button-disabled"),e(this).find(".notice-wrap").remove(),e(this).append('<div class="notice-wrap"><span class="spinner is-active"></span><div class="edd-progress"><div></div></div></div>'),t.process_step(1,a,t)}})},process_step:function(t,d,n){e.ajax({type:"POST",url:ajaxurl,data:{form:d,action:"edd_do_ajax_export",step:t},dataType:"json",success:function(t){if("done"==t.step||t.error){var a=e(".edd-export-form").find(".edd-progress").parent().parent(),i=a.find(".notice-wrap");if(a.find(".button-disabled").removeClass("button-disabled"),t.error){var o=t.message;i.html('<div class="update error"><p>'+o+"</p></div>")}else i.remove(),window.location=t.url}else e(".edd-progress div").animate({width:t.percentage+"%"},50,function(){}),n.process_step(parseInt(t.step),d,n)}}).fail(function(e){window.console&&window.console.log&&console.log(e)})}};u.init();var _={vars:{customer_card_wrap_editable:e("#edd-customer-card-wrapper .editable"),customer_card_wrap_edit_item:e("#edd-customer-card-wrapper .edit-item"),user_id:e('input[name="customerinfo[user_id]"]'),state_input:e(':input[name="customerinfo[state]"]'),note:e("#customer-note")},init:function(){this.edit_customer(),this.user_search(),this.remove_user(),this.cancel_edit(),this.change_country(),this.add_note(),this.delete_checked()},edit_customer:function(){e(document.body).on("click","#edit-customer",function(e){e.preventDefault(),_.vars.customer_card_wrap_editable.hide(),_.vars.customer_card_wrap_edit_item.fadeIn().css("display","block")})},user_search:function(){e(document.body).on("click.eddSelectUser",".edd_user_search_results a",function(t){t.preventDefault();var d=e(this).data("userid");_.vars.user_id.val(d)})},remove_user:function(){e(document.body).on("click","#disconnect-customer",function(t){t.preventDefault();var d=e('input[name="customerinfo[id]"]').val(),n={edd_action:"disconnect-userid",customer_id:d,_wpnonce:e("#edit-customer-info #_wpnonce").val()};e.post(ajaxurl,n,function(){window.location.href=window.location.href},"json")})},cancel_edit:function(){e(document.body).on("click","#edd-edit-customer-cancel",function(t){t.preventDefault(),_.vars.customer_card_wrap_edit_item.hide(),_.vars.customer_card_wrap_editable.show(),e(".edd_user_search_results").html("")})},change_country:function(){e('select[name="customerinfo[country]"]').change(function(){var t=e(this);return data={action:"edd_get_shop_states",country:t.val(),field_name:"customerinfo[state]"},e.post(ajaxurl,data,function(e){_.vars.state_input.replaceWith("nostates"==e?'<input type="text" name="'+data.field_name+'" value="" class="edd-edit-toggles medium-text"/>':e)}),!1})},add_note:function(){e(document.body).on("click","#add-customer-note",function(t){t.preventDefault();var d={edd_action:"add-customer-note",customer_id:e("#customer-id").val(),customer_note:_.vars.note.val(),add_customer_note_nonce:e("#add_customer_note_nonce").val()};if(d.customer_note)e.ajax({type:"POST",data:d,url:ajaxurl,success:function(t){e("#edd-customer-notes").prepend(t),e(".edd-no-customer-notes").hide(),_.vars.note.val("")}}).fail(function(e){window.console&&window.console.log&&console.log(e)});else{var n=_.vars.note.css("border-color");_.vars.note.css("border-color","red"),setTimeout(function(){_.vars.note.css("border-color",n)},500)}})},delete_checked:function(){e("#edd-customer-delete-confirm").change(function(){var t=e("#edd-customer-delete-records"),d=e("#edd-delete-customer");e(this).prop("checked")?(t.attr("disabled",!1),d.attr("disabled",!1)):(t.attr("disabled",!0),t.prop("checked",!1),d.attr("disabled",!0))})}};_.init(),e(".edd-ajax-user-search").keyup(function(){var t=e(this).val(),d="";e(this).data("exclude")&&(d=e(this).data("exclude")),e(".edd-ajax").show(),data={action:"edd_search_users",user_name:t,exclude:d},document.body.style.cursor="wait",e.ajax({type:"POST",data:data,dataType:"json",url:ajaxurl,success:function(t){e(".edd-ajax").hide(),e(".edd_user_search_results").removeClass("hidden"),e(".edd_user_search_results span").html(""),e(t.results).appendTo(".edd_user_search_results span"),document.body.style.cursor="default"}})}),e(document.body).on("click.eddSelectUser",".edd_user_search_results span a",function(t){t.preventDefault();var d=e(this).data("login");e(".edd-ajax-user-search").val(d),e(".edd_user_search_results").addClass("hidden"),e(".edd_user_search_results span").html("")}),e(document.body).on("click.eddCancelUserSearch",".edd_user_search_results a.edd-ajax-user-cancel",function(t){t.preventDefault(),e(".edd-ajax-user-search").val(""),e(".edd_user_search_results").addClass("hidden"),e(".edd_user_search_results span").html("")}),e.ajax({type:"GET",data:{action:"edd_load_dashboard_widget"},url:ajaxurl,success:function(t){e("#edd_dashboard_sales .inside").html(t)}}),e(document).on("keydown",".customer-note-input",function(t){13==t.keyCode&&(t.metaKey||t.ctrlKey)&&e("#add-customer-note").click()})});var eddFormatCurrency=function(e){var t=parseFloat(e),d=edd_vars.currency,n=edd_vars.currency_decimals;return t.toLocaleString(d,{style:"currency",currency:d,minimumFractionDigits:n,maximumFractionDigits:n})},eddFormatNumber=function(e){{var t=parseFloat(e),d=edd_vars.currency;edd_vars.currency_decimals}return t.toLocaleString(d,{style:"decimal",minimumFractionDigits:0,maximumFractionDigits:0})},eddLabelFormatter=function(e){return'<div style="font-size:12px; text-align:center; padding:2px">'+e+"</div>"},eddLegendFormatterSales=function(e,t){var d=e.toLowerCase().replace(/\s/g,"-"),n='<div class="edd-legend-color" style="background-color: '+t.color+'"></div>',a='<div class="edd-pie-legend-item">'+e+": "+Math.round(t.percent)+"% ("+eddFormatNumber(t.data[0][1])+")</div>",i='<div id="'+t.edd_vars.id+d+'" class="edd-legend-item-wrapper">'+n+a+"</div>";return jQuery("#edd-pie-legend-"+t.edd_vars.id).append(i),i},eddLegendFormatterEarnings=function(e,t){var d=e.toLowerCase().replace(/\s/g,"-"),n='<div class="edd-legend-color" style="background-color: '+t.color+'"></div>',a='<div class="edd-pie-legend-item">'+e+": "+Math.round(t.percent)+"% ("+eddFormatCurrency(t.data[0][1])+")</div>",i='<div id="'+t.edd_vars.id+d+'" class="edd-legend-item-wrapper">'+n+a+"</div>";return jQuery("#edd-pie-legend-"+t.edd_vars.id).append(i),i};
1
+ jQuery(document).ready(function(a){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");b&&(b=b.replace(/\[(\d+)\]/,"["+parseInt(c)+"]"),a(this).attr("name",b).attr("id",b))}),clone.find("span.edd_price_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(".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%")})},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 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("price"===e){var g=c.data("key");a('.edd_repeatable_condition_field option[value="'+g+'"]').remove()}if(d>1)a("input, select",c).val(""),c.fadeOut("fast").remove();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){a(".edd_pricing_fields,.edd_repeatable_table .pricing").toggle()})},files:function(){if("undefined"==typeof wp||"1"!==edd_vars.new_media_ui)a(".edd_upload_file_button").length>0&&(window.formfield="",a(document.body).on("click",".edd_upload_file_button",function(b){if(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),null!=edd_vars.post_id)var c="post_id="+edd_vars.post_id+"&";tb_show(edd_vars.add_new_download,"media-upload.php?"+c+"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 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")?!1:!0}),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 a=c.state().get("selection");a.each(function(a,c){if(a=a.toJSON(),0===c)window.formfield.find(".edd_repeatable_attachment_id_field").val(a.id),window.formfield.find(".edd_repeatable_upload_field").val(a.url),window.formfield.find(".edd_repeatable_name_field").val(a.title);else{var d=window.formfield,e=b.clone_repeatable(d);e.find(".edd_repeatable_attachment_id_field").val(a.id),e.find(".edd_repeatable_upload_field").val(a.url),a.title.length>0?e.find(".edd_repeatable_name_field").val(a.title):e.find(".edd_repeatable_name_field").val(a.filename),e.insertAfter(d)}})}),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.new_customer(),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");"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(),i=a('input[name="edd-payment-removed"]').val();i=a.parseJSON(i),i.length<1&&(i={});var j=[{id:e,price_id:f,quantity:g,amount:h}];i[c]=j,a('input[name="edd-payment-removed"]').val(JSON.stringify(i)),a(this).parent().parent().parent().remove(),a("#edd-payment-downloads-changed").val(1),a(".edd-order-payment-recalc-totals").show()}return!1})},new_customer:function(){a("#edd-customer-details").on("click",".edd-payment-new-customer, .edd-payment-new-customer-cancel",function(b){b.preventDefault(),a(".customer-info").toggle(),a(".new-customer").toggle();var c=a("#edd-new-customer");a(".new-customer").is(":visible")?c.val(1):c.val(0)})},add_download:function(){a("#edd-purchased-files").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-amount"),f=a(".edd_price_options_select option:selected"),g=c.val(),h=c.find(":selected").text(),i=d.val(),j=e.val(),k=f.val(),l=f.text();if(1>g)return!1;if(j||(j=0),j=parseFloat(j),isNaN(j))return alert(edd_vars.numeric_item_price),!1;if("1"===edd_vars.quantities_enabled){if(isNaN(parseInt(i)))return alert(edd_vars.numeric_quantity),!1;j*=i}j=j.toFixed(edd_vars.currency_decimals);var m=j+edd_vars.currency_sign;"before"===edd_vars.currency_pos&&(m=edd_vars.currency_sign+j),l&&(h=h+" - "+l);var n=a("#edd-purchased-files div.row").length,o=a("#edd-purchased-files div.row:last").clone();o.find(".download span").html('<a href="post.php?post='+g+'&action=edit"></a>'),o.find(".download span a").text(h),o.find(".price-text").text(m),o.find(".item-quantity").text(i),o.find(".item-price").text(edd_vars.currency_sign+(j/i).toFixed(edd_vars.currency_decimals)),o.find("input.edd-payment-details-download-id").val(g),o.find("input.edd-payment-details-download-price-id").val(k),o.find("input.edd-payment-details-download-amount").val(j),o.find("input.edd-payment-details-download-quantity").val(i),o.find("input.edd-payment-details-download-has-log").val(0),o.find("input").each(function(){var b=a(this).attr("name");b=b.replace(/\[(\d+)\]/,"["+parseInt(n)+"]"),a(this).attr("name",b).attr("id",b)}),a("#edd-payment-downloads-changed").val(1),a(o).insertAfter("#edd-purchased-files div.row:last"),a(".edd-order-payment-recalc-totals").show()})},recalculate_total:function(){a("#edd-order-recalc-total").on("click",function(b){b.preventDefault();var c=0,d=a("#edd-purchased-files .row .edd-payment-details-download-amount");d.length&&d.each(function(){c+=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)})},variable_prices_check:function(){a("#edd-purchased-files").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(){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(){a(".edd-amount-description").toggle()})},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},f=a(".edd_price_options_select");a.post(ajaxurl,e,function(a){f.remove(),b.after(a)})}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").on("click",function(){return confirm(edd_vars.delete_payment)?!0:!1}),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(".chosen-choices").on("click",function(){a(this).children("li").children("input").attr("placeholder",edd_vars.type_to_search)});var i,j=342;a(".edd-select.chosen-container .chosen-search input, .edd-select.chosen-container .search-field input").keyup(function(b){var c=a(this).val(),d=a(this).closest(".edd-select-chosen"),e=d.attr("id").replace("_chosen",""),g=(b.which,"edd_download_search");d.attr("id").indexOf("customer")>=0&&(g="edd_customer_search"),c.length<=3&&"edd_download_search"==g||16==b.which||13==b.which||91==b.which||17==b.which||37==b.which||38==b.which||39==b.which||40==b.which||(clearTimeout(i),i=setTimeout(function(){a.ajax({type:"GET",url:ajaxurl,data:{action:g,s:c,current_id:edd_vars.post_id},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()},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)})}};k.init();var l={init:function(){this.submit()},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){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="update error"><p>'+g+"</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)})}};l.init();var m={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.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(),m.vars.customer_card_wrap_editable.hide(),m.vars.customer_card_wrap_edit_item.fadeIn().css("display","block")})},user_search:function(){a(document.body).on("click.eddSelectUser",".edd_user_search_results a",function(b){b.preventDefault();var c=a(this).data("userid");m.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(),m.vars.customer_card_wrap_edit_item.hide(),m.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?m.vars.state_input.replaceWith('<input type="text" name="'+data.field_name+'" value="" class="edd-edit-toggles medium-text"/>'):m.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:m.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(),m.vars.note.val("")}}).fail(function(a){window.console&&window.console.log&&console.log(a)});else{var d=m.vars.note.css("border-color");m.vars.note.css("border-color","red"),setTimeout(function(){m.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))})}};m.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.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: Serve Digital Downloads Through WordPress
6
  * Author: Pippin Williamson
7
  * Author URI: https://pippinsplugins.com
8
- * Version: 2.4.5
9
  * Text Domain: edd
10
  * Domain Path: languages
11
  *
@@ -25,7 +25,7 @@
25
  * @package EDD
26
  * @category Core
27
  * @author Pippin Williamson
28
- * @version 2.4.5
29
  */
30
 
31
  // Exit if accessed directly
@@ -187,7 +187,7 @@ final class Easy_Digital_Downloads {
187
 
188
  // Plugin version
189
  if ( ! defined( 'EDD_VERSION' ) ) {
190
- define( 'EDD_VERSION', '2.4.5' );
191
  }
192
 
193
  // Plugin Folder Path
5
  * Description: Serve Digital Downloads Through WordPress
6
  * Author: Pippin Williamson
7
  * Author URI: https://pippinsplugins.com
8
+ * Version: 2.4.6
9
  * Text Domain: edd
10
  * Domain Path: languages
11
  *
25
  * @package EDD
26
  * @category Core
27
  * @author Pippin Williamson
28
+ * @version 2.4.6
29
  */
30
 
31
  // Exit if accessed directly
187
 
188
  // Plugin version
189
  if ( ! defined( 'EDD_VERSION' ) ) {
190
+ define( 'EDD_VERSION', '2.4.6' );
191
  }
192
 
193
  // Plugin Folder Path
includes/cart/actions.php CHANGED
@@ -66,6 +66,11 @@ add_action( 'template_redirect', 'edd_process_cart_endpoints', 100 );
66
  function edd_process_add_to_cart( $data ) {
67
  $download_id = absint( $data['download_id'] );
68
  $options = isset( $data['edd_options'] ) ? $data['edd_options'] : array();
 
 
 
 
 
69
  $cart = edd_add_to_cart( $download_id, $options );
70
 
71
  if ( edd_straight_to_checkout() && ! edd_is_checkout() ) {
66
  function edd_process_add_to_cart( $data ) {
67
  $download_id = absint( $data['download_id'] );
68
  $options = isset( $data['edd_options'] ) ? $data['edd_options'] : array();
69
+
70
+ if ( ! empty( $data['edd_download_quantity'] ) ) {
71
+ $options['quantity'] = absint( $data['edd_download_quantity'] );
72
+ }
73
+
74
  $cart = edd_add_to_cart( $download_id, $options );
75
 
76
  if ( edd_straight_to_checkout() && ! edd_is_checkout() ) {
includes/checkout/functions.php CHANGED
@@ -320,10 +320,15 @@ function edd_is_ssl_enforced() {
320
  * @return void
321
  */
322
  function edd_enforced_ssl_redirect_handler() {
 
323
  if ( ! edd_is_ssl_enforced() || ! edd_is_checkout() || is_admin() || is_ssl() ) {
324
  return;
325
  }
326
 
 
 
 
 
327
  $uri = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
328
 
329
  wp_safe_redirect( $uri );
320
  * @return void
321
  */
322
  function edd_enforced_ssl_redirect_handler() {
323
+
324
  if ( ! edd_is_ssl_enforced() || ! edd_is_checkout() || is_admin() || is_ssl() ) {
325
  return;
326
  }
327
 
328
+ if( edd_is_checkout() && false !== strpos( edd_get_current_page_url(), 'https://' ) ) {
329
+ return;
330
+ }
331
+
332
  $uri = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
333
 
334
  wp_safe_redirect( $uri );
includes/checkout/template.php CHANGED
@@ -908,6 +908,6 @@ add_filter( 'the_content', 'edd_filter_success_page_content', 99999 );
908
  * @param array $item Cart item array
909
  * @return boolean
910
  */
911
- function edd_receipt_show_download_files( $item_id, $receipt_args, $item ) {
912
  return apply_filters( 'edd_receipt_show_download_files', true, $item_id, $receipt_args, $item );
913
  }
908
  * @param array $item Cart item array
909
  * @return boolean
910
  */
911
+ function edd_receipt_show_download_files( $item_id, $receipt_args, $item = array() ) {
912
  return apply_filters( 'edd_receipt_show_download_files', true, $item_id, $receipt_args, $item );
913
  }
includes/payments/functions.php CHANGED
@@ -748,7 +748,7 @@ function edd_get_sales_by_date( $day = null, $month_num = null, $year = null, $h
748
  $args = apply_filters( 'edd_get_sales_by_date_args', $args );
749
 
750
  $key = md5( serialize( $args ) );
751
- $count = get_transient( $key, 'edd' );
752
 
753
  if( false === $count ) {
754
  $sales = new WP_Query( $args );
748
  $args = apply_filters( 'edd_get_sales_by_date_args', $args );
749
 
750
  $key = md5( serialize( $args ) );
751
+ $count = get_transient( $key );
752
 
753
  if( false === $count ) {
754
  $sales = new WP_Query( $args );
includes/user-functions.php CHANGED
@@ -469,9 +469,9 @@ function edd_new_user_notification( $user_id = 0, $user_data = array() ) {
469
  $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
470
  $message = sprintf( __( 'New user registration on your site %s:' ), $blogname ) . "\r\n\r\n";
471
  $message .= sprintf( __( 'Username: %s'), $user_data['user_login'] ) . "\r\n\r\n";
472
- $message .= sprintf( __( 'E-mail: %s'), $user_data['user_email'] ) . "\r\n";
473
 
474
- @wp_mail( get_option( 'admin_email' ), sprintf( __('[%s] New User Registration' ), $blogname ), $message );
475
 
476
  $message = sprintf( __( 'Username: %s' ), $user_data['user_login'] ) . "\r\n";
477
  $message .= sprintf( __( 'Password: %s' ), __( '[Password entered at checkout]', 'edd' ) ) . "\r\n";
@@ -570,7 +570,7 @@ function edd_get_user_verification_url( $user_id = 0 ) {
570
  'edd_action' => 'verify_user',
571
  'user_id' => $user_id,
572
  'ttl' => strtotime( '+24 hours' )
573
- ), untrailingslashit( get_permalink( edd_get_option( 'purchase_history_page', 0 ) ) ) );
574
 
575
  $token = edd_get_user_verification_token( $base_url );
576
  $url = add_query_arg( 'token', $token, $base_url );
@@ -788,7 +788,7 @@ function edd_process_user_verification_request() {
788
 
789
  $redirect = apply_filters(
790
  'edd_user_account_verification_request_redirect',
791
- add_query_arg( 'edd-verify-request', '1', get_permalink( edd_get_option( 'purchase_history_page', 0 ) ) )
792
  );
793
 
794
  wp_safe_redirect( $redirect );
@@ -820,7 +820,7 @@ function edd_process_user_account_verification() {
820
 
821
  $parts = parse_url( add_query_arg( array() ) );
822
  wp_parse_str( $parts['query'], $query_args );
823
- $url = add_query_arg( $query_args, untrailingslashit( get_permalink( edd_get_option( 'purchase_history_page', 0 ) ) ) );
824
 
825
  if( ! edd_validate_user_verification_token( $url ) ) {
826
 
@@ -835,11 +835,28 @@ function edd_process_user_account_verification() {
835
 
836
  $redirect = apply_filters(
837
  'edd_user_account_verified_redirect',
838
- add_query_arg( 'edd-verify-success', '1', get_permalink( edd_get_option( 'purchase_history_page', 0 ) ) )
839
  );
840
 
841
  wp_safe_redirect( $redirect );
842
  exit;
843
 
844
  }
845
- add_action( 'edd_verify_user', 'edd_process_user_account_verification' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
469
  $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
470
  $message = sprintf( __( 'New user registration on your site %s:' ), $blogname ) . "\r\n\r\n";
471
  $message .= sprintf( __( 'Username: %s'), $user_data['user_login'] ) . "\r\n\r\n";
472
+ $message .= sprintf( __( 'E-mail: %s'), $user_data['user_email'] ) . "\r\n";
473
 
474
+ @wp_mail( get_option( 'admin_email' ), sprintf( __('[%s] New User Registration' ), $blogname ), $message );
475
 
476
  $message = sprintf( __( 'Username: %s' ), $user_data['user_login'] ) . "\r\n";
477
  $message .= sprintf( __( 'Password: %s' ), __( '[Password entered at checkout]', 'edd' ) ) . "\r\n";
570
  'edd_action' => 'verify_user',
571
  'user_id' => $user_id,
572
  'ttl' => strtotime( '+24 hours' )
573
+ ), untrailingslashit( edd_get_user_verification_page() ) );
574
 
575
  $token = edd_get_user_verification_token( $base_url );
576
  $url = add_query_arg( 'token', $token, $base_url );
788
 
789
  $redirect = apply_filters(
790
  'edd_user_account_verification_request_redirect',
791
+ add_query_arg( 'edd-verify-request', '1', edd_get_user_verification_page() )
792
  );
793
 
794
  wp_safe_redirect( $redirect );
820
 
821
  $parts = parse_url( add_query_arg( array() ) );
822
  wp_parse_str( $parts['query'], $query_args );
823
+ $url = add_query_arg( $query_args, untrailingslashit( edd_get_user_verification_page() ) );
824
 
825
  if( ! edd_validate_user_verification_token( $url ) ) {
826
 
835
 
836
  $redirect = apply_filters(
837
  'edd_user_account_verified_redirect',
838
+ add_query_arg( 'edd-verify-success', '1', edd_get_user_verification_page() )
839
  );
840
 
841
  wp_safe_redirect( $redirect );
842
  exit;
843
 
844
  }
845
+ add_action( 'edd_verify_user', 'edd_process_user_account_verification' );
846
+
847
+ /**
848
+ * Retrieves the purchase history page, or main URL for the account verification process
849
+ *
850
+ * @since 2.4.6
851
+ * @return string The base URL to use for account verification
852
+ */
853
+ function edd_get_user_verification_page() {
854
+ $url = home_url();
855
+ $purchase_history = edd_get_option( 'purchase_history_page', 0 );
856
+
857
+ if ( ! empty( $purchase_history ) ) {
858
+ $url = get_permalink( $purchase_history );
859
+ }
860
+
861
+ return apply_filters( 'edd_user_verification_base_url', $url );
862
+ }
readme.txt CHANGED
@@ -7,7 +7,7 @@ Tags: download, downloads, e-store, eshop, digital downloads, e-downloads, ecomm
7
  Requires at least: 3.9.2
8
  Tested up to: 4.3
9
 
10
- Stable Tag: 2.4.5
11
 
12
  License: GNU Version 2 or Any Later Version
13
 
@@ -191,6 +191,15 @@ Yes, through the addition of one or more of the add-on payment gateways, you can
191
 
192
  == Changelog ==
193
 
 
 
 
 
 
 
 
 
 
194
  = 2.4.5, September 16, 2015 =
195
 
196
  * Fix: Bug with AJAX URL on checkout and mixed-content error messages for sites that use HTTPS on checkout but not in /wp-admin/
7
  Requires at least: 3.9.2
8
  Tested up to: 4.3
9
 
10
+ Stable Tag: 2.4.6
11
 
12
  License: GNU Version 2 or Any Later Version
13
 
191
 
192
  == Changelog ==
193
 
194
+ = 2.4.6, September 18, 2015 =
195
+
196
+ * Fix: Bug in user verification process causing redirect loop when Purchase History page is not set
197
+ * Fix: Warning: Missing argument 3 for edd_receipt_show_download_files()
198
+ * Fix: Quick Edits on Downloads not always expanding the form
199
+ * Fix: Occasional redirect loop caused by edd_enforced_ssl_redirect_handler()
200
+ * Fix: Item quantity not properly added to cart when AJAX is disabled
201
+ * Tweak: Fix extra parameter being provided in get sales by date
202
+
203
  = 2.4.5, September 16, 2015 =
204
 
205
  * Fix: Bug with AJAX URL on checkout and mixed-content error messages for sites that use HTTPS on checkout but not in /wp-admin/