Version Description
Download this release
Release Info
Developer | mordauk |
Plugin | Easy Digital Downloads |
Version | 2.5.8 |
Comparing to | |
See all releases |
Code changes from version 2.5.7 to 2.5.8
- assets/js/admin-scripts.js +8 -8
- assets/js/admin-scripts.min.js +1 -1
- assets/js/edd-checkout-global.js +4 -2
- assets/js/edd-checkout-global.min.js +1 -1
- easy-digital-downloads.php +13 -13
- includes/admin/payments/view-order-details.php +1 -0
- includes/admin/settings/register-settings.php +107 -107
- includes/ajax-functions.php +2 -2
- includes/cart/actions.php +1 -1
- includes/cart/functions.php +3 -3
- includes/class-edd-download.php +10 -0
- includes/class-edd-html-elements.php +7 -7
- includes/download-functions.php +9 -1
- includes/formatting.php +23 -0
- includes/payments/class-edd-payment.php +3 -3
- includes/process-download.php +3 -2
- includes/scripts.php +2 -0
- includes/shortcodes.php +2 -2
- includes/user-functions.php +3 -1
- languages/README.md +4 -4
- readme.txt +19 -1
- templates/checkout_cart.php +1 -1
- templates/shortcode-receipt.php +1 -1
assets/js/admin-scripts.js
CHANGED
@@ -1149,14 +1149,14 @@ jQuery(document).ready(function ($) {
|
|
1149 |
if(
|
1150 |
( val.length <= 3 && 'edd_download_search' == search_type ) ||
|
1151 |
(
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
)
|
1161 |
) {
|
1162 |
return;
|
1149 |
if(
|
1150 |
( val.length <= 3 && 'edd_download_search' == search_type ) ||
|
1151 |
(
|
1152 |
+
lastKey == 16 ||
|
1153 |
+
lastKey == 13 ||
|
1154 |
+
lastKey == 91 ||
|
1155 |
+
lastKey == 17 ||
|
1156 |
+
lastKey == 37 ||
|
1157 |
+
lastKey == 38 ||
|
1158 |
+
lastKey == 39 ||
|
1159 |
+
lastKey == 40
|
1160 |
)
|
1161 |
) {
|
1162 |
return;
|
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"),n=e(this).attr("id");t&&(t=t.replace(/\[(\d+)\]/,"["+parseInt(d)+"]"),e(this).attr("name",t)),"undefined"!=typeof n&&(n=n.replace(/(\d+)/,parseInt(d)),e(this).attr("id",n))}),clone.find("span.edd_price_id").each(function(){e(this).text(parseInt(d))}),clone.find("span.edd_file_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(t){var d=e("#edd_products"),n=e("#edd_download_files"),a=e("#edd_download_limit_wrap");"bundle"===e(this).val()?(d.show(),n.hide(),a.hide()):(d.hide(),n.show(),a.show())})},prices:function(){e(document.body).on("change","#edd_variable_pricing",function(t){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),e.title.length>0?a.find(".edd_repeatable_name_field").val(e.title):a.find(".edd_repeatable_name_field").val(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");"nostates"==t?d.replaceWith('<input type="text" name="edd-payment-address[0][state]" value="" class="edd-edit-toggles medium-text"/>'):d.replaceWith(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");e(".new-customer").is(":visible")?d.val(1):d.val(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;var p=c;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 f=e("#edd-purchased-files div.row").length,m=e("#edd-purchased-files div.row:last").clone();m.find(".download span").html('<a href="post.php?post='+o+'&action=edit"></a>'),m.find(".download span a").text(r),m.find(".price-text").text(_),m.find(".item-quantity").text(s),m.find(".item-price").text(edd_vars.currency_sign+(c/s).toFixed(edd_vars.currency_decimals)),m.find("input.edd-payment-details-download-id").val(o),m.find("input.edd-payment-details-download-price-id").val(l),m.find("input.edd-payment-details-download-item-price").val(p),m.find("input.edd-payment-details-download-amount").val(c),m.find("input.edd-payment-details-download-quantity").val(s),m.find("input.edd-payment-details-download-has-log").val(0),m.find("input").each(function(){var t=e(this).attr("name");t=t.replace(/\[(\d+)\]/,"["+parseInt(f)+"]"),e(this).attr("name",t).attr("id",t)}),e("#edd-payment-downloads-changed").val(1),e(m).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.toFixed(edd_vars.currency_decimals))})},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(t){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(e){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,all_prices:!0},i=e(".edd_price_options_select");e.post(ajaxurl,a,function(t){i.remove(),e("#edd_customer_export_download_chosen").after(t)})}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,t){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(){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(document.body).on("keyup",".edd-select.chosen-container .chosen-search input, .edd-select.chosen-container .search-field input",function(t){var d=e(this).val(),n=e(this).closest(".edd-select-chosen"),a=n.attr("id").replace("_chosen",""),i=n.hasClass("no-bundles"),o=(t.which,"edd_download_search");n.prev().data("search-type")&&(o="edd_"+n.prev().data("search-type")+"_search"),d.length<=3&&"edd_download_search"==o||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:o,s:d,current_id:edd_vars.post_id,no_bundles:i},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(e){})},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(),this.create_api_key(),this.recount_stats()},revoke_api_key:function(){e(document.body).on("click",".edd-revoke-api-key",function(e){return confirm(edd_vars.revoke_api_key)})},regenerate_api_key:function(){e(document.body).on("click",".edd-regenerate-api-key",function(e){return confirm(edd_vars.regenerate_api_key)})},create_api_key:function(){e(document.body).on("submit","#api-key-generate-form",function(t){var d=e('input[type="text"][name="user_id"]');d.css("border-color","#ddd");var n=d.val();return n.length<1||0==n?(d.css("border-color","#ff0000"),!1):void 0})},recount_stats:function(){e("body").on("change","#recount-stats-type",function(){var t=e("#edd-tools-recount-form"),d=e("option:selected",this).data("type"),n=e("#recount-stats-submit"),a=e("#tools-product-dropdown");if(t.find(".notice-wrap").remove(),n.removeClass("button-disabled").attr("disabled",!1),a.hide(),e(".edd-recount-stats-descriptions span").hide(),"recount-download"===d)a.show(),a.find(".edd-select-chosen").css("width","auto");else if("reset-stats"===d){t.append('<div class="notice-wrap"></div>');var i=t.find(".notice-wrap");i.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>"),e("#recount-stats-submit").addClass("button-disabled").attr("disabled","disabled")}else a.hide(),a.val(0);e("#"+d).show()}),e("body").on("change","#confirm-reset",function(){var t=e(this).is(":checked");t?e("#recount-stats-submit").removeClass("button-disabled").removeAttr("disabled"):e("#recount-stats-submit").addClass("button-disabled").attr("disabled","disabled")}),e("#edd-tools-recount-form").submit(function(t){var d=e("#recount-stats-type").val(),n=e(this),a=e("option:selected",this).data("type");if("reset-stats"===a){var i=e("#confirm-reset").is(":checked");if(i)return!0;r=!0}n.find(".notice-wrap").remove(),n.append('<div class="notice-wrap"></div>');var o=n.find(".notice-wrap"),r=!1;if((null===d||0===d)&&(o.html('<div class="updated error"><p>'+edd_vars.batch_export_no_class+"</p></div>"),r=!0),"recount-download"===a){var s=e('select[name="download_id"]').val();0==s&&(o.html('<div class="updated error"><p>'+edd_vars.batch_export_no_reqs+"</p></div>"),r=!0)}return r?(n.find(".button-disabled").removeClass("button-disabled"),!1):void 0})}};l.init();var u={init:function(){this.submit(),this.dismiss_message()},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||t.success){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="updated error"><p>'+o+"</p></div>")}else if(t.success){var r=t.message;i.html('<div id="edd-batch-success" class="updated notice is-dismissible"><p>'+r+'<span class="notice-dismiss"></span></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)})},dismiss_message:function(){e("body").on("click","#edd-batch-success .notice-dismiss",function(){e("#edd-batch-success").parent().slideUp("fast")})}};u.init();var p={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(),p.vars.customer_card_wrap_editable.hide(),p.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");p.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(e){window.location.href=window.location.href},"json")})},cancel_edit:function(){e(document.body).on("click","#edd-edit-customer-cancel",function(t){t.preventDefault(),p.vars.customer_card_wrap_edit_item.hide(),p.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){"nostates"==e?p.vars.state_input.replaceWith('<input type="text" name="'+data.field_name+'" value="" class="edd-edit-toggles medium-text"/>'):p.vars.state_input.replaceWith(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:p.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(),p.vars.note.val("")}}).fail(function(e){window.console&&window.console.log&&console.log(e)});else{var n=p.vars.note.css("border-color");p.vars.note.css("border-color","red"),setTimeout(function(){p.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))})}};p.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("#edd_dashboard_sales").length&&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,t){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(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"),n=e(this).attr("id");t&&(t=t.replace(/\[(\d+)\]/,"["+parseInt(d)+"]"),e(this).attr("name",t)),"undefined"!=typeof n&&(n=n.replace(/(\d+)/,parseInt(d)),e(this).attr("id",n))}),clone.find("span.edd_price_id").each(function(){e(this).text(parseInt(d))}),clone.find("span.edd_file_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(t){var d=e("#edd_products"),n=e("#edd_download_files"),a=e("#edd_download_limit_wrap");"bundle"===e(this).val()?(d.show(),n.hide(),a.hide()):(d.hide(),n.show(),a.show())})},prices:function(){e(document.body).on("change","#edd_variable_pricing",function(t){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),e.title.length>0?a.find(".edd_repeatable_name_field").val(e.title):a.find(".edd_repeatable_name_field").val(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");"nostates"==t?d.replaceWith('<input type="text" name="edd-payment-address[0][state]" value="" class="edd-edit-toggles medium-text"/>'):d.replaceWith(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");e(".new-customer").is(":visible")?d.val(1):d.val(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;var p=c;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 f=e("#edd-purchased-files div.row").length,m=e("#edd-purchased-files div.row:last").clone();m.find(".download span").html('<a href="post.php?post='+o+'&action=edit"></a>'),m.find(".download span a").text(r),m.find(".price-text").text(_),m.find(".item-quantity").text(s),m.find(".item-price").text(edd_vars.currency_sign+(c/s).toFixed(edd_vars.currency_decimals)),m.find("input.edd-payment-details-download-id").val(o),m.find("input.edd-payment-details-download-price-id").val(l),m.find("input.edd-payment-details-download-item-price").val(p),m.find("input.edd-payment-details-download-amount").val(c),m.find("input.edd-payment-details-download-quantity").val(s),m.find("input.edd-payment-details-download-has-log").val(0),m.find("input").each(function(){var t=e(this).attr("name");t=t.replace(/\[(\d+)\]/,"["+parseInt(f)+"]"),e(this).attr("name",t).attr("id",t)}),e("#edd-payment-downloads-changed").val(1),e(m).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.toFixed(edd_vars.currency_decimals))})},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(t){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(e){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,all_prices:!0},i=e(".edd_price_options_select");e.post(ajaxurl,a,function(t){i.remove(),e("#edd_customer_export_download_chosen").after(t)})}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,t){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(){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(document.body).on("keyup",".edd-select.chosen-container .chosen-search input, .edd-select.chosen-container .search-field input",function(t){var d=e(this).val(),n=e(this).closest(".edd-select-chosen"),a=n.attr("id").replace("_chosen",""),i=n.hasClass("no-bundles"),o=t.which,r="edd_download_search";n.prev().data("search-type")&&(r="edd_"+n.prev().data("search-type")+"_search"),d.length<=3&&"edd_download_search"==r||16==o||13==o||91==o||17==o||37==o||38==o||39==o||40==o||(clearTimeout(s),s=setTimeout(function(){e.ajax({type:"GET",url:ajaxurl,data:{action:r,s:d,current_id:edd_vars.post_id,no_bundles:i},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(e){})},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(),this.create_api_key(),this.recount_stats()},revoke_api_key:function(){e(document.body).on("click",".edd-revoke-api-key",function(e){return confirm(edd_vars.revoke_api_key)})},regenerate_api_key:function(){e(document.body).on("click",".edd-regenerate-api-key",function(e){return confirm(edd_vars.regenerate_api_key)})},create_api_key:function(){e(document.body).on("submit","#api-key-generate-form",function(t){var d=e('input[type="text"][name="user_id"]');d.css("border-color","#ddd");var n=d.val();return n.length<1||0==n?(d.css("border-color","#ff0000"),!1):void 0})},recount_stats:function(){e("body").on("change","#recount-stats-type",function(){var t=e("#edd-tools-recount-form"),d=e("option:selected",this).data("type"),n=e("#recount-stats-submit"),a=e("#tools-product-dropdown");if(t.find(".notice-wrap").remove(),n.removeClass("button-disabled").attr("disabled",!1),a.hide(),e(".edd-recount-stats-descriptions span").hide(),"recount-download"===d)a.show(),a.find(".edd-select-chosen").css("width","auto");else if("reset-stats"===d){t.append('<div class="notice-wrap"></div>');var i=t.find(".notice-wrap");i.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>"),e("#recount-stats-submit").addClass("button-disabled").attr("disabled","disabled")}else a.hide(),a.val(0);e("#"+d).show()}),e("body").on("change","#confirm-reset",function(){var t=e(this).is(":checked");t?e("#recount-stats-submit").removeClass("button-disabled").removeAttr("disabled"):e("#recount-stats-submit").addClass("button-disabled").attr("disabled","disabled")}),e("#edd-tools-recount-form").submit(function(t){var d=e("#recount-stats-type").val(),n=e(this),a=e("option:selected",this).data("type");if("reset-stats"===a){var i=e("#confirm-reset").is(":checked");if(i)return!0;r=!0}n.find(".notice-wrap").remove(),n.append('<div class="notice-wrap"></div>');var o=n.find(".notice-wrap"),r=!1;if((null===d||0===d)&&(o.html('<div class="updated error"><p>'+edd_vars.batch_export_no_class+"</p></div>"),r=!0),"recount-download"===a){var s=e('select[name="download_id"]').val();0==s&&(o.html('<div class="updated error"><p>'+edd_vars.batch_export_no_reqs+"</p></div>"),r=!0)}return r?(n.find(".button-disabled").removeClass("button-disabled"),!1):void 0})}};l.init();var u={init:function(){this.submit(),this.dismiss_message()},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||t.success){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="updated error"><p>'+o+"</p></div>")}else if(t.success){var r=t.message;i.html('<div id="edd-batch-success" class="updated notice is-dismissible"><p>'+r+'<span class="notice-dismiss"></span></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)})},dismiss_message:function(){e("body").on("click","#edd-batch-success .notice-dismiss",function(){e("#edd-batch-success").parent().slideUp("fast")})}};u.init();var p={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(),p.vars.customer_card_wrap_editable.hide(),p.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");p.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(e){window.location.href=window.location.href},"json")})},cancel_edit:function(){e(document.body).on("click","#edd-edit-customer-cancel",function(t){t.preventDefault(),p.vars.customer_card_wrap_edit_item.hide(),p.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){"nostates"==e?p.vars.state_input.replaceWith('<input type="text" name="'+data.field_name+'" value="" class="edd-edit-toggles medium-text"/>'):p.vars.state_input.replaceWith(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:p.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(),p.vars.note.val("")}}).fail(function(e){window.console&&window.console.log&&console.log(e)});else{var n=p.vars.note.css("border-color");p.vars.note.css("border-color","red"),setTimeout(function(){p.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))})}};p.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("#edd_dashboard_sales").length&&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,t){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};
|
assets/js/edd-checkout-global.js
CHANGED
@@ -279,8 +279,10 @@ window.EDD_Checkout = (function($) {
|
|
279 |
},
|
280 |
success: function (discount_response) {
|
281 |
|
|
|
|
|
282 |
$('.edd_cart_amount').each(function() {
|
283 |
-
if( edd_global_vars.currency_sign +
|
284 |
// We're removing a 100% discount code so we need to force the payment gateway to reload
|
285 |
window.location.reload();
|
286 |
}
|
@@ -369,4 +371,4 @@ window.EDD_Checkout = (function($) {
|
|
369 |
})(window.jQuery);
|
370 |
|
371 |
// init on document.ready
|
372 |
-
window.jQuery(document).ready(EDD_Checkout.init);
|
279 |
},
|
280 |
success: function (discount_response) {
|
281 |
|
282 |
+
var zero = '0' + edd_global_vars.decimal_separator + '00';
|
283 |
+
|
284 |
$('.edd_cart_amount').each(function() {
|
285 |
+
if( edd_global_vars.currency_sign + zero == $(this).text() || zero + edd_global_vars.currency_sign == $(this).text() ) {
|
286 |
// We're removing a 100% discount code so we need to force the payment gateway to reload
|
287 |
window.location.reload();
|
288 |
}
|
371 |
})(window.jQuery);
|
372 |
|
373 |
// init on document.ready
|
374 |
+
window.jQuery(document).ready(EDD_Checkout.init);
|
assets/js/edd-checkout-global.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
window.EDD_Checkout=function(e){"use strict";function d(){s=e(document.body),r=e("#edd_purchase_form"),l=e(".edd_cart_amount"),_=l.text(),u=e("#edd_checkout_form_wrap"),s.on("change","#edd_cc_address input.card_state, #edd_cc_address select",t),s.on("keyup change",".edd-do-validate .card-number",function(){o(e(this))}),s.on("submit","#edd_payment_mode",function(){var d=e("#edd-gateway option:selected").val();return 0==d?(alert(edd_global_vars.no_gateway),!1):void 0}),s.on("click","#edd_payment_mode_select input",function(){e("#edd_payment_mode_select label.edd-gateway-option-selected").removeClass("edd-gateway-option-selected"),e("#edd_payment_mode_select input:checked").parent().addClass("edd-gateway-option-selected")}),u.on("click",".edd-apply-discount",n),u.on("keypress","#edd-discount",function(e){return"13"==e.keyCode?!1:void 0}),u.on("keyup","#edd-discount",function(e){"13"==e.keyCode&&u.find(".edd-apply-discount").trigger("click")}),s.on("click",".edd_discount_remove",i),s.on("click",".edd_discount_link",function(d){d.preventDefault(),e(".edd_discount_link").parent().hide(),e("#edd-discount-code-wrap").show().find("#edd-discount").focus()}),s.find("#edd-discount-code-wrap").hide(),s.find("#edd_show_discount").show(),s.on("change",".edd-item-quantity",c),s.on("click",".edd-amazon-logout #Logout",function(e){e.preventDefault(),amazon.Login.logout(),window.location=edd_amazon.checkoutUri})}function t(){var d=e(this);if("card_state"!=d.attr("id")){var t={action:"edd_get_shop_states",country:d.val(),field_name:"card_state"};e.ajax({type:"POST",data:t,url:edd_global_vars.ajaxurl,xhrFields:{withCredentials:!0},success:function(e){if("nostates"==e){var d='<input type="text" name="card_state" class="cart-state edd-input required" value=""/>';r.find('input[name="card_state"], select[name="card_state"]').replaceWith(d)}else r.find('input[name="card_state"], select[name="card_state"]').replaceWith(e);s.trigger("edd_cart_billing_address_updated",[e])}}).fail(function(e){window.console&&window.console.log&&console.log(e)}).done(function(e){a()})}else a();return!1}function a(d){if("1"==edd_global_vars.taxes_enabled){var t=e("#edd_cc_address");d||(d=t.find("#card_state").val());var a={action:"edd_recalculate_taxes",billing_country:t.find("#billing_country").val(),state:d};e.ajax({type:"POST",data:a,dataType:"json",url:edd_global_vars.ajaxurl,xhrFields:{withCredentials:!0},success:function(d){e("#edd_checkout_cart_form").replaceWith(d.html),e(".edd_cart_amount").html(d.total);var t=new Object;t.postdata=a,t.response=d,s.trigger("edd_taxes_recalculated",[t])}}).fail(function(e){window.console&&window.console.log&&(console.log(e),s.trigger("edd_taxes_recalculated",[tax_data]))})}}function o(d){var t=d;t.validateCreditCard(function(d){var a=e(".card-type");null==d.card_type?(a.removeClass().addClass("off card-type"),t.removeClass("valid"),t.addClass("error")):(a.removeClass("off"),a.addClass(d.card_type.name),d.length_valid&&d.luhn_valid?(t.addClass("valid"),t.removeClass("error")):(t.removeClass("valid"),t.addClass("error")))})}function n(d){d.preventDefault();var t=(e(this),e("#edd-discount").val()),o=e("#edd-discount-loader");if(""==t||t==edd_global_vars.enter_discount)return!1;var n={action:"edd_apply_discount",code:t,form:e("#edd_purchase_form").serialize()};return e("#edd-discount-error-wrap").html("").hide(),o.show(),e.ajax({type:"POST",data:n,dataType:"json",url:edd_global_vars.ajaxurl,xhrFields:{withCredentials:!0},success:function(d){d?"valid"==d.msg?(e(".edd_cart_discount").html(d.html),e(".edd_cart_discount_row").show(),e(".edd_cart_amount").each(function(){e(this).text(d.total)}),e("#edd-discount",u).val(""),a(),"0.00"==d.total_plain?(e("#edd_cc_fields,#edd_cc_address,#edd_payment_mode_select").slideUp(),e('input[name="edd-gateway"]').val("manual")):e("#edd_cc_fields,#edd_cc_address").slideDown(),s.trigger("edd_discount_applied",[d])):(e("#edd-discount-error-wrap").html('<span class="edd_error">'+d.msg+"</span>"),e("#edd-discount-error-wrap").show(),s.trigger("edd_discount_invalid",[d])):(window.console&&window.console.log&&console.log(d),s.trigger("edd_discount_failed",[d])),o.hide()}}).fail(function(e){window.console&&window.console.log&&console.log(e)}),!1}function i(d){var t=e(this),o={action:"edd_remove_discount",code:t.data("code")};return e.ajax({type:"POST",data:o,dataType:"json",url:edd_global_vars.ajaxurl,xhrFields:{withCredentials:!0},success:function(d){e(".edd_cart_amount").each(function(){(edd_global_vars.currency_sign+
|
1 |
+
window.EDD_Checkout=function(e){"use strict";function d(){s=e(document.body),r=e("#edd_purchase_form"),l=e(".edd_cart_amount"),_=l.text(),u=e("#edd_checkout_form_wrap"),s.on("change","#edd_cc_address input.card_state, #edd_cc_address select",t),s.on("keyup change",".edd-do-validate .card-number",function(){o(e(this))}),s.on("submit","#edd_payment_mode",function(){var d=e("#edd-gateway option:selected").val();return 0==d?(alert(edd_global_vars.no_gateway),!1):void 0}),s.on("click","#edd_payment_mode_select input",function(){e("#edd_payment_mode_select label.edd-gateway-option-selected").removeClass("edd-gateway-option-selected"),e("#edd_payment_mode_select input:checked").parent().addClass("edd-gateway-option-selected")}),u.on("click",".edd-apply-discount",n),u.on("keypress","#edd-discount",function(e){return"13"==e.keyCode?!1:void 0}),u.on("keyup","#edd-discount",function(e){"13"==e.keyCode&&u.find(".edd-apply-discount").trigger("click")}),s.on("click",".edd_discount_remove",i),s.on("click",".edd_discount_link",function(d){d.preventDefault(),e(".edd_discount_link").parent().hide(),e("#edd-discount-code-wrap").show().find("#edd-discount").focus()}),s.find("#edd-discount-code-wrap").hide(),s.find("#edd_show_discount").show(),s.on("change",".edd-item-quantity",c),s.on("click",".edd-amazon-logout #Logout",function(e){e.preventDefault(),amazon.Login.logout(),window.location=edd_amazon.checkoutUri})}function t(){var d=e(this);if("card_state"!=d.attr("id")){var t={action:"edd_get_shop_states",country:d.val(),field_name:"card_state"};e.ajax({type:"POST",data:t,url:edd_global_vars.ajaxurl,xhrFields:{withCredentials:!0},success:function(e){if("nostates"==e){var d='<input type="text" name="card_state" class="cart-state edd-input required" value=""/>';r.find('input[name="card_state"], select[name="card_state"]').replaceWith(d)}else r.find('input[name="card_state"], select[name="card_state"]').replaceWith(e);s.trigger("edd_cart_billing_address_updated",[e])}}).fail(function(e){window.console&&window.console.log&&console.log(e)}).done(function(e){a()})}else a();return!1}function a(d){if("1"==edd_global_vars.taxes_enabled){var t=e("#edd_cc_address");d||(d=t.find("#card_state").val());var a={action:"edd_recalculate_taxes",billing_country:t.find("#billing_country").val(),state:d};e.ajax({type:"POST",data:a,dataType:"json",url:edd_global_vars.ajaxurl,xhrFields:{withCredentials:!0},success:function(d){e("#edd_checkout_cart_form").replaceWith(d.html),e(".edd_cart_amount").html(d.total);var t=new Object;t.postdata=a,t.response=d,s.trigger("edd_taxes_recalculated",[t])}}).fail(function(e){window.console&&window.console.log&&(console.log(e),s.trigger("edd_taxes_recalculated",[tax_data]))})}}function o(d){var t=d;t.validateCreditCard(function(d){var a=e(".card-type");null==d.card_type?(a.removeClass().addClass("off card-type"),t.removeClass("valid"),t.addClass("error")):(a.removeClass("off"),a.addClass(d.card_type.name),d.length_valid&&d.luhn_valid?(t.addClass("valid"),t.removeClass("error")):(t.removeClass("valid"),t.addClass("error")))})}function n(d){d.preventDefault();var t=(e(this),e("#edd-discount").val()),o=e("#edd-discount-loader");if(""==t||t==edd_global_vars.enter_discount)return!1;var n={action:"edd_apply_discount",code:t,form:e("#edd_purchase_form").serialize()};return e("#edd-discount-error-wrap").html("").hide(),o.show(),e.ajax({type:"POST",data:n,dataType:"json",url:edd_global_vars.ajaxurl,xhrFields:{withCredentials:!0},success:function(d){d?"valid"==d.msg?(e(".edd_cart_discount").html(d.html),e(".edd_cart_discount_row").show(),e(".edd_cart_amount").each(function(){e(this).text(d.total)}),e("#edd-discount",u).val(""),a(),"0.00"==d.total_plain?(e("#edd_cc_fields,#edd_cc_address,#edd_payment_mode_select").slideUp(),e('input[name="edd-gateway"]').val("manual")):e("#edd_cc_fields,#edd_cc_address").slideDown(),s.trigger("edd_discount_applied",[d])):(e("#edd-discount-error-wrap").html('<span class="edd_error">'+d.msg+"</span>"),e("#edd-discount-error-wrap").show(),s.trigger("edd_discount_invalid",[d])):(window.console&&window.console.log&&console.log(d),s.trigger("edd_discount_failed",[d])),o.hide()}}).fail(function(e){window.console&&window.console.log&&console.log(e)}),!1}function i(d){var t=e(this),o={action:"edd_remove_discount",code:t.data("code")};return e.ajax({type:"POST",data:o,dataType:"json",url:edd_global_vars.ajaxurl,xhrFields:{withCredentials:!0},success:function(d){var t="0"+edd_global_vars.decimal_separator+"00";e(".edd_cart_amount").each(function(){(edd_global_vars.currency_sign+t==e(this).text()||t+edd_global_vars.currency_sign==e(this).text())&&window.location.reload(),e(this).text(d.total)}),e(".edd_cart_discount").html(d.html),d.discounts||e(".edd_cart_discount_row").hide(),a(),e("#edd_cc_fields,#edd_cc_address").slideDown(),s.trigger("edd_discount_removed",[d])}}).fail(function(e){window.console&&window.console.log&&console.log(e)}),!1}function c(d){var t=e(this),a=t.val(),o=t.data("key"),n=t.closest(".edd_cart_item").data("download-id"),i=t.parent().find('input[name="edd-cart-download-'+o+'-options"]').val(),c={action:"edd_update_quantity",quantity:a,download_id:n,options:i};return e.ajax({type:"POST",data:c,dataType:"json",url:edd_global_vars.ajaxurl,xhrFields:{withCredentials:!0},success:function(d){e(".edd_cart_subtotal_amount").each(function(){e(this).text(d.subtotal)}),e(".edd_cart_tax_amount").each(function(){e(this).text(d.taxes)}),e(".edd_cart_amount").each(function(){e(this).text(d.total),s.trigger("edd_quantity_updated",[d])})}}).fail(function(e){window.console&&window.console.log&&console.log(e)}),!1}var s,r,l,_,u;return{init:d,recalculate_taxes:a}}(window.jQuery),window.jQuery(document).ready(EDD_Checkout.init);
|
easy-digital-downloads.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
* Description: Serve Digital Downloads Through WordPress.
|
6 |
* Author: Pippin Williamson and Company
|
7 |
* Author URI: https://easydigitaldownloads.com
|
8 |
-
* Version: 2.5.
|
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.5.
|
29 |
*/
|
30 |
|
31 |
// Exit if accessed directly.
|
@@ -50,7 +50,7 @@ final class Easy_Digital_Downloads {
|
|
50 |
/**
|
51 |
* EDD Roles Object.
|
52 |
*
|
53 |
-
* @var object
|
54 |
* @since 1.5
|
55 |
*/
|
56 |
public $roles;
|
@@ -58,7 +58,7 @@ final class Easy_Digital_Downloads {
|
|
58 |
/**
|
59 |
* EDD Cart Fees Object.
|
60 |
*
|
61 |
-
* @var object
|
62 |
* @since 1.5
|
63 |
*/
|
64 |
public $fees;
|
@@ -66,7 +66,7 @@ final class Easy_Digital_Downloads {
|
|
66 |
/**
|
67 |
* EDD API Object.
|
68 |
*
|
69 |
-
* @var object
|
70 |
* @since 1.5
|
71 |
*/
|
72 |
public $api;
|
@@ -76,7 +76,7 @@ final class Easy_Digital_Downloads {
|
|
76 |
*
|
77 |
* This holds cart items, purchase sessions, and anything else stored in the session.
|
78 |
*
|
79 |
-
* @var object
|
80 |
* @since 1.5
|
81 |
*/
|
82 |
public $session;
|
@@ -84,7 +84,7 @@ final class Easy_Digital_Downloads {
|
|
84 |
/**
|
85 |
* EDD HTML Element Helper Object.
|
86 |
*
|
87 |
-
* @var object
|
88 |
* @since 1.5
|
89 |
*/
|
90 |
public $html;
|
@@ -92,7 +92,7 @@ final class Easy_Digital_Downloads {
|
|
92 |
/**
|
93 |
* EDD Emails Object.
|
94 |
*
|
95 |
-
* @var object
|
96 |
* @since 2.1
|
97 |
*/
|
98 |
public $emails;
|
@@ -100,7 +100,7 @@ final class Easy_Digital_Downloads {
|
|
100 |
/**
|
101 |
* EDD Email Template Tags Object.
|
102 |
*
|
103 |
-
* @var object
|
104 |
* @since 1.9
|
105 |
*/
|
106 |
public $email_tags;
|
@@ -108,7 +108,7 @@ final class Easy_Digital_Downloads {
|
|
108 |
/**
|
109 |
* EDD Customers DB Object.
|
110 |
*
|
111 |
-
* @var object
|
112 |
* @since 2.1
|
113 |
*/
|
114 |
public $customers;
|
@@ -126,7 +126,7 @@ final class Easy_Digital_Downloads {
|
|
126 |
* @uses Easy_Digital_Downloads::includes() Include the required files.
|
127 |
* @uses Easy_Digital_Downloads::load_textdomain() load the language files.
|
128 |
* @see EDD()
|
129 |
-
* @return The one true Easy_Digital_Downloads
|
130 |
*/
|
131 |
public static function instance() {
|
132 |
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Easy_Digital_Downloads ) ) {
|
@@ -186,7 +186,7 @@ final class Easy_Digital_Downloads {
|
|
186 |
|
187 |
// Plugin version.
|
188 |
if ( ! defined( 'EDD_VERSION' ) ) {
|
189 |
-
define( 'EDD_VERSION', '2.5.
|
190 |
}
|
191 |
|
192 |
// Plugin Folder Path.
|
@@ -431,7 +431,7 @@ endif; // End if class_exists check.
|
|
431 |
* Example: <?php $edd = EDD(); ?>
|
432 |
*
|
433 |
* @since 1.4
|
434 |
-
|
435 |
*/
|
436 |
function EDD() {
|
437 |
return Easy_Digital_Downloads::instance();
|
5 |
* Description: Serve Digital Downloads Through WordPress.
|
6 |
* Author: Pippin Williamson and Company
|
7 |
* Author URI: https://easydigitaldownloads.com
|
8 |
+
* Version: 2.5.8
|
9 |
* Text Domain: easy-digital-downloads
|
10 |
* Domain Path: languages
|
11 |
*
|
25 |
* @package EDD
|
26 |
* @category Core
|
27 |
* @author Pippin Williamson
|
28 |
+
* @version 2.5.8
|
29 |
*/
|
30 |
|
31 |
// Exit if accessed directly.
|
50 |
/**
|
51 |
* EDD Roles Object.
|
52 |
*
|
53 |
+
* @var object|EDD_Roles
|
54 |
* @since 1.5
|
55 |
*/
|
56 |
public $roles;
|
58 |
/**
|
59 |
* EDD Cart Fees Object.
|
60 |
*
|
61 |
+
* @var object|EDD_Fees
|
62 |
* @since 1.5
|
63 |
*/
|
64 |
public $fees;
|
66 |
/**
|
67 |
* EDD API Object.
|
68 |
*
|
69 |
+
* @var object|EDD_API
|
70 |
* @since 1.5
|
71 |
*/
|
72 |
public $api;
|
76 |
*
|
77 |
* This holds cart items, purchase sessions, and anything else stored in the session.
|
78 |
*
|
79 |
+
* @var object|EDD_Session
|
80 |
* @since 1.5
|
81 |
*/
|
82 |
public $session;
|
84 |
/**
|
85 |
* EDD HTML Element Helper Object.
|
86 |
*
|
87 |
+
* @var object|EDD_HTML_Elements
|
88 |
* @since 1.5
|
89 |
*/
|
90 |
public $html;
|
92 |
/**
|
93 |
* EDD Emails Object.
|
94 |
*
|
95 |
+
* @var object|EDD_Emails
|
96 |
* @since 2.1
|
97 |
*/
|
98 |
public $emails;
|
100 |
/**
|
101 |
* EDD Email Template Tags Object.
|
102 |
*
|
103 |
+
* @var object|EDD_Email_Template_Tags
|
104 |
* @since 1.9
|
105 |
*/
|
106 |
public $email_tags;
|
108 |
/**
|
109 |
* EDD Customers DB Object.
|
110 |
*
|
111 |
+
* @var object|EDD_DB_Customers
|
112 |
* @since 2.1
|
113 |
*/
|
114 |
public $customers;
|
126 |
* @uses Easy_Digital_Downloads::includes() Include the required files.
|
127 |
* @uses Easy_Digital_Downloads::load_textdomain() load the language files.
|
128 |
* @see EDD()
|
129 |
+
* @return object|Easy_Digital_Downloads The one true Easy_Digital_Downloads
|
130 |
*/
|
131 |
public static function instance() {
|
132 |
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Easy_Digital_Downloads ) ) {
|
186 |
|
187 |
// Plugin version.
|
188 |
if ( ! defined( 'EDD_VERSION' ) ) {
|
189 |
+
define( 'EDD_VERSION', '2.5.8' );
|
190 |
}
|
191 |
|
192 |
// Plugin Folder Path.
|
431 |
* Example: <?php $edd = EDD(); ?>
|
432 |
*
|
433 |
* @since 1.4
|
434 |
+
* @return object|Easy_Digital_Downloads The one true Easy_Digital_Downloads Instance.
|
435 |
*/
|
436 |
function EDD() {
|
437 |
return Easy_Digital_Downloads::instance();
|
includes/admin/payments/view-order-details.php
CHANGED
@@ -70,6 +70,7 @@ $currency_code = $payment->currency;
|
|
70 |
<?php do_action( 'edd_view_order_details_totals_before', $payment_id ); ?>
|
71 |
|
72 |
<div class="edd-admin-box-inside">
|
|
|
73 |
<span class="label"><?php _e( 'Status:', 'easy-digital-downloads' ); ?></span>
|
74 |
<select name="edd-payment-status" class="medium-text">
|
75 |
<?php foreach( edd_get_payment_statuses() as $key => $status ) : ?>
|
70 |
<?php do_action( 'edd_view_order_details_totals_before', $payment_id ); ?>
|
71 |
|
72 |
<div class="edd-admin-box-inside">
|
73 |
+
<p>
|
74 |
<span class="label"><?php _e( 'Status:', 'easy-digital-downloads' ); ?></span>
|
75 |
<select name="edd-payment-status" class="medium-text">
|
76 |
<?php foreach( edd_get_payment_statuses() as $key => $status ) : ?>
|
includes/admin/settings/register-settings.php
CHANGED
@@ -19,6 +19,7 @@ if ( !defined( 'ABSPATH' ) ) exit;
|
|
19 |
* Looks to see if the specified setting exists, returns default if not
|
20 |
*
|
21 |
* @since 1.8.4
|
|
|
22 |
* @return mixed
|
23 |
*/
|
24 |
function edd_get_option( $key = '', $default = false ) {
|
@@ -38,6 +39,7 @@ function edd_get_option( $key = '', $default = false ) {
|
|
38 |
* @since 2.3
|
39 |
* @param string $key The Key to update
|
40 |
* @param string|bool|int $value The value to set the key to
|
|
|
41 |
* @return boolean True if updated, false if not.
|
42 |
*/
|
43 |
function edd_update_option( $key = '', $value = false ) {
|
@@ -79,6 +81,7 @@ function edd_update_option( $key = '', $value = false ) {
|
|
79 |
*
|
80 |
* @since 2.3
|
81 |
* @param string $key The Key to delete
|
|
|
82 |
* @return boolean True if updated, false if not.
|
83 |
*/
|
84 |
function edd_delete_option( $key = '' ) {
|
@@ -888,6 +891,7 @@ function edd_get_registered_settings() {
|
|
888 |
* @since 1.0.8.2
|
889 |
*
|
890 |
* @param array $input The value inputted in the field
|
|
|
891 |
*
|
892 |
* @return string $input Sanitizied value
|
893 |
*/
|
@@ -966,8 +970,6 @@ function edd_settings_sanitize( $input = array() ) {
|
|
966 |
*/
|
967 |
function edd_settings_sanitize_misc_file_downloads( $input ) {
|
968 |
|
969 |
-
global $edd_options;
|
970 |
-
|
971 |
if( ! current_user_can( 'manage_shop_settings' ) ) {
|
972 |
return $input;
|
973 |
}
|
@@ -990,8 +992,6 @@ add_filter( 'edd_settings_misc-file_downloads_sanitize', 'edd_settings_sanitize_
|
|
990 |
*/
|
991 |
function edd_settings_sanitize_misc_accounting( $input ) {
|
992 |
|
993 |
-
global $edd_options;
|
994 |
-
|
995 |
if( ! current_user_can( 'manage_shop_settings' ) ) {
|
996 |
return $input;
|
997 |
}
|
@@ -1199,21 +1199,21 @@ function edd_header_callback( $args ) {
|
|
1199 |
*
|
1200 |
* @since 1.0
|
1201 |
* @param array $args Arguments passed by the setting
|
1202 |
-
*
|
1203 |
* @return void
|
1204 |
*/
|
1205 |
function edd_checkbox_callback( $args ) {
|
1206 |
-
|
1207 |
|
1208 |
if ( isset( $args['faux'] ) && true === $args['faux'] ) {
|
1209 |
$name = '';
|
1210 |
} else {
|
1211 |
-
$name = 'name="edd_settings[' .
|
1212 |
}
|
1213 |
|
1214 |
$checked = isset( $edd_options[ $args['id'] ] ) ? checked( 1, $edd_options[ $args['id'] ], false ) : '';
|
1215 |
-
$html = '<input type="checkbox" id="edd_settings[' .
|
1216 |
-
$html .= '<label for="edd_settings[' .
|
1217 |
|
1218 |
echo $html;
|
1219 |
}
|
@@ -1225,17 +1225,17 @@ function edd_checkbox_callback( $args ) {
|
|
1225 |
*
|
1226 |
* @since 1.0
|
1227 |
* @param array $args Arguments passed by the setting
|
1228 |
-
*
|
1229 |
* @return void
|
1230 |
*/
|
1231 |
function edd_multicheck_callback( $args ) {
|
1232 |
-
|
1233 |
|
1234 |
if ( ! empty( $args['options'] ) ) {
|
1235 |
foreach( $args['options'] as $key => $option ):
|
1236 |
if( isset( $edd_options[$args['id']][$key] ) ) { $enabled = $option; } else { $enabled = NULL; }
|
1237 |
-
echo '<input name="edd_settings[' .
|
1238 |
-
echo '<label for="edd_settings[' .
|
1239 |
endforeach;
|
1240 |
echo '<p class="description">' . $args['desc'] . '</p>';
|
1241 |
}
|
@@ -1246,24 +1246,24 @@ function edd_multicheck_callback( $args ) {
|
|
1246 |
*
|
1247 |
* @since 2.1
|
1248 |
* @param array $args Arguments passed by the setting
|
1249 |
-
*
|
1250 |
* @return void
|
1251 |
*/
|
1252 |
function edd_payment_icons_callback( $args ) {
|
1253 |
-
|
1254 |
|
1255 |
if ( ! empty( $args['options'] ) ) {
|
1256 |
foreach( $args['options'] as $key => $option ) {
|
1257 |
|
1258 |
-
if( isset( $edd_options[$
|
1259 |
$enabled = $option;
|
1260 |
} else {
|
1261 |
$enabled = NULL;
|
1262 |
}
|
1263 |
|
1264 |
-
echo '<label for="edd_settings[' .
|
1265 |
|
1266 |
-
echo '<input name="edd_settings[' .
|
1267 |
|
1268 |
if( edd_string_is_image_url( $key ) ) {
|
1269 |
|
@@ -1312,22 +1312,22 @@ function edd_payment_icons_callback( $args ) {
|
|
1312 |
*
|
1313 |
* @since 1.3.3
|
1314 |
* @param array $args Arguments passed by the setting
|
1315 |
-
*
|
1316 |
* @return void
|
1317 |
*/
|
1318 |
function edd_radio_callback( $args ) {
|
1319 |
-
|
1320 |
|
1321 |
foreach ( $args['options'] as $key => $option ) :
|
1322 |
$checked = false;
|
1323 |
|
1324 |
-
if (
|
1325 |
$checked = true;
|
1326 |
-
elseif( isset( $args['std'] ) && $args['std'] == $key && !
|
1327 |
$checked = true;
|
1328 |
|
1329 |
-
echo '<input name="edd_settings[' .
|
1330 |
-
echo '<label for="edd_settings[' .
|
1331 |
endforeach;
|
1332 |
|
1333 |
echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
|
@@ -1340,20 +1340,20 @@ function edd_radio_callback( $args ) {
|
|
1340 |
*
|
1341 |
* @since 1.0
|
1342 |
* @param array $args Arguments passed by the setting
|
1343 |
-
*
|
1344 |
* @return void
|
1345 |
*/
|
1346 |
function edd_gateways_callback( $args ) {
|
1347 |
-
|
1348 |
|
1349 |
foreach ( $args['options'] as $key => $option ) :
|
1350 |
-
if ( isset( $edd_options[
|
1351 |
$enabled = '1';
|
1352 |
else
|
1353 |
$enabled = null;
|
1354 |
|
1355 |
-
echo '<input name="edd_settings[' . esc_attr( $args['id'] ) . '][' .
|
1356 |
-
echo '<label for="edd_settings[' .
|
1357 |
endforeach;
|
1358 |
}
|
1359 |
|
@@ -1364,21 +1364,21 @@ function edd_gateways_callback( $args ) {
|
|
1364 |
*
|
1365 |
* @since 1.5
|
1366 |
* @param array $args Arguments passed by the setting
|
1367 |
-
*
|
1368 |
* @return void
|
1369 |
*/
|
1370 |
function edd_gateway_select_callback($args) {
|
1371 |
-
|
1372 |
|
1373 |
-
echo '<select name="edd_settings[' .
|
1374 |
|
1375 |
foreach ( $args['options'] as $key => $option ) :
|
1376 |
$selected = isset( $edd_options[ $args['id'] ] ) ? selected( $key, $edd_options[$args['id']], false ) : '';
|
1377 |
-
echo '<option value="' .
|
1378 |
endforeach;
|
1379 |
|
1380 |
echo '</select>';
|
1381 |
-
echo '<label for="edd_settings[' .
|
1382 |
}
|
1383 |
|
1384 |
/**
|
@@ -1388,14 +1388,14 @@ function edd_gateway_select_callback($args) {
|
|
1388 |
*
|
1389 |
* @since 1.0
|
1390 |
* @param array $args Arguments passed by the setting
|
1391 |
-
*
|
1392 |
* @return void
|
1393 |
*/
|
1394 |
function edd_text_callback( $args ) {
|
1395 |
-
|
1396 |
|
1397 |
-
if (
|
1398 |
-
$value = $edd_options
|
1399 |
} else {
|
1400 |
$value = isset( $args['std'] ) ? $args['std'] : '';
|
1401 |
}
|
@@ -1410,8 +1410,8 @@ function edd_text_callback( $args ) {
|
|
1410 |
|
1411 |
$readonly = $args['readonly'] === true ? ' readonly="readonly"' : '';
|
1412 |
$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
1413 |
-
$html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="edd_settings[' .
|
1414 |
-
$html .= '<label for="edd_settings[' .
|
1415 |
|
1416 |
echo $html;
|
1417 |
}
|
@@ -1423,14 +1423,14 @@ function edd_text_callback( $args ) {
|
|
1423 |
*
|
1424 |
* @since 1.9
|
1425 |
* @param array $args Arguments passed by the setting
|
1426 |
-
*
|
1427 |
* @return void
|
1428 |
*/
|
1429 |
function edd_number_callback( $args ) {
|
1430 |
-
|
1431 |
|
1432 |
-
if (
|
1433 |
-
$value = $edd_options
|
1434 |
} else {
|
1435 |
$value = isset( $args['std'] ) ? $args['std'] : '';
|
1436 |
}
|
@@ -1448,8 +1448,8 @@ function edd_number_callback( $args ) {
|
|
1448 |
$step = isset( $args['step'] ) ? $args['step'] : 1;
|
1449 |
|
1450 |
$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
1451 |
-
$html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text" id="edd_settings[' .
|
1452 |
-
$html .= '<label for="edd_settings[' .
|
1453 |
|
1454 |
echo $html;
|
1455 |
}
|
@@ -1461,20 +1461,20 @@ function edd_number_callback( $args ) {
|
|
1461 |
*
|
1462 |
* @since 1.0
|
1463 |
* @param array $args Arguments passed by the setting
|
1464 |
-
*
|
1465 |
* @return void
|
1466 |
*/
|
1467 |
function edd_textarea_callback( $args ) {
|
1468 |
-
|
1469 |
|
1470 |
-
if (
|
1471 |
-
$value = $edd_options
|
1472 |
} else {
|
1473 |
$value = isset( $args['std'] ) ? $args['std'] : '';
|
1474 |
}
|
1475 |
|
1476 |
-
$html = '<textarea class="large-text" cols="50" rows="5" id="edd_settings[' .
|
1477 |
-
$html .= '<label for="edd_settings[' .
|
1478 |
|
1479 |
echo $html;
|
1480 |
}
|
@@ -1486,21 +1486,21 @@ function edd_textarea_callback( $args ) {
|
|
1486 |
*
|
1487 |
* @since 1.3
|
1488 |
* @param array $args Arguments passed by the setting
|
1489 |
-
*
|
1490 |
* @return void
|
1491 |
*/
|
1492 |
function edd_password_callback( $args ) {
|
1493 |
-
|
1494 |
|
1495 |
-
if (
|
1496 |
-
$value = $edd_options
|
1497 |
} else {
|
1498 |
$value = isset( $args['std'] ) ? $args['std'] : '';
|
1499 |
}
|
1500 |
|
1501 |
$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
1502 |
-
$html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="edd_settings[' .
|
1503 |
-
$html .= '<label for="edd_settings[' .
|
1504 |
|
1505 |
echo $html;
|
1506 |
}
|
@@ -1528,14 +1528,14 @@ function edd_missing_callback($args) {
|
|
1528 |
*
|
1529 |
* @since 1.0
|
1530 |
* @param array $args Arguments passed by the setting
|
1531 |
-
*
|
1532 |
* @return void
|
1533 |
*/
|
1534 |
function edd_select_callback($args) {
|
1535 |
-
|
1536 |
|
1537 |
-
if (
|
1538 |
-
$value = $edd_options
|
1539 |
} else {
|
1540 |
$value = isset( $args['std'] ) ? $args['std'] : '';
|
1541 |
}
|
@@ -1552,7 +1552,7 @@ function edd_select_callback($args) {
|
|
1552 |
$chosen = '';
|
1553 |
}
|
1554 |
|
1555 |
-
$html = '<select id="edd_settings[' .
|
1556 |
|
1557 |
foreach ( $args['options'] as $option => $name ) {
|
1558 |
$selected = selected( $option, $value, false );
|
@@ -1560,7 +1560,7 @@ function edd_select_callback($args) {
|
|
1560 |
}
|
1561 |
|
1562 |
$html .= '</select>';
|
1563 |
-
$html .= '<label for="edd_settings[' .
|
1564 |
|
1565 |
echo $html;
|
1566 |
}
|
@@ -1572,19 +1572,19 @@ function edd_select_callback($args) {
|
|
1572 |
*
|
1573 |
* @since 1.8
|
1574 |
* @param array $args Arguments passed by the setting
|
1575 |
-
*
|
1576 |
* @return void
|
1577 |
*/
|
1578 |
function edd_color_select_callback( $args ) {
|
1579 |
-
|
1580 |
|
1581 |
-
if (
|
1582 |
-
$value = $edd_options
|
1583 |
} else {
|
1584 |
$value = isset( $args['std'] ) ? $args['std'] : '';
|
1585 |
}
|
1586 |
|
1587 |
-
$html = '<select id="edd_settings[' .
|
1588 |
|
1589 |
foreach ( $args['options'] as $option => $color ) {
|
1590 |
$selected = selected( $option, $value, false );
|
@@ -1592,7 +1592,7 @@ function edd_color_select_callback( $args ) {
|
|
1592 |
}
|
1593 |
|
1594 |
$html .= '</select>';
|
1595 |
-
$html .= '<label for="edd_settings[' .
|
1596 |
|
1597 |
echo $html;
|
1598 |
}
|
@@ -1604,14 +1604,16 @@ function edd_color_select_callback( $args ) {
|
|
1604 |
*
|
1605 |
* @since 1.0
|
1606 |
* @param array $args Arguments passed by the setting
|
1607 |
-
*
|
1608 |
* @global $wp_version WordPress Version
|
1609 |
*/
|
1610 |
function edd_rich_editor_callback( $args ) {
|
1611 |
-
global $
|
|
|
|
|
1612 |
|
1613 |
-
if (
|
1614 |
-
$value = $edd_options
|
1615 |
|
1616 |
if( empty( $args['allow_blank'] ) && empty( $value ) ) {
|
1617 |
$value = isset( $args['std'] ) ? $args['std'] : '';
|
@@ -1627,10 +1629,10 @@ function edd_rich_editor_callback( $args ) {
|
|
1627 |
wp_editor( stripslashes( $value ), 'edd_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'edd_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ) ) );
|
1628 |
$html = ob_get_clean();
|
1629 |
} else {
|
1630 |
-
$html = '<textarea class="large-text" rows="10" id="edd_settings[' .
|
1631 |
}
|
1632 |
|
1633 |
-
$html .= '<br/><label for="edd_settings[' .
|
1634 |
|
1635 |
echo $html;
|
1636 |
}
|
@@ -1642,22 +1644,22 @@ function edd_rich_editor_callback( $args ) {
|
|
1642 |
*
|
1643 |
* @since 1.0
|
1644 |
* @param array $args Arguments passed by the setting
|
1645 |
-
*
|
1646 |
* @return void
|
1647 |
*/
|
1648 |
function edd_upload_callback( $args ) {
|
1649 |
-
|
1650 |
|
1651 |
-
if (
|
1652 |
-
$value = $edd_options
|
1653 |
} else {
|
1654 |
$value = isset($args['std']) ? $args['std'] : '';
|
1655 |
}
|
1656 |
|
1657 |
$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
1658 |
-
$html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="edd_settings[' .
|
1659 |
$html .= '<span> <input type="button" class="edd_settings_upload_button button-secondary" value="' . __( 'Upload File', 'easy-digital-downloads' ) . '"/></span>';
|
1660 |
-
$html .= '<label for="edd_settings[' .
|
1661 |
|
1662 |
echo $html;
|
1663 |
}
|
@@ -1670,22 +1672,22 @@ function edd_upload_callback( $args ) {
|
|
1670 |
*
|
1671 |
* @since 1.6
|
1672 |
* @param array $args Arguments passed by the setting
|
1673 |
-
*
|
1674 |
* @return void
|
1675 |
*/
|
1676 |
function edd_color_callback( $args ) {
|
1677 |
-
|
1678 |
|
1679 |
-
if (
|
1680 |
-
$value = $edd_options
|
1681 |
} else {
|
1682 |
$value = isset( $args['std'] ) ? $args['std'] : '';
|
1683 |
}
|
1684 |
|
1685 |
$default = isset( $args['std'] ) ? $args['std'] : '';
|
1686 |
|
1687 |
-
$html = '<input type="text" class="edd-color-picker" id="edd_settings[' .
|
1688 |
-
$html .= '<label for="edd_settings[' .
|
1689 |
|
1690 |
echo $html;
|
1691 |
}
|
@@ -1697,11 +1699,11 @@ function edd_color_callback( $args ) {
|
|
1697 |
*
|
1698 |
* @since 1.6
|
1699 |
* @param array $args Arguments passed by the setting
|
1700 |
-
*
|
1701 |
* @return void
|
1702 |
*/
|
1703 |
function edd_shop_states_callback($args) {
|
1704 |
-
|
1705 |
|
1706 |
if ( isset( $args['placeholder'] ) ) {
|
1707 |
$placeholder = $args['placeholder'];
|
@@ -1713,7 +1715,7 @@ function edd_shop_states_callback($args) {
|
|
1713 |
|
1714 |
$chosen = ( $args['chosen'] ? ' edd-chosen' : '' );
|
1715 |
$class = empty( $states ) ? ' class="edd-no-states' . $chosen . '"' : 'class="' . $chosen . '"';
|
1716 |
-
$html = '<select id="edd_settings[' .
|
1717 |
|
1718 |
foreach ( $states as $option => $name ) {
|
1719 |
$selected = isset( $edd_options[ $args['id'] ] ) ? selected( $option, $edd_options[$args['id']], false ) : '';
|
@@ -1721,7 +1723,7 @@ function edd_shop_states_callback($args) {
|
|
1721 |
}
|
1722 |
|
1723 |
$html .= '</select>';
|
1724 |
-
$html .= '<label for="edd_settings[' .
|
1725 |
|
1726 |
echo $html;
|
1727 |
}
|
@@ -1733,11 +1735,9 @@ function edd_shop_states_callback($args) {
|
|
1733 |
*
|
1734 |
* @since 1.6
|
1735 |
* @param array $args Arguments passed by the setting
|
1736 |
-
* @global $edd_options Array of all the EDD Options
|
1737 |
* @return void
|
1738 |
*/
|
1739 |
function edd_tax_rates_callback($args) {
|
1740 |
-
global $edd_options;
|
1741 |
$rates = edd_get_tax_rates();
|
1742 |
ob_start(); ?>
|
1743 |
<p><?php echo $args['desc']; ?></p>
|
@@ -1758,7 +1758,7 @@ function edd_tax_rates_callback($args) {
|
|
1758 |
<?php
|
1759 |
echo EDD()->html->select( array(
|
1760 |
'options' => edd_get_country_list(),
|
1761 |
-
'name' => 'tax_rates[' .
|
1762 |
'selected' => $rate['country'],
|
1763 |
'show_option_all' => false,
|
1764 |
'show_option_none' => false,
|
@@ -1774,7 +1774,7 @@ function edd_tax_rates_callback($args) {
|
|
1774 |
if( ! empty( $states ) ) {
|
1775 |
echo EDD()->html->select( array(
|
1776 |
'options' => $states,
|
1777 |
-
'name' => 'tax_rates[' .
|
1778 |
'selected' => $rate['state'],
|
1779 |
'show_option_all' => false,
|
1780 |
'show_option_none' => false,
|
@@ -1783,17 +1783,17 @@ function edd_tax_rates_callback($args) {
|
|
1783 |
) );
|
1784 |
} else {
|
1785 |
echo EDD()->html->text( array(
|
1786 |
-
'name' => 'tax_rates[' .
|
1787 |
'value' => ! empty( $rate['state'] ) ? $rate['state'] : '',
|
1788 |
) );
|
1789 |
}
|
1790 |
?>
|
1791 |
</td>
|
1792 |
<td class="edd_tax_global">
|
1793 |
-
<input type="checkbox" name="tax_rates[<?php echo
|
1794 |
-
<label for="tax_rates[<?php echo
|
1795 |
</td>
|
1796 |
-
<td class="edd_tax_rate"><input type="number" class="small-text" step="0.0001" min="0.0" max="99" name="tax_rates[<?php echo
|
1797 |
<td><span class="edd_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'easy-digital-downloads' ); ?></span></td>
|
1798 |
</tr>
|
1799 |
<?php endforeach; ?>
|
@@ -1850,18 +1850,18 @@ function edd_descriptive_text_callback( $args ) {
|
|
1850 |
*
|
1851 |
* @since 1.5
|
1852 |
* @param array $args Arguments passed by the setting
|
1853 |
-
*
|
1854 |
* @return void
|
1855 |
*/
|
1856 |
if ( ! function_exists( 'edd_license_key_callback' ) ) {
|
1857 |
function edd_license_key_callback( $args ) {
|
1858 |
-
|
1859 |
|
1860 |
$messages = array();
|
1861 |
$license = get_option( $args['options']['is_valid_license_option'] );
|
1862 |
|
1863 |
-
if (
|
1864 |
-
$value = $edd_options
|
1865 |
} else {
|
1866 |
$value = isset( $args['std'] ) ? $args['std'] : '';
|
1867 |
}
|
@@ -1982,13 +1982,13 @@ if ( ! function_exists( 'edd_license_key_callback' ) ) {
|
|
1982 |
}
|
1983 |
|
1984 |
$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
1985 |
-
$html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="edd_settings[' .
|
1986 |
|
1987 |
if ( ( is_object( $license ) && 'valid' == $license->license ) || 'valid' == $license ) {
|
1988 |
$html .= '<input type="submit" class="button-secondary" name="' . $args['id'] . '_deactivate" value="' . __( 'Deactivate License', 'easy-digital-downloads' ) . '"/>';
|
1989 |
}
|
1990 |
|
1991 |
-
$html .= '<label for="edd_settings[' .
|
1992 |
|
1993 |
if ( ! empty( $messages ) ) {
|
1994 |
foreach( $messages as $message ) {
|
@@ -2000,7 +2000,7 @@ if ( ! function_exists( 'edd_license_key_callback' ) ) {
|
|
2000 |
}
|
2001 |
}
|
2002 |
|
2003 |
-
wp_nonce_field(
|
2004 |
|
2005 |
if ( isset( $license_status ) ) {
|
2006 |
echo '<div class="' . $license_status . '">' . $html . '</div>';
|
19 |
* Looks to see if the specified setting exists, returns default if not
|
20 |
*
|
21 |
* @since 1.8.4
|
22 |
+
* @global $edd_options Array of all the EDD Options
|
23 |
* @return mixed
|
24 |
*/
|
25 |
function edd_get_option( $key = '', $default = false ) {
|
39 |
* @since 2.3
|
40 |
* @param string $key The Key to update
|
41 |
* @param string|bool|int $value The value to set the key to
|
42 |
+
* @global $edd_options Array of all the EDD Options
|
43 |
* @return boolean True if updated, false if not.
|
44 |
*/
|
45 |
function edd_update_option( $key = '', $value = false ) {
|
81 |
*
|
82 |
* @since 2.3
|
83 |
* @param string $key The Key to delete
|
84 |
+
* @global $edd_options Array of all the EDD Options
|
85 |
* @return boolean True if updated, false if not.
|
86 |
*/
|
87 |
function edd_delete_option( $key = '' ) {
|
891 |
* @since 1.0.8.2
|
892 |
*
|
893 |
* @param array $input The value inputted in the field
|
894 |
+
* @global $edd_options Array of all the EDD Options
|
895 |
*
|
896 |
* @return string $input Sanitizied value
|
897 |
*/
|
970 |
*/
|
971 |
function edd_settings_sanitize_misc_file_downloads( $input ) {
|
972 |
|
|
|
|
|
973 |
if( ! current_user_can( 'manage_shop_settings' ) ) {
|
974 |
return $input;
|
975 |
}
|
992 |
*/
|
993 |
function edd_settings_sanitize_misc_accounting( $input ) {
|
994 |
|
|
|
|
|
995 |
if( ! current_user_can( 'manage_shop_settings' ) ) {
|
996 |
return $input;
|
997 |
}
|
1199 |
*
|
1200 |
* @since 1.0
|
1201 |
* @param array $args Arguments passed by the setting
|
1202 |
+
*
|
1203 |
* @return void
|
1204 |
*/
|
1205 |
function edd_checkbox_callback( $args ) {
|
1206 |
+
$edd_options = edd_get_option( $args['id'] );
|
1207 |
|
1208 |
if ( isset( $args['faux'] ) && true === $args['faux'] ) {
|
1209 |
$name = '';
|
1210 |
} else {
|
1211 |
+
$name = 'name="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']"';
|
1212 |
}
|
1213 |
|
1214 |
$checked = isset( $edd_options[ $args['id'] ] ) ? checked( 1, $edd_options[ $args['id'] ], false ) : '';
|
1215 |
+
$html = '<input type="checkbox" id="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']"' . $name . ' value="1" ' . $checked . '/>';
|
1216 |
+
$html .= '<label for="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
|
1217 |
|
1218 |
echo $html;
|
1219 |
}
|
1225 |
*
|
1226 |
* @since 1.0
|
1227 |
* @param array $args Arguments passed by the setting
|
1228 |
+
*
|
1229 |
* @return void
|
1230 |
*/
|
1231 |
function edd_multicheck_callback( $args ) {
|
1232 |
+
$edd_options = edd_get_option( $args['id'] );
|
1233 |
|
1234 |
if ( ! empty( $args['options'] ) ) {
|
1235 |
foreach( $args['options'] as $key => $option ):
|
1236 |
if( isset( $edd_options[$args['id']][$key] ) ) { $enabled = $option; } else { $enabled = NULL; }
|
1237 |
+
echo '<input name="edd_settings[' . edd_sanitize_key( $args['id'] ) . '][' . edd_sanitize_key( $key ) . ']" id="edd_settings[' . edd_sanitize_key( $args['id'] ) . '][' . edd_sanitize_key( $key ) . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked($option, $enabled, false) . '/> ';
|
1238 |
+
echo '<label for="edd_settings[' . edd_sanitize_key( $args['id'] ) . '][' . edd_sanitize_key( $key ) . ']">' . wp_kses_post( $option ) . '</label><br/>';
|
1239 |
endforeach;
|
1240 |
echo '<p class="description">' . $args['desc'] . '</p>';
|
1241 |
}
|
1246 |
*
|
1247 |
* @since 2.1
|
1248 |
* @param array $args Arguments passed by the setting
|
1249 |
+
*
|
1250 |
* @return void
|
1251 |
*/
|
1252 |
function edd_payment_icons_callback( $args ) {
|
1253 |
+
$edd_options = edd_get_option( $args['id'] );
|
1254 |
|
1255 |
if ( ! empty( $args['options'] ) ) {
|
1256 |
foreach( $args['options'] as $key => $option ) {
|
1257 |
|
1258 |
+
if( isset( $edd_options[$key] ) ) {
|
1259 |
$enabled = $option;
|
1260 |
} else {
|
1261 |
$enabled = NULL;
|
1262 |
}
|
1263 |
|
1264 |
+
echo '<label for="edd_settings[' . edd_sanitize_key( $args['id'] ) . '][' . edd_sanitize_key( $key ) . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
|
1265 |
|
1266 |
+
echo '<input name="edd_settings[' . edd_sanitize_key( $args['id'] ) . '][' . edd_sanitize_key( $key ) . ']" id="edd_settings[' . edd_sanitize_key( $args['id'] ) . '][' . edd_sanitize_key( $key ) . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> ';
|
1267 |
|
1268 |
if( edd_string_is_image_url( $key ) ) {
|
1269 |
|
1312 |
*
|
1313 |
* @since 1.3.3
|
1314 |
* @param array $args Arguments passed by the setting
|
1315 |
+
*
|
1316 |
* @return void
|
1317 |
*/
|
1318 |
function edd_radio_callback( $args ) {
|
1319 |
+
$edd_options = edd_get_option( $args['id'] );
|
1320 |
|
1321 |
foreach ( $args['options'] as $key => $option ) :
|
1322 |
$checked = false;
|
1323 |
|
1324 |
+
if ( $edd_options && $edd_options == $key )
|
1325 |
$checked = true;
|
1326 |
+
elseif( isset( $args['std'] ) && $args['std'] == $key && ! $edd_options )
|
1327 |
$checked = true;
|
1328 |
|
1329 |
+
echo '<input name="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']" id="edd_settings[' . edd_sanitize_key( $args['id'] ) . '][' . edd_sanitize_key( $key ) . ']" type="radio" value="' . edd_sanitize_key( $key ) . '" ' . checked(true, $checked, false) . '/> ';
|
1330 |
+
echo '<label for="edd_settings[' . edd_sanitize_key( $args['id'] ) . '][' . edd_sanitize_key( $key ) . ']">' . esc_html( $option ) . '</label><br/>';
|
1331 |
endforeach;
|
1332 |
|
1333 |
echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
|
1340 |
*
|
1341 |
* @since 1.0
|
1342 |
* @param array $args Arguments passed by the setting
|
1343 |
+
*
|
1344 |
* @return void
|
1345 |
*/
|
1346 |
function edd_gateways_callback( $args ) {
|
1347 |
+
$edd_options = edd_get_option( $args['id'] );
|
1348 |
|
1349 |
foreach ( $args['options'] as $key => $option ) :
|
1350 |
+
if ( isset( $edd_options[ $key ] ) )
|
1351 |
$enabled = '1';
|
1352 |
else
|
1353 |
$enabled = null;
|
1354 |
|
1355 |
+
echo '<input name="edd_settings[' . esc_attr( $args['id'] ) . '][' . edd_sanitize_key( $key ) . ']"" id="edd_settings[' . edd_sanitize_key( $args['id'] ) . '][' . edd_sanitize_key( $key ) . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> ';
|
1356 |
+
echo '<label for="edd_settings[' . edd_sanitize_key( $args['id'] ) . '][' . edd_sanitize_key( $key ) . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
|
1357 |
endforeach;
|
1358 |
}
|
1359 |
|
1364 |
*
|
1365 |
* @since 1.5
|
1366 |
* @param array $args Arguments passed by the setting
|
1367 |
+
*
|
1368 |
* @return void
|
1369 |
*/
|
1370 |
function edd_gateway_select_callback($args) {
|
1371 |
+
$edd_options = edd_get_option( $args['id'] );
|
1372 |
|
1373 |
+
echo '<select name="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']"" id="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']">';
|
1374 |
|
1375 |
foreach ( $args['options'] as $key => $option ) :
|
1376 |
$selected = isset( $edd_options[ $args['id'] ] ) ? selected( $key, $edd_options[$args['id']], false ) : '';
|
1377 |
+
echo '<option value="' . edd_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
|
1378 |
endforeach;
|
1379 |
|
1380 |
echo '</select>';
|
1381 |
+
echo '<label for="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
|
1382 |
}
|
1383 |
|
1384 |
/**
|
1388 |
*
|
1389 |
* @since 1.0
|
1390 |
* @param array $args Arguments passed by the setting
|
1391 |
+
*
|
1392 |
* @return void
|
1393 |
*/
|
1394 |
function edd_text_callback( $args ) {
|
1395 |
+
$edd_options = edd_get_option( $args['id'] );
|
1396 |
|
1397 |
+
if ( $edd_options ) {
|
1398 |
+
$value = $edd_options;
|
1399 |
} else {
|
1400 |
$value = isset( $args['std'] ) ? $args['std'] : '';
|
1401 |
}
|
1410 |
|
1411 |
$readonly = $args['readonly'] === true ? ' readonly="readonly"' : '';
|
1412 |
$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
1413 |
+
$html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>';
|
1414 |
+
$html .= '<label for="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
|
1415 |
|
1416 |
echo $html;
|
1417 |
}
|
1423 |
*
|
1424 |
* @since 1.9
|
1425 |
* @param array $args Arguments passed by the setting
|
1426 |
+
*
|
1427 |
* @return void
|
1428 |
*/
|
1429 |
function edd_number_callback( $args ) {
|
1430 |
+
$edd_options = edd_get_option( $args['id'] );
|
1431 |
|
1432 |
+
if ( $edd_options ) {
|
1433 |
+
$value = $edd_options;
|
1434 |
} else {
|
1435 |
$value = isset( $args['std'] ) ? $args['std'] : '';
|
1436 |
}
|
1448 |
$step = isset( $args['step'] ) ? $args['step'] : 1;
|
1449 |
|
1450 |
$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
1451 |
+
$html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text" id="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>';
|
1452 |
+
$html .= '<label for="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
|
1453 |
|
1454 |
echo $html;
|
1455 |
}
|
1461 |
*
|
1462 |
* @since 1.0
|
1463 |
* @param array $args Arguments passed by the setting
|
1464 |
+
*
|
1465 |
* @return void
|
1466 |
*/
|
1467 |
function edd_textarea_callback( $args ) {
|
1468 |
+
$edd_options = edd_get_option( $args['id'] );
|
1469 |
|
1470 |
+
if ( $edd_options ) {
|
1471 |
+
$value = $edd_options;
|
1472 |
} else {
|
1473 |
$value = isset( $args['std'] ) ? $args['std'] : '';
|
1474 |
}
|
1475 |
|
1476 |
+
$html = '<textarea class="large-text" cols="50" rows="5" id="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']" name="edd_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
|
1477 |
+
$html .= '<label for="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
|
1478 |
|
1479 |
echo $html;
|
1480 |
}
|
1486 |
*
|
1487 |
* @since 1.3
|
1488 |
* @param array $args Arguments passed by the setting
|
1489 |
+
*
|
1490 |
* @return void
|
1491 |
*/
|
1492 |
function edd_password_callback( $args ) {
|
1493 |
+
$edd_options = edd_get_option( $args['id'] );
|
1494 |
|
1495 |
+
if ( $edd_options ) {
|
1496 |
+
$value = $edd_options;
|
1497 |
} else {
|
1498 |
$value = isset( $args['std'] ) ? $args['std'] : '';
|
1499 |
}
|
1500 |
|
1501 |
$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
1502 |
+
$html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']" name="edd_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
|
1503 |
+
$html .= '<label for="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
|
1504 |
|
1505 |
echo $html;
|
1506 |
}
|
1528 |
*
|
1529 |
* @since 1.0
|
1530 |
* @param array $args Arguments passed by the setting
|
1531 |
+
*
|
1532 |
* @return void
|
1533 |
*/
|
1534 |
function edd_select_callback($args) {
|
1535 |
+
$edd_options = edd_get_option( $args['id'] );
|
1536 |
|
1537 |
+
if ( $edd_options ) {
|
1538 |
+
$value = $edd_options;
|
1539 |
} else {
|
1540 |
$value = isset( $args['std'] ) ? $args['std'] : '';
|
1541 |
}
|
1552 |
$chosen = '';
|
1553 |
}
|
1554 |
|
1555 |
+
$html = '<select id="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']" name="edd_settings[' . esc_attr( $args['id'] ) . ']" ' . $chosen . 'data-placeholder="' . esc_html( $placeholder ) . '" />';
|
1556 |
|
1557 |
foreach ( $args['options'] as $option => $name ) {
|
1558 |
$selected = selected( $option, $value, false );
|
1560 |
}
|
1561 |
|
1562 |
$html .= '</select>';
|
1563 |
+
$html .= '<label for="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
|
1564 |
|
1565 |
echo $html;
|
1566 |
}
|
1572 |
*
|
1573 |
* @since 1.8
|
1574 |
* @param array $args Arguments passed by the setting
|
1575 |
+
*
|
1576 |
* @return void
|
1577 |
*/
|
1578 |
function edd_color_select_callback( $args ) {
|
1579 |
+
$edd_options = edd_get_option( $args['id'] );
|
1580 |
|
1581 |
+
if ( $edd_options ) {
|
1582 |
+
$value = $edd_options;
|
1583 |
} else {
|
1584 |
$value = isset( $args['std'] ) ? $args['std'] : '';
|
1585 |
}
|
1586 |
|
1587 |
+
$html = '<select id="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']" name="edd_settings[' . esc_attr( $args['id'] ) . ']"/>';
|
1588 |
|
1589 |
foreach ( $args['options'] as $option => $color ) {
|
1590 |
$selected = selected( $option, $value, false );
|
1592 |
}
|
1593 |
|
1594 |
$html .= '</select>';
|
1595 |
+
$html .= '<label for="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
|
1596 |
|
1597 |
echo $html;
|
1598 |
}
|
1604 |
*
|
1605 |
* @since 1.0
|
1606 |
* @param array $args Arguments passed by the setting
|
1607 |
+
*
|
1608 |
* @global $wp_version WordPress Version
|
1609 |
*/
|
1610 |
function edd_rich_editor_callback( $args ) {
|
1611 |
+
global $wp_version;
|
1612 |
+
|
1613 |
+
$edd_options = edd_get_option( $args['id'] );
|
1614 |
|
1615 |
+
if ( $edd_options ) {
|
1616 |
+
$value = $edd_options;
|
1617 |
|
1618 |
if( empty( $args['allow_blank'] ) && empty( $value ) ) {
|
1619 |
$value = isset( $args['std'] ) ? $args['std'] : '';
|
1629 |
wp_editor( stripslashes( $value ), 'edd_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'edd_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ) ) );
|
1630 |
$html = ob_get_clean();
|
1631 |
} else {
|
1632 |
+
$html = '<textarea class="large-text" rows="10" id="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']" name="edd_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
|
1633 |
}
|
1634 |
|
1635 |
+
$html .= '<br/><label for="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
|
1636 |
|
1637 |
echo $html;
|
1638 |
}
|
1644 |
*
|
1645 |
* @since 1.0
|
1646 |
* @param array $args Arguments passed by the setting
|
1647 |
+
*
|
1648 |
* @return void
|
1649 |
*/
|
1650 |
function edd_upload_callback( $args ) {
|
1651 |
+
$edd_options = edd_get_option( $args['id'] );
|
1652 |
|
1653 |
+
if ( $edd_options ) {
|
1654 |
+
$value = $edd_options;
|
1655 |
} else {
|
1656 |
$value = isset($args['std']) ? $args['std'] : '';
|
1657 |
}
|
1658 |
|
1659 |
$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
1660 |
+
$html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']" name="edd_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
|
1661 |
$html .= '<span> <input type="button" class="edd_settings_upload_button button-secondary" value="' . __( 'Upload File', 'easy-digital-downloads' ) . '"/></span>';
|
1662 |
+
$html .= '<label for="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
|
1663 |
|
1664 |
echo $html;
|
1665 |
}
|
1672 |
*
|
1673 |
* @since 1.6
|
1674 |
* @param array $args Arguments passed by the setting
|
1675 |
+
*
|
1676 |
* @return void
|
1677 |
*/
|
1678 |
function edd_color_callback( $args ) {
|
1679 |
+
$edd_options = edd_get_option( $args['id'] );
|
1680 |
|
1681 |
+
if ( $edd_options ) {
|
1682 |
+
$value = $edd_options;
|
1683 |
} else {
|
1684 |
$value = isset( $args['std'] ) ? $args['std'] : '';
|
1685 |
}
|
1686 |
|
1687 |
$default = isset( $args['std'] ) ? $args['std'] : '';
|
1688 |
|
1689 |
+
$html = '<input type="text" class="edd-color-picker" id="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']" name="edd_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />';
|
1690 |
+
$html .= '<label for="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
|
1691 |
|
1692 |
echo $html;
|
1693 |
}
|
1699 |
*
|
1700 |
* @since 1.6
|
1701 |
* @param array $args Arguments passed by the setting
|
1702 |
+
*
|
1703 |
* @return void
|
1704 |
*/
|
1705 |
function edd_shop_states_callback($args) {
|
1706 |
+
$edd_options = edd_get_option( $args['id'] );
|
1707 |
|
1708 |
if ( isset( $args['placeholder'] ) ) {
|
1709 |
$placeholder = $args['placeholder'];
|
1715 |
|
1716 |
$chosen = ( $args['chosen'] ? ' edd-chosen' : '' );
|
1717 |
$class = empty( $states ) ? ' class="edd-no-states' . $chosen . '"' : 'class="' . $chosen . '"';
|
1718 |
+
$html = '<select id="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']" name="edd_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
|
1719 |
|
1720 |
foreach ( $states as $option => $name ) {
|
1721 |
$selected = isset( $edd_options[ $args['id'] ] ) ? selected( $option, $edd_options[$args['id']], false ) : '';
|
1723 |
}
|
1724 |
|
1725 |
$html .= '</select>';
|
1726 |
+
$html .= '<label for="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
|
1727 |
|
1728 |
echo $html;
|
1729 |
}
|
1735 |
*
|
1736 |
* @since 1.6
|
1737 |
* @param array $args Arguments passed by the setting
|
|
|
1738 |
* @return void
|
1739 |
*/
|
1740 |
function edd_tax_rates_callback($args) {
|
|
|
1741 |
$rates = edd_get_tax_rates();
|
1742 |
ob_start(); ?>
|
1743 |
<p><?php echo $args['desc']; ?></p>
|
1758 |
<?php
|
1759 |
echo EDD()->html->select( array(
|
1760 |
'options' => edd_get_country_list(),
|
1761 |
+
'name' => 'tax_rates[' . edd_sanitize_key( $key ) . '][country]',
|
1762 |
'selected' => $rate['country'],
|
1763 |
'show_option_all' => false,
|
1764 |
'show_option_none' => false,
|
1774 |
if( ! empty( $states ) ) {
|
1775 |
echo EDD()->html->select( array(
|
1776 |
'options' => $states,
|
1777 |
+
'name' => 'tax_rates[' . edd_sanitize_key( $key ) . '][state]',
|
1778 |
'selected' => $rate['state'],
|
1779 |
'show_option_all' => false,
|
1780 |
'show_option_none' => false,
|
1783 |
) );
|
1784 |
} else {
|
1785 |
echo EDD()->html->text( array(
|
1786 |
+
'name' => 'tax_rates[' . edd_sanitize_key( $key ) . '][state]', $rate['state'],
|
1787 |
'value' => ! empty( $rate['state'] ) ? $rate['state'] : '',
|
1788 |
) );
|
1789 |
}
|
1790 |
?>
|
1791 |
</td>
|
1792 |
<td class="edd_tax_global">
|
1793 |
+
<input type="checkbox" name="tax_rates[<?php echo edd_sanitize_key( $key ); ?>][global]" id="tax_rates[<?php echo edd_sanitize_key( $key ); ?>][global]" value="1"<?php checked( true, ! empty( $rate['global'] ) ); ?>/>
|
1794 |
+
<label for="tax_rates[<?php echo edd_sanitize_key( $key ); ?>][global]"><?php _e( 'Apply to whole country', 'easy-digital-downloads' ); ?></label>
|
1795 |
</td>
|
1796 |
+
<td class="edd_tax_rate"><input type="number" class="small-text" step="0.0001" min="0.0" max="99" name="tax_rates[<?php echo edd_sanitize_key( $key ); ?>][rate]" value="<?php echo esc_html( $rate['rate'] ); ?>"/></td>
|
1797 |
<td><span class="edd_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'easy-digital-downloads' ); ?></span></td>
|
1798 |
</tr>
|
1799 |
<?php endforeach; ?>
|
1850 |
*
|
1851 |
* @since 1.5
|
1852 |
* @param array $args Arguments passed by the setting
|
1853 |
+
*
|
1854 |
* @return void
|
1855 |
*/
|
1856 |
if ( ! function_exists( 'edd_license_key_callback' ) ) {
|
1857 |
function edd_license_key_callback( $args ) {
|
1858 |
+
$edd_options = edd_get_option( $args['id'] );
|
1859 |
|
1860 |
$messages = array();
|
1861 |
$license = get_option( $args['options']['is_valid_license_option'] );
|
1862 |
|
1863 |
+
if ( $edd_options ) {
|
1864 |
+
$value = $edd_options;
|
1865 |
} else {
|
1866 |
$value = isset( $args['std'] ) ? $args['std'] : '';
|
1867 |
}
|
1982 |
}
|
1983 |
|
1984 |
$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
1985 |
+
$html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']" name="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
|
1986 |
|
1987 |
if ( ( is_object( $license ) && 'valid' == $license->license ) || 'valid' == $license ) {
|
1988 |
$html .= '<input type="submit" class="button-secondary" name="' . $args['id'] . '_deactivate" value="' . __( 'Deactivate License', 'easy-digital-downloads' ) . '"/>';
|
1989 |
}
|
1990 |
|
1991 |
+
$html .= '<label for="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
|
1992 |
|
1993 |
if ( ! empty( $messages ) ) {
|
1994 |
foreach( $messages as $message ) {
|
2000 |
}
|
2001 |
}
|
2002 |
|
2003 |
+
wp_nonce_field( edd_sanitize_key( $args['id'] ) . '-nonce', edd_sanitize_key( $args['id'] ) . '-nonce' );
|
2004 |
|
2005 |
if ( isset( $license_status ) ) {
|
2006 |
echo '<div class="' . $license_status . '">' . $html . '</div>';
|
includes/ajax-functions.php
CHANGED
@@ -268,7 +268,7 @@ function edd_ajax_apply_discount() {
|
|
268 |
if ( is_user_logged_in() ) {
|
269 |
$user = get_current_user_id();
|
270 |
} else {
|
271 |
-
|
272 |
if ( ! empty( $form['edd_email'] ) ) {
|
273 |
$user = urldecode( $form['edd_email'] );
|
274 |
}
|
@@ -315,7 +315,7 @@ function edd_ajax_update_cart_item_quantity() {
|
|
315 |
|
316 |
$download_id = absint( $_POST['download_id'] );
|
317 |
$quantity = absint( $_POST['quantity'] );
|
318 |
-
$options =
|
319 |
|
320 |
edd_set_cart_item_quantity( $download_id, absint( $_POST['quantity'] ), $options );
|
321 |
$total = edd_get_cart_total();
|
268 |
if ( is_user_logged_in() ) {
|
269 |
$user = get_current_user_id();
|
270 |
} else {
|
271 |
+
parse_str( $_POST['form'], $form );
|
272 |
if ( ! empty( $form['edd_email'] ) ) {
|
273 |
$user = urldecode( $form['edd_email'] );
|
274 |
}
|
315 |
|
316 |
$download_id = absint( $_POST['download_id'] );
|
317 |
$quantity = absint( $_POST['quantity'] );
|
318 |
+
$options = json_decode( stripslashes( $_POST['options'] ), true );
|
319 |
|
320 |
edd_set_cart_item_quantity( $download_id, absint( $_POST['quantity'] ), $options );
|
321 |
$total = edd_get_cart_total();
|
includes/cart/actions.php
CHANGED
@@ -141,7 +141,7 @@ add_action( 'edd_purchase_collection', 'edd_process_collection_purchase' );
|
|
141 |
function edd_process_cart_update( $data ) {
|
142 |
|
143 |
foreach( $data['edd-cart-downloads'] as $key => $cart_download_id ) {
|
144 |
-
$options =
|
145 |
$quantity = absint( $data['edd-cart-download-' . $key . '-quantity'] );
|
146 |
edd_set_cart_item_quantity( $cart_download_id, $quantity, $options );
|
147 |
}
|
141 |
function edd_process_cart_update( $data ) {
|
142 |
|
143 |
foreach( $data['edd-cart-downloads'] as $key => $cart_download_id ) {
|
144 |
+
$options = json_decode( stripslashes( $data['edd-cart-download-' . $key . '-options'] ), true );
|
145 |
$quantity = absint( $data['edd-cart-download-' . $key . '-quantity'] );
|
146 |
edd_set_cart_item_quantity( $cart_download_id, $quantity, $options );
|
147 |
}
|
includes/cart/functions.php
CHANGED
@@ -1053,7 +1053,7 @@ function edd_is_cart_saved() {
|
|
1053 |
return false;
|
1054 |
|
1055 |
// Check that the saved cart is not the same as the current cart
|
1056 |
-
if (
|
1057 |
return false;
|
1058 |
|
1059 |
return true;
|
@@ -1083,7 +1083,7 @@ function edd_save_cart() {
|
|
1083 |
|
1084 |
} else {
|
1085 |
|
1086 |
-
$cart =
|
1087 |
|
1088 |
setcookie( 'edd_saved_cart', $cart, time()+3600*24*7, COOKIEPATH, COOKIE_DOMAIN );
|
1089 |
setcookie( 'edd_cart_token', $token, time()+3600*24*7, COOKIEPATH, COOKIE_DOMAIN );
|
@@ -1158,7 +1158,7 @@ function edd_restore_cart() {
|
|
1158 |
return new WP_Error( 'invalid_cart_token', __( 'The cart cannot be restored. Invalid token.', 'easy-digital-downloads' ) );
|
1159 |
}
|
1160 |
|
1161 |
-
$saved_cart =
|
1162 |
|
1163 |
setcookie( 'edd_saved_cart', '', time()-3600, COOKIEPATH, COOKIE_DOMAIN );
|
1164 |
setcookie( 'edd_cart_token', '', time()-3600, COOKIEPATH, COOKIE_DOMAIN );
|
1053 |
return false;
|
1054 |
|
1055 |
// Check that the saved cart is not the same as the current cart
|
1056 |
+
if ( json_decode( stripslashes( $_COOKIE['edd_saved_cart'] ), true ) === EDD()->session->get( 'edd_cart' ) )
|
1057 |
return false;
|
1058 |
|
1059 |
return true;
|
1083 |
|
1084 |
} else {
|
1085 |
|
1086 |
+
$cart = json_encode( $cart );
|
1087 |
|
1088 |
setcookie( 'edd_saved_cart', $cart, time()+3600*24*7, COOKIEPATH, COOKIE_DOMAIN );
|
1089 |
setcookie( 'edd_cart_token', $token, time()+3600*24*7, COOKIEPATH, COOKIE_DOMAIN );
|
1158 |
return new WP_Error( 'invalid_cart_token', __( 'The cart cannot be restored. Invalid token.', 'easy-digital-downloads' ) );
|
1159 |
}
|
1160 |
|
1161 |
+
$saved_cart = json_decode( stripslashes( $saved_cart ), true );
|
1162 |
|
1163 |
setcookie( 'edd_saved_cart', '', time()-3600, COOKIEPATH, COOKIE_DOMAIN );
|
1164 |
setcookie( 'edd_cart_token', '', time()-3600, COOKIEPATH, COOKIE_DOMAIN );
|
includes/class-edd-download.php
CHANGED
@@ -244,6 +244,16 @@ class EDD_Download {
|
|
244 |
|
245 |
}
|
246 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
247 |
/**
|
248 |
* Retrieve the price
|
249 |
*
|
244 |
|
245 |
}
|
246 |
|
247 |
+
/**
|
248 |
+
* Retrieve the download name
|
249 |
+
*
|
250 |
+
* @since
|
251 |
+
* @return string
|
252 |
+
*/
|
253 |
+
public function get_name() {
|
254 |
+
return get_the_title( $this->ID );
|
255 |
+
}
|
256 |
+
|
257 |
/**
|
258 |
* Retrieve the price
|
259 |
*
|
includes/class-edd-html-elements.php
CHANGED
@@ -364,7 +364,7 @@ class EDD_HTML_Elements {
|
|
364 |
}
|
365 |
|
366 |
$class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
|
367 |
-
$output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr(
|
368 |
|
369 |
if ( $args['show_option_all'] ) {
|
370 |
if( $args['multiple'] ) {
|
@@ -481,13 +481,13 @@ class EDD_HTML_Elements {
|
|
481 |
$data = '';
|
482 |
if ( ! empty( $args['data'] ) ) {
|
483 |
foreach ( $args['data'] as $key => $value ) {
|
484 |
-
$data .= 'data-' .
|
485 |
}
|
486 |
}
|
487 |
|
488 |
-
$output = '<span id="edd-' .
|
489 |
|
490 |
-
$output .= '<label class="edd-label" for="' .
|
491 |
|
492 |
if ( ! empty( $args['desc'] ) ) {
|
493 |
$output .= '<span class="edd-description">' . esc_html( $args['desc'] ) . '</span>';
|
@@ -544,11 +544,11 @@ class EDD_HTML_Elements {
|
|
544 |
$disabled = ' disabled="disabled"';
|
545 |
}
|
546 |
|
547 |
-
$output = '<span id="edd-' .
|
548 |
|
549 |
-
$output .= '<label class="edd-label" for="' .
|
550 |
|
551 |
-
$output .= '<textarea name="' . esc_attr( $args['name'] ) . '" id="' .
|
552 |
|
553 |
if ( ! empty( $args['desc'] ) ) {
|
554 |
$output .= '<span class="edd-description">' . esc_html( $args['desc'] ) . '</span>';
|
364 |
}
|
365 |
|
366 |
$class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
|
367 |
+
$output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( edd_sanitize_key( str_replace( '-', '_', $args['id'] ) ) ) . '" class="edd-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '"'. $data_elements . '>';
|
368 |
|
369 |
if ( $args['show_option_all'] ) {
|
370 |
if( $args['multiple'] ) {
|
481 |
$data = '';
|
482 |
if ( ! empty( $args['data'] ) ) {
|
483 |
foreach ( $args['data'] as $key => $value ) {
|
484 |
+
$data .= 'data-' . edd_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" ';
|
485 |
}
|
486 |
}
|
487 |
|
488 |
+
$output = '<span id="edd-' . edd_sanitize_key( $args['name'] ) . '-wrap">';
|
489 |
|
490 |
+
$output .= '<label class="edd-label" for="' . edd_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>';
|
491 |
|
492 |
if ( ! empty( $args['desc'] ) ) {
|
493 |
$output .= '<span class="edd-description">' . esc_html( $args['desc'] ) . '</span>';
|
544 |
$disabled = ' disabled="disabled"';
|
545 |
}
|
546 |
|
547 |
+
$output = '<span id="edd-' . edd_sanitize_key( $args['name'] ) . '-wrap">';
|
548 |
|
549 |
+
$output .= '<label class="edd-label" for="' . edd_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>';
|
550 |
|
551 |
+
$output .= '<textarea name="' . esc_attr( $args['name'] ) . '" id="' . edd_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>';
|
552 |
|
553 |
if ( ! empty( $args['desc'] ) ) {
|
554 |
$output .= '<span class="edd-description">' . esc_html( $args['desc'] ) . '</span>';
|
includes/download-functions.php
CHANGED
@@ -164,9 +164,17 @@ function edd_price( $download_id = 0, $echo = true, $price_id = false ) {
|
|
164 |
$prices = edd_get_variable_prices( $download_id );
|
165 |
|
166 |
if ( false !== $price_id && isset( $prices[$price_id] ) ) {
|
167 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
} else {
|
|
|
169 |
$price = edd_get_lowest_price_option( $download_id );
|
|
|
170 |
}
|
171 |
|
172 |
$price = edd_sanitize_amount( $price );
|
164 |
$prices = edd_get_variable_prices( $download_id );
|
165 |
|
166 |
if ( false !== $price_id && isset( $prices[$price_id] ) ) {
|
167 |
+
|
168 |
+
$price = edd_get_price_option_amount( $download_id, $price_id );
|
169 |
+
|
170 |
+
} elseif( $default = edd_get_default_variable_price( $download_id ) ) {
|
171 |
+
|
172 |
+
$price = edd_get_price_option_amount( $download_id, $default );
|
173 |
+
|
174 |
} else {
|
175 |
+
|
176 |
$price = edd_get_lowest_price_option( $download_id );
|
177 |
+
|
178 |
}
|
179 |
|
180 |
$price = edd_sanitize_amount( $price );
|
includes/formatting.php
CHANGED
@@ -210,3 +210,26 @@ function edd_currency_decimal_filter( $decimals = 2 ) {
|
|
210 |
}
|
211 |
add_filter( 'edd_sanitize_amount_decimals', 'edd_currency_decimal_filter' );
|
212 |
add_filter( 'edd_format_amount_decimals', 'edd_currency_decimal_filter' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
210 |
}
|
211 |
add_filter( 'edd_sanitize_amount_decimals', 'edd_currency_decimal_filter' );
|
212 |
add_filter( 'edd_format_amount_decimals', 'edd_currency_decimal_filter' );
|
213 |
+
|
214 |
+
/**
|
215 |
+
* Sanitizes a string key for EDD Settings
|
216 |
+
*
|
217 |
+
* Keys are used as internal identifiers. Alphanumeric characters, dashes, underscores, stops, colons and slashes are allowed
|
218 |
+
*
|
219 |
+
* @since 2.5.8
|
220 |
+
* @param string $key String key
|
221 |
+
* @return string Sanitized key
|
222 |
+
*/
|
223 |
+
function edd_sanitize_key( $key ) {
|
224 |
+
$raw_key = $key;
|
225 |
+
$key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key );
|
226 |
+
|
227 |
+
/**
|
228 |
+
* Filter a sanitized key string.
|
229 |
+
*
|
230 |
+
* @since 2.5.8
|
231 |
+
* @param string $key Sanitized key.
|
232 |
+
* @param string $raw_key The key prior to sanitization.
|
233 |
+
*/
|
234 |
+
return apply_filters( 'edd_sanitize_key', $key, $raw_key );
|
235 |
+
}
|
includes/payments/class-edd-payment.php
CHANGED
@@ -878,7 +878,7 @@ final class EDD_Payment {
|
|
878 |
$defaults = array(
|
879 |
'quantity' => 1,
|
880 |
'price_id' => false,
|
881 |
-
'item_price' =>
|
882 |
'discount' => 0,
|
883 |
'tax' => 0.00,
|
884 |
'fees' => array(),
|
@@ -887,7 +887,7 @@ final class EDD_Payment {
|
|
887 |
$args = wp_parse_args( apply_filters( 'edd_payment_add_download_args', $args, $download->ID ), $defaults );
|
888 |
|
889 |
// Allow overriding the price
|
890 |
-
if( $args['item_price'] ) {
|
891 |
$item_price = $args['item_price'];
|
892 |
} else {
|
893 |
// Deal with variable pricing
|
@@ -1792,7 +1792,7 @@ final class EDD_Payment {
|
|
1792 |
private function setup_transaction_id() {
|
1793 |
$transaction_id = $this->get_meta( '_edd_payment_transaction_id', true );
|
1794 |
|
1795 |
-
if ( empty( $transaction_id ) ) {
|
1796 |
|
1797 |
$gateway = $this->gateway;
|
1798 |
$transaction_id = apply_filters( 'edd_get_payment_transaction_id-' . $gateway, $this->ID );
|
878 |
$defaults = array(
|
879 |
'quantity' => 1,
|
880 |
'price_id' => false,
|
881 |
+
'item_price' => false,
|
882 |
'discount' => 0,
|
883 |
'tax' => 0.00,
|
884 |
'fees' => array(),
|
887 |
$args = wp_parse_args( apply_filters( 'edd_payment_add_download_args', $args, $download->ID ), $defaults );
|
888 |
|
889 |
// Allow overriding the price
|
890 |
+
if( false !== $args['item_price'] ) {
|
891 |
$item_price = $args['item_price'];
|
892 |
} else {
|
893 |
// Deal with variable pricing
|
1792 |
private function setup_transaction_id() {
|
1793 |
$transaction_id = $this->get_meta( '_edd_payment_transaction_id', true );
|
1794 |
|
1795 |
+
if ( empty( $transaction_id ) || (int) $transaction_id === (int) $this->ID ) {
|
1796 |
|
1797 |
$gateway = $this->gateway;
|
1798 |
$transaction_id = apply_filters( 'edd_get_payment_transaction_id-' . $gateway, $this->ID );
|
includes/process-download.php
CHANGED
@@ -159,7 +159,8 @@ function edd_process_download() {
|
|
159 |
case 'direct' :
|
160 |
default:
|
161 |
|
162 |
-
$direct
|
|
|
163 |
|
164 |
if ( ( ! isset( $file_details['scheme'] ) || ! in_array( $file_details['scheme'], $schemes ) ) && isset( $file_details['path'] ) && file_exists( $requested_file ) ) {
|
165 |
|
@@ -209,7 +210,7 @@ function edd_process_download() {
|
|
209 |
} elseif ( $direct && ( stristr( getenv( 'SERVER_SOFTWARE' ), 'nginx' ) || stristr( getenv( 'SERVER_SOFTWARE' ), 'cherokee' ) ) ) {
|
210 |
|
211 |
// We need a path relative to the domain
|
212 |
-
$file_path = str_ireplace( $_SERVER['DOCUMENT_ROOT'], '', $file_path );
|
213 |
header( "X-Accel-Redirect: /$file_path" );
|
214 |
|
215 |
}
|
159 |
case 'direct' :
|
160 |
default:
|
161 |
|
162 |
+
$direct = false;
|
163 |
+
$file_path = $requested_file;
|
164 |
|
165 |
if ( ( ! isset( $file_details['scheme'] ) || ! in_array( $file_details['scheme'], $schemes ) ) && isset( $file_details['path'] ) && file_exists( $requested_file ) ) {
|
166 |
|
210 |
} elseif ( $direct && ( stristr( getenv( 'SERVER_SOFTWARE' ), 'nginx' ) || stristr( getenv( 'SERVER_SOFTWARE' ), 'cherokee' ) ) ) {
|
211 |
|
212 |
// We need a path relative to the domain
|
213 |
+
$file_path = str_ireplace( realpath( $_SERVER['DOCUMENT_ROOT'] ), '', $file_path );
|
214 |
header( "X-Accel-Redirect: /$file_path" );
|
215 |
|
216 |
}
|
includes/scripts.php
CHANGED
@@ -48,6 +48,8 @@ function edd_load_scripts() {
|
|
48 |
'checkout_nonce' => wp_create_nonce( 'edd_checkout_nonce' ),
|
49 |
'currency_sign' => edd_currency_filter(''),
|
50 |
'currency_pos' => edd_get_option( 'currency_position', 'before' ),
|
|
|
|
|
51 |
'no_gateway' => __( 'Please select a payment method', 'easy-digital-downloads' ),
|
52 |
'no_discount' => __( 'Please enter a discount code', 'easy-digital-downloads' ), // Blank discount code message
|
53 |
'enter_discount' => __( 'Enter discount', 'easy-digital-downloads' ),
|
48 |
'checkout_nonce' => wp_create_nonce( 'edd_checkout_nonce' ),
|
49 |
'currency_sign' => edd_currency_filter(''),
|
50 |
'currency_pos' => edd_get_option( 'currency_position', 'before' ),
|
51 |
+
'decimal_separator' => edd_get_option( 'decimal_separator', '.' ),
|
52 |
+
'thousands_separator'=> edd_get_option( 'thousands_separator', ',' ),
|
53 |
'no_gateway' => __( 'Please select a payment method', 'easy-digital-downloads' ),
|
54 |
'no_discount' => __( 'Please enter a discount code', 'easy-digital-downloads' ), // Blank discount code message
|
55 |
'enter_discount' => __( 'Enter discount', 'easy-digital-downloads' ),
|
includes/shortcodes.php
CHANGED
@@ -642,10 +642,10 @@ function edd_receipt_shortcode( $atts, $content = null ) {
|
|
642 |
$session = edd_get_purchase_session();
|
643 |
if ( isset( $_GET['payment_key'] ) ) {
|
644 |
$payment_key = urldecode( $_GET['payment_key'] );
|
645 |
-
} elseif ( $edd_receipt_args['payment_key'] ) {
|
646 |
-
$payment_key = $edd_receipt_args['payment_key'];
|
647 |
} else if ( $session ) {
|
648 |
$payment_key = $session['purchase_key'];
|
|
|
|
|
649 |
}
|
650 |
|
651 |
// No key found
|
642 |
$session = edd_get_purchase_session();
|
643 |
if ( isset( $_GET['payment_key'] ) ) {
|
644 |
$payment_key = urldecode( $_GET['payment_key'] );
|
|
|
|
|
645 |
} else if ( $session ) {
|
646 |
$payment_key = $session['purchase_key'];
|
647 |
+
} elseif ( $edd_receipt_args['payment_key'] ) {
|
648 |
+
$payment_key = $edd_receipt_args['payment_key'];
|
649 |
}
|
650 |
|
651 |
// No key found
|
includes/user-functions.php
CHANGED
@@ -477,6 +477,8 @@ function edd_get_customer_address( $user_id = 0 ) {
|
|
477 |
*
|
478 |
* @access public
|
479 |
* @since 1.8.8
|
|
|
|
|
480 |
* @return void
|
481 |
*/
|
482 |
function edd_new_user_notification( $user_id = 0, $user_data = array() ) {
|
@@ -494,7 +496,7 @@ function edd_new_user_notification( $user_id = 0, $user_data = array() ) {
|
|
494 |
|
495 |
$message = sprintf( __( 'Username: %s' ), $user_data['user_login'] ) . "\r\n";
|
496 |
$message .= sprintf( __( 'Password: %s' ), __( '[Password entered at checkout]', 'easy-digital-downloads' ) ) . "\r\n";
|
497 |
-
$message .= wp_login_url() . "\r\n";
|
498 |
|
499 |
wp_mail( $user_data['user_email'], sprintf( __( '[%s] Your username and password' ), $blogname ), $message );
|
500 |
|
477 |
*
|
478 |
* @access public
|
479 |
* @since 1.8.8
|
480 |
+
* @param int $user_id
|
481 |
+
* @param array $user_data
|
482 |
* @return void
|
483 |
*/
|
484 |
function edd_new_user_notification( $user_id = 0, $user_data = array() ) {
|
496 |
|
497 |
$message = sprintf( __( 'Username: %s' ), $user_data['user_login'] ) . "\r\n";
|
498 |
$message .= sprintf( __( 'Password: %s' ), __( '[Password entered at checkout]', 'easy-digital-downloads' ) ) . "\r\n";
|
499 |
+
$message .= '<a href="' . wp_login_url() . '"> ' . esc_attr__( 'Click Here to Log In', 'easy-digital-downloads' ) . ' »</a>' . "\r\n";
|
500 |
|
501 |
wp_mail( $user_data['user_email'], sprintf( __( '[%s] Your username and password' ), $blogname ), $message );
|
502 |
|
languages/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
-
# Easy Digital Downloads
|
2 |
|
3 |
-
To help translate, review, or improve a translation,join our
|
4 |
-
https://
|
5 |
|
6 |
-
More info at
|
7 |
|
1 |
+
# Easy Digital Downloads i18n #
|
2 |
|
3 |
+
To help translate, review, or improve a translation, join our Translations Community at
|
4 |
+
https://translate.wordpress.org/projects/wp-plugins/easy-digital-downloads
|
5 |
|
6 |
+
More info at https://make.wordpress.org/polyglots/
|
7 |
|
readme.txt
CHANGED
@@ -6,7 +6,7 @@ Donate link: https://pippinsplugins.com/support-the-site
|
|
6 |
Tags: download, downloads, e-store, eshop, digital downloads, e-downloads, ecommerce, e commerce, e-commerce, selling, wp-ecommerce, wp ecommerce, mordauk, Pippin Williamson, pippinsplugins
|
7 |
Requires at least: 4.0
|
8 |
Tested up to: 4.5
|
9 |
-
Stable Tag: 2.5.
|
10 |
|
11 |
License: GNU Version 2 or Any Later Version
|
12 |
|
@@ -214,6 +214,24 @@ Yes, through the addition of one or more of the add-on payment gateways, you can
|
|
214 |
|
215 |
== Changelog ==
|
216 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
217 |
= 2.5.7, February 10, 2016 =
|
218 |
|
219 |
* New: Added refund() method to EDD_Payment class
|
6 |
Tags: download, downloads, e-store, eshop, digital downloads, e-downloads, ecommerce, e commerce, e-commerce, selling, wp-ecommerce, wp ecommerce, mordauk, Pippin Williamson, pippinsplugins
|
7 |
Requires at least: 4.0
|
8 |
Tested up to: 4.5
|
9 |
+
Stable Tag: 2.5.8
|
10 |
|
11 |
License: GNU Version 2 or Any Later Version
|
12 |
|
214 |
|
215 |
== Changelog ==
|
216 |
|
217 |
+
= 2.5.8, February 18, 2016 =
|
218 |
+
|
219 |
+
* Fix: Transaction ID detection not working properly for old payment records that stored transaction ID in notes
|
220 |
+
* Fix: 100% discount codes not properly removing billing fields when decimal separator is not a period
|
221 |
+
* Fix: [edd_receipt payment_key="false"] results in error retrieving receipt message
|
222 |
+
* Fix: Unused variable in Javascript
|
223 |
+
* Fix: File downloads failing with Force download method on nginx
|
224 |
+
* Fix: Undefined variable $file_path during file downloads on some servers
|
225 |
+
* Fix: Incorrect inline PHP documentation
|
226 |
+
* Fix: Settings with some non-alphanumeric keys not saved properly
|
227 |
+
* Fix: Price override in add_download() method of EDD_Payment does not respect price of 0
|
228 |
+
* Fix: Dash incorrectly shown after product name on the receipt page
|
229 |
+
* Fix: Missing P tag on View Order Details screen
|
230 |
+
* Tweak: Replace usage of $edd_options with edd_get_option() helper function
|
231 |
+
* Tweak: URL in New User Notification email now linked
|
232 |
+
* Tweak: edd_price() now displays the value of the Default price option
|
233 |
+
* New: Introduced edd_payment_currency_default filter
|
234 |
+
|
235 |
= 2.5.7, February 10, 2016 =
|
236 |
|
237 |
* New: Added refund() method to EDD_Payment class
|
templates/checkout_cart.php
CHANGED
@@ -43,7 +43,7 @@ global $post; ?>
|
|
43 |
<?php if( edd_item_quantities_enabled() ) : ?>
|
44 |
<input type="number" min="1" step="1" name="edd-cart-download-<?php echo $key; ?>-quantity" data-key="<?php echo $key; ?>" class="edd-input edd-item-quantity" value="<?php echo edd_get_cart_item_quantity( $item['id'], $item['options'] ); ?>"/>
|
45 |
<input type="hidden" name="edd-cart-downloads[]" value="<?php echo $item['id']; ?>"/>
|
46 |
-
<input type="hidden" name="edd-cart-download-<?php echo $key; ?>-options" value="<?php echo esc_attr(
|
47 |
<?php endif; ?>
|
48 |
<?php do_action( 'edd_cart_actions', $item, $key ); ?>
|
49 |
<a class="edd_cart_remove_item_btn" href="<?php echo esc_url( edd_remove_item_url( $key ) ); ?>"><?php _e( 'Remove', 'easy-digital-downloads' ); ?></a>
|
43 |
<?php if( edd_item_quantities_enabled() ) : ?>
|
44 |
<input type="number" min="1" step="1" name="edd-cart-download-<?php echo $key; ?>-quantity" data-key="<?php echo $key; ?>" class="edd-input edd-item-quantity" value="<?php echo edd_get_cart_item_quantity( $item['id'], $item['options'] ); ?>"/>
|
45 |
<input type="hidden" name="edd-cart-downloads[]" value="<?php echo $item['id']; ?>"/>
|
46 |
+
<input type="hidden" name="edd-cart-download-<?php echo $key; ?>-options" value="<?php echo esc_attr( json_encode( $item['options'] ) ); ?>"/>
|
47 |
<?php endif; ?>
|
48 |
<?php do_action( 'edd_cart_actions', $item, $key ); ?>
|
49 |
<a class="edd_cart_remove_item_btn" href="<?php echo esc_url( edd_remove_item_url( $key ) ); ?>"><?php _e( 'Remove', 'easy-digital-downloads' ); ?></a>
|
templates/shortcode-receipt.php
CHANGED
@@ -149,7 +149,7 @@ $status = edd_get_payment_status( $payment, true );
|
|
149 |
|
150 |
<div class="edd_purchase_receipt_product_name">
|
151 |
<?php echo esc_html( $item['name'] ); ?>
|
152 |
-
<?php if( ! is_null( $price_id ) ) : ?>
|
153 |
<span class="edd_purchase_receipt_price_name"> – <?php echo edd_get_price_option_name( $item['id'], $price_id, $payment->ID ); ?></span>
|
154 |
<?php endif; ?>
|
155 |
</div>
|
149 |
|
150 |
<div class="edd_purchase_receipt_product_name">
|
151 |
<?php echo esc_html( $item['name'] ); ?>
|
152 |
+
<?php if( edd_has_variable_prices( $item['id'] ) && ! is_null( $price_id ) ) : ?>
|
153 |
<span class="edd_purchase_receipt_price_name"> – <?php echo edd_get_price_option_name( $item['id'], $price_id, $payment->ID ); ?></span>
|
154 |
<?php endif; ?>
|
155 |
</div>
|