LearnPress – WordPress LMS Plugin - Version 4.1.6.6

Version Description

(2022-06-13) = ~ Fixed: security. ~ Added: option "Enable loading ajax Courses on the Archive Course page". ~ Added: option "No Page load Courses Ajax".

Download this release

Release Info

Developer ThimPress
Plugin Icon 128x128 LearnPress – WordPress LMS Plugin
Version 4.1.6.6
Comparing to
See all releases

Code changes from version 4.1.6.5 to 4.1.6.6

Files changed (121) hide show
  1. assets/js/admin/admin.min.js +1 -1
  2. assets/js/dist/frontend/checkout.js +6 -1
  3. assets/js/dist/frontend/checkout.min.js +1 -1
  4. assets/js/dist/frontend/courses.js +31 -11
  5. assets/js/dist/frontend/courses.min.js +1 -1
  6. assets/src/apps/js/frontend/checkout.js +5 -1
  7. assets/src/apps/js/frontend/courses.js +29 -10
  8. assets/src/js/admin/admin.js +15 -1
  9. config/settings/course.php +175 -0
  10. inc/abstract-settings.php +1 -1
  11. inc/abstracts/abstract-assets.php +1 -0
  12. inc/admin/class-lp-admin-ajax.php +0 -681
  13. inc/admin/class-lp-admin-assets.php +4 -2
  14. inc/admin/class-lp-setup-wizard.php +4 -4
  15. inc/admin/lp-admin-actions.php +10 -2
  16. inc/admin/lp-admin-functions.php +1 -1
  17. inc/admin/meta-box/class-lp-meta-box-helper.php +2 -2
  18. inc/admin/meta-box/fields/checkbox.php +14 -21
  19. inc/admin/meta-box/fields/course-permalink.php +1 -1
  20. inc/admin/meta-box/fields/list-emails.php +9 -7
  21. inc/admin/settings/class-lp-settings-payments.php +1 -1
  22. inc/admin/settings/class-lp-settings-profile.php +1 -1
  23. inc/admin/settings/email-groups/class-lp-settings-emails-group.php +1 -1
  24. inc/admin/sub-menus/class-lp-submenu-settings.php +2 -2
  25. inc/admin/sub-menus/class-lp-submenu-statistics.php +0 -25
  26. inc/admin/views/addons/html-themes.php +1 -1
  27. inc/admin/views/backend-user-profile.php +1 -1
  28. inc/admin/views/meta-boxes/fields/select.php +8 -4
  29. inc/admin/views/meta-boxes/order/details.php +2 -2
  30. inc/admin/views/meta-boxes/quiz/settings.php +1 -1
  31. inc/admin/views/setup/content.php +5 -5
  32. inc/admin/views/setup/setup-paypal.php +1 -1
  33. inc/admin/views/setup/steps/currency.php +3 -2
  34. inc/admin/views/setup/steps/pages.php +1 -1
  35. inc/admin/views/tools/html-cache.php +1 -1
  36. inc/admin/views/tools/html-cron.php +1 -1
  37. inc/admin/views/user/courses.php +2 -2
  38. inc/attributes/course.php +11 -9
  39. inc/class-lp-ajax.php +7 -3
  40. inc/class-lp-assets.php +3 -5
  41. inc/class-lp-checkout.php +3 -3
  42. inc/class-lp-debug.php +2 -2
  43. inc/class-lp-emails.php +1 -1
  44. inc/class-lp-forms-handler.php +2 -2
  45. inc/class-lp-hard-cache.php +1 -1
  46. inc/class-lp-helper.php +14 -3
  47. inc/class-lp-install.php +4 -2
  48. inc/class-lp-page-controller.php +186 -54
  49. inc/class-lp-query-search.php +5 -0
  50. inc/class-lp-query.php +3 -3
  51. inc/class-lp-schedules.php +0 -10
  52. inc/class-lp-settings.php +1 -1
  53. inc/course/abstract-course.php +4 -4
  54. inc/course/lp-course-functions.php +17 -12
  55. inc/curds/class-lp-user-curd.php +1 -1
  56. inc/custom-post-types/abstract.php +1 -224
  57. inc/custom-post-types/order.php +8 -6
  58. inc/emails/admin/class-lp-email-cancelled-order-admin.php +1 -1
  59. inc/emails/admin/class-lp-email-completed-order-admin.php +1 -1
  60. inc/emails/admin/class-lp-email-enrolled-course-admin.php +1 -1
  61. inc/emails/admin/class-lp-email-finished-course-admin.php +1 -1
  62. inc/emails/admin/class-lp-email-new-order-admin.php +1 -1
  63. inc/emails/class-lp-email.php +7 -7
  64. inc/external-plugin/elementor/widgets/login-form.php +1 -1
  65. inc/external-plugin/elementor/widgets/register-form.php +1 -1
  66. inc/gateways/class-lp-gateway-abstract.php +1 -1
  67. inc/gateways/paypal/class-lp-gateway-paypal-basic.php +22 -11
  68. inc/gateways/paypal/class-lp-gateway-paypal-security.php +28 -19
  69. inc/gateways/paypal/class-lp-gateway-paypal.php +1 -1
  70. inc/jwt/class-jwt-auth.php +1 -2
  71. inc/jwt/includes/class-jwt-public.php +0 -73
  72. inc/jwt/rest-api/version1/class-lp-rest-courses-v1-controller.php +2 -2
  73. inc/jwt/rest-api/version1/class-lp-rest-lessons-v1-controller.php +22 -0
  74. inc/jwt/rest-api/version1/class-lp-rest-posts-controller.php +5 -5
  75. inc/jwt/rest-api/version1/class-lp-rest-users-v1-controller.php +1 -1
  76. inc/lesson/lp-lesson-functions.php +2 -2
  77. inc/libraries/wp-background-process/classes/wp-async-request.php +1 -1
  78. inc/lp-core-functions.php +38 -54
  79. inc/lp-deprecated.php +43 -43
  80. inc/lp-template-functions.php +11 -11
  81. inc/lp-webhooks.php +1 -1
  82. inc/order/class-lp-order.php +4 -4
  83. inc/order/lp-order-functions.php +1 -1
  84. inc/question/class-lp-question.php +3 -2
  85. inc/quiz/class-lp-quiz.php +6 -2
  86. inc/quiz/lp-quiz-functions.php +1 -1
  87. inc/rest-api/v1/frontend/class-lp-rest-courses-controller.php +49 -17
  88. inc/rest-api/v1/frontend/class-lp-rest-lazy-load-controller.php +2 -2
  89. inc/rest-api/v1/frontend/class-lp-rest-settings-controller.php +3 -3
  90. inc/rest-api/v1/frontend/class-lp-rest-users-controller.php +3 -3
  91. inc/settings/abstract-settings-page.php +127 -0
  92. inc/settings/class-lp-settings-courses.php +84 -0
  93. inc/templates/class-lp-template-course.php +33 -29
  94. inc/templates/class-lp-template-profile.php +3 -3
  95. inc/user-item/class-lp-user-item-quiz.php +1 -1
  96. inc/user/class-lp-profile-tabs.php +2 -2
  97. inc/user/class-lp-profile.php +15 -13
  98. inc/user/class-lp-user.php +1 -1
  99. inc/user/lp-user-functions.php +12 -40
  100. languages/learnpress.pot +727 -703
  101. learnpress.php +6 -3
  102. readme.txt +6 -1
  103. templates/archive-course.php +7 -1
  104. templates/content-quiz/js.php +1 -1
  105. templates/content-quiz/title.php +1 -1
  106. templates/loop/course/instructor.php +0 -1
  107. templates/loop/course/students.php +4 -1
  108. templates/profile/tabs/settings/basic-information.php +1 -1
  109. templates/single-course/buttons/continue.php +1 -1
  110. templates/single-course/buttons/external-link.php +4 -1
  111. templates/single-course/buttons/retry.php +4 -1
  112. templates/single-course/content-item.php +6 -2
  113. templates/single-course/content-item/popup-footer.php +2 -2
  114. templates/single-course/instructor.php +4 -1
  115. templates/single-course/meta/duration.php +1 -1
  116. templates/single-course/meta/instructor.php +4 -1
  117. templates/single-course/section/item-meta.php +6 -2
  118. templates/single-course/sidebar/user-time.php +2 -2
  119. templates/single-course/tabs/curriculum.php +1 -1
  120. templates/single-course/tabs/instructor.php +4 -1
  121. templates/single-course/tabs/overview.php +5 -3
assets/js/admin/admin.min.js CHANGED
@@ -1 +1 @@
1
- !function(e){const t=function(){e.ajax({url:"",data:{"lp-ajax":"toggle_item_preview",item_id:this.value,previewable:this.checked?"yes":"no",nonce:e(this).attr("data-nonce")},dataType:"text",success:function(e){e=LP.parseJSON(e)}})},a=function(t){const a=e(this).addClass("disabled");t.preventDefault(),e.post({url:a.attr("href"),data:{"lp-ajax":"create-pages"},dataType:"text",success:function(e){const t=a.closest(".lp-notice").html("<p>"+e+"</p>");setTimeout((function(){t.fadeOut()}),2e3)}})},n=function(t){t.preventDefault();e(this).closest(".lp-upgrade-notice").fadeOut(),e.post({url:"",data:{"lp-hide-upgrade-message":"yes"},success:function(e){}})},o=function(t){if(e(t.target).hasClass("buy-now"))return;t.preventDefault();const a=e(this).closest(".plugin-card");e(this).hasClass("updating-message")||(e(this).addClass("updating-message button-working disabled"),e.ajax({url:e(this).attr("href"),data:{},success:function(t){e.ajax({url:window.location.href,success:function(t){const n=e(t).find("#"+a.attr("id"));n.length?a.replaceWith(n):a.find(".plugin-action-buttons a").removeClass("updating-message button-working").html(learn_press_admin_localize.plugin_installed)}})}}))},l=function(e){return e.preventDefault(),!1};e.fn._filter_post_by_author=function(){const t=e("#post-search-input");if(!t.length)return;const a=e(t[0].form),n=e('<select name="author" id="author"></select>').insertAfter(t).select2({ajax:{url:window.location.href+"&lp-ajax=search-authors",dataType:"json",s:""},placeholder:"Search by user",minimumInputLength:3,allowClear:!0}).on("select2:select",(function(){e('input[name="author"]').val(n.val())}));a.on("submit",(function(){window.location.href.removeQueryVar("author").addQueryVar("author",n.val())}))};const s=()=>{e(".lp-button-upgrade").each((function(){e(this).on("click",(function(t){t.preventDefault(),e("#lp-update-db-modal").removeClass("lp-update-db-modal__hidden")}))})),e(".lp-update-db-modal__button").on("click",(function(t){t.preventDefault();const a=e(this),n=a.text(),o=a.data("loading"),l=e(".lp-update-db-modal__content-text").data("text");a.addClass("loading"),a.text(o);const s=()=>{e.ajax({url:lpGlobalSettings.ajax+"?action=lp_update_database",method:"GET",success(t){if("success"===t.status)return a.text(n),e(".lp-update-db-modal__content").addClass("lp-update-db-modal__success"),e(".lp-update-db-modal__content-text > h3").text(l),a.removeClass("loading"),!1;s()}})};s()}));e(".lp-update-db-modal__cancel").on("click",(function(t){t.preventDefault(),e("#lp-update-db-modal").addClass("lp-update-db-modal__hidden")}))},i=()=>{e(".lp-meta-box__file").each((t,a)=>{let n;const o=e(a).find(".lp-meta-box__file_input"),l=e(a).find(".lp-meta-box__file_list"),s=e(a).find(".btn-upload"),i=!!e(a).data("multil");e(s).on("click",e=>{e.preventDefault(),n||(n=wp.media({states:[new wp.media.controller.Library({filterable:"all",multiple:i})]}),n.on("select",(function(){const e=n.state().get("selection");let t=o.val();e.forEach((function(e){if((e=e.toJSON()).id)if(i?t=t?t+","+e.id:e.id:(t=e.id,l.empty()),"image"===e.type){const t=e.sizes&&e.sizes.thumbnail?e.sizes.thumbnail.url:e.url;l.append('<li class="lp-meta-box__file_list-item image" data-attachment_id="'+e.id+'"><img src="'+t+'" /><ul class="actions"><li><a href="#" class="delete"></a></li></ul></li>')}else l.append('<li class="lp-meta-box__file_list-item image" data-attachment_id="'+e.id+'"><img class="is_file" src="'+e.icon+'" /><span>'+e.filename+'</span><ul class="actions"><li><a href="#" class="delete"></a></li></ul></li>')})),c(),o.val(t)}))),n.open()}),i&&l.sortable({items:"li.image",cursor:"move",scrollSensitivity:40,forcePlaceholderSize:!0,forceHelperSize:!1,helper:"clone",opacity:.65,placeholder:"lp-metabox-sortable-placeholder",start(e,t){t.item.css("background-color","#f6f6f6")},stop(e,t){t.item.removeAttr("style")},update(){let t="";l.find("li.image").css("cursor","default").each((function(){const a=e(this).attr("data-attachment_id");t=t+a+","})),c(),o.val(t)}});const c=()=>{e(l).find("li.image").each((t,a)=>{e(a).find("a.delete").on("click",(function(){if(e(a).remove(),i){let t="";e(l).find("li.image").css("cursor","default").each((function(){const a=e(this).attr("data-attachment_id");t=t+a+","})),o.val(t)}else o.val("");return!1}))})};c()})};e(document).ready((function(){if(i(),s(),e(".learn-press-dropdown-pages").LP("DropdownPages"),e(".learn-press-advertisement-slider").LP("Advertisement","a","s").appendTo(e("#wpbody-content")),e(".learn-press-toggle-item-preview").on("change",t),e(".learn-press-tip").LP("QuickTip"),e(document).on("click","#learn-press-create-pages",a).on("click",".lp-upgrade-notice .close-notice",n).on("click",".plugin-action-buttons a",o).on("click","[data-remove-confirm]",l).on("mousedown",".lp-sortable-handle",(function(t){e("html, body").addClass("lp-item-moving"),e(t.target).closest(".lp-sortable-handle").css("cursor","inherit")})).on("mouseup",(function(t){e("html, body").removeClass("lp-item-moving"),e(".lp-sortable-handle").css("cursor","")})),e("#order-export__section").length){document.querySelectorAll(".tabs");const t=document.querySelectorAll(".tab"),a=document.querySelectorAll(".panel");function c(e){for(let e=0;e<t.length;e++)t[e].classList.remove("active");for(let e=0;e<a.length;e++)a[e].classList.remove("active");e.target.classList.add("active");const n=e.target.getAttribute("data-target");document.getElementById("panels").getElementsByClassName(n)[0].classList.add("active")}for(let e=0;e<t.length;e++)t[e].addEventListener("click",c,!1);const n=document.getElementById("myModal"),o=document.getElementById("order-export__button"),l=document.getElementsByClassName("close")[0];o.onclick=function(){n.style.display="block"},l.onclick=function(){n.style.display="none"},window.onclick=function(e){e.target==n&&(n.style.display="none")},e("#lp-invoice__content").length&&e("#lp-invoice__export").click((function(){const t=new jsPDF("p","pt","letter"),a={"#bypassme":(e,t)=>!0},n={top:80,bottom:60,left:40,width:522};t.fromHTML(e("#lp-invoice__content")[0],n.left,n.top,{width:n.width,elementHandlers:a},(function(e){const a=t.output("blob");window.open(URL.createObjectURL(a))}),n)})),e("#lp-invoice__update").click((function(){let t=e(this).data("id"),a=e('input[name="site_title"]'),n=e('input[name="order_date"]'),o=e('input[name="invoice_no"]'),l=e('input[name="order_customer"]'),s=e('input[name="order_email"]'),i=e('input[name="order_payment"]');a=a.is(":checked")?"check":"uncheck",n=n.is(":checked")?"check":"uncheck",o=o.is(":checked")?"check":"uncheck",l=l.is(":checked")?"check":"uncheck",s=s.is(":checked")?"check":"uncheck",i=i.is(":checked")?"check":"uncheck",e.ajax({type:"post",dataType:"html",url:"admin-ajax.php",data:{site_title:a,order_date:n,invoice_no:o,order_customer:l,order_email:s,order_id:t,order_payment:i,action:"learnpress_update_order_exports"},beforeSend(){e(".export-options__loading").addClass("active")},success(t){e("#lp-invoice__content").html(""),e("#lp-invoice__content").append(t),e(".export-options__loading").removeClass("active"),e(".options-tab").removeClass("active"),e(".preview-tab").addClass("active"),e("#panels .export-options").removeClass("active"),e("#panels .pdf-preview").addClass("active")},error(e,t,a){console.log("The following error occured: "+t,a)}})}))}if(e.fn._filter_post_by_author(),window.location.hash){const t=window.location.hash;if("#_lp_passing_grade"==t){const a=document.querySelector(t);e("html, body").animate({scrollTop:e(t).offset().top},900,"swing"),a.parentNode.style.border="2px solid orangered"}}}))}(jQuery);
1
+ !function(e){const t=function(){e.ajax({url:"",data:{"lp-ajax":"toggle_item_preview",item_id:this.value,previewable:this.checked?"yes":"no",nonce:e(this).attr("data-nonce")},dataType:"text",success:function(e){e=LP.parseJSON(e)}})},a=function(t){const a=e(this).addClass("disabled");t.preventDefault(),e.post({url:a.attr("href"),data:{"lp-ajax":"create-pages"},dataType:"text",success:function(e){const t=a.closest(".lp-notice").html("<p>"+e+"</p>");setTimeout((function(){t.fadeOut()}),2e3)}})},n=function(t){t.preventDefault();e(this).closest(".lp-upgrade-notice").fadeOut(),e.post({url:"",data:{"lp-hide-upgrade-message":"yes"},success:function(e){}})},o=function(t){if(e(t.target).hasClass("buy-now"))return;t.preventDefault();const a=e(this).closest(".plugin-card");e(this).hasClass("updating-message")||(e(this).addClass("updating-message button-working disabled"),e.ajax({url:e(this).attr("href"),data:{},success:function(t){e.ajax({url:window.location.href,success:function(t){const n=e(t).find("#"+a.attr("id"));n.length?a.replaceWith(n):a.find(".plugin-action-buttons a").removeClass("updating-message button-working").html(learn_press_admin_localize.plugin_installed)}})}}))},l=function(e){return e.preventDefault(),!1};e.fn._filter_post_by_author=function(){const t=e("#post-search-input");if(!t.length)return;const a=e(t[0].form),n=e('<select name="author" id="author"></select>').insertAfter(t).select2({ajax:{url:window.location.href+"&lp-ajax=search-authors",dataType:"json",s:""},placeholder:wp.i18n.__("Search by user","learnpress"),minimumInputLength:3,allowClear:!0}).on("select2:select",(function(){e('input[name="author"]').val(n.val())}));a.on("submit",(function(){window.location.href.removeQueryVar("author").addQueryVar("author",n.val())}))};const s=()=>{e(".lp-button-upgrade").each((function(){e(this).on("click",(function(t){t.preventDefault(),e("#lp-update-db-modal").removeClass("lp-update-db-modal__hidden")}))})),e(".lp-update-db-modal__button").on("click",(function(t){t.preventDefault();const a=e(this),n=a.text(),o=a.data("loading"),l=e(".lp-update-db-modal__content-text").data("text");a.addClass("loading"),a.text(o);const s=()=>{e.ajax({url:lpGlobalSettings.ajax+"?action=lp_update_database",method:"GET",success(t){if("success"===t.status)return a.text(n),e(".lp-update-db-modal__content").addClass("lp-update-db-modal__success"),e(".lp-update-db-modal__content-text > h3").text(l),a.removeClass("loading"),!1;s()}})};s()}));e(".lp-update-db-modal__cancel").on("click",(function(t){t.preventDefault(),e("#lp-update-db-modal").addClass("lp-update-db-modal__hidden")}))},i=()=>{e(".lp-meta-box__file").each((t,a)=>{let n;const o=e(a).find(".lp-meta-box__file_input"),l=e(a).find(".lp-meta-box__file_list"),s=e(a).find(".btn-upload"),i=!!e(a).data("multil");e(s).on("click",e=>{e.preventDefault(),n||(n=wp.media({states:[new wp.media.controller.Library({filterable:"all",multiple:i})]}),n.on("select",(function(){const e=n.state().get("selection");let t=o.val();e.forEach((function(e){if((e=e.toJSON()).id)if(i?t=t?t+","+e.id:e.id:(t=e.id,l.empty()),"image"===e.type){const t=e.sizes&&e.sizes.thumbnail?e.sizes.thumbnail.url:e.url;l.append('<li class="lp-meta-box__file_list-item image" data-attachment_id="'+e.id+'"><img src="'+t+'" /><ul class="actions"><li><a href="#" class="delete"></a></li></ul></li>')}else l.append('<li class="lp-meta-box__file_list-item image" data-attachment_id="'+e.id+'"><img class="is_file" src="'+e.icon+'" /><span>'+e.filename+'</span><ul class="actions"><li><a href="#" class="delete"></a></li></ul></li>')})),c(),o.val(t)}))),n.open()}),i&&l.sortable({items:"li.image",cursor:"move",scrollSensitivity:40,forcePlaceholderSize:!0,forceHelperSize:!1,helper:"clone",opacity:.65,placeholder:"lp-metabox-sortable-placeholder",start(e,t){t.item.css("background-color","#f6f6f6")},stop(e,t){t.item.removeAttr("style")},update(){let t="";l.find("li.image").css("cursor","default").each((function(){const a=e(this).attr("data-attachment_id");t=t+a+","})),c(),o.val(t)}});const c=()=>{e(l).find("li.image").each((t,a)=>{e(a).find("a.delete").on("click",(function(){if(e(a).remove(),i){let t="";e(l).find("li.image").css("cursor","default").each((function(){const a=e(this).attr("data-attachment_id");t=t+a+","})),o.val(t)}else o.val("");return!1}))})};c()})};e(document).ready((function(){if(i(),s(),e(".learn-press-dropdown-pages").LP("DropdownPages"),e(".learn-press-advertisement-slider").LP("Advertisement","a","s").appendTo(e("#wpbody-content")),e(".learn-press-toggle-item-preview").on("change",t),e(".learn-press-tip").LP("QuickTip"),e(document).on("click","#learn-press-create-pages",a).on("click",".lp-upgrade-notice .close-notice",n).on("click",".plugin-action-buttons a",o).on("click","[data-remove-confirm]",l).on("mousedown",".lp-sortable-handle",(function(t){e("html, body").addClass("lp-item-moving"),e(t.target).closest(".lp-sortable-handle").css("cursor","inherit")})).on("mouseup",(function(t){e("html, body").removeClass("lp-item-moving"),e(".lp-sortable-handle").css("cursor","")})),e("#order-export__section").length){document.querySelectorAll(".tabs");const t=document.querySelectorAll(".tab"),a=document.querySelectorAll(".panel");function c(e){for(let e=0;e<t.length;e++)t[e].classList.remove("active");for(let e=0;e<a.length;e++)a[e].classList.remove("active");e.target.classList.add("active");const n=e.target.getAttribute("data-target");document.getElementById("panels").getElementsByClassName(n)[0].classList.add("active")}for(let e=0;e<t.length;e++)t[e].addEventListener("click",c,!1);const n=document.getElementById("myModal"),o=document.getElementById("order-export__button"),l=document.getElementsByClassName("close")[0];o.onclick=function(){n.style.display="block"},l.onclick=function(){n.style.display="none"},window.onclick=function(e){e.target==n&&(n.style.display="none")},e("#lp-invoice__content").length&&e("#lp-invoice__export").click((function(){const t=new jsPDF("p","pt","letter"),a={"#bypassme":(e,t)=>!0},n={top:80,bottom:60,left:40,width:522};t.fromHTML(e("#lp-invoice__content")[0],n.left,n.top,{width:n.width,elementHandlers:a},(function(e){const a=t.output("blob");window.open(URL.createObjectURL(a))}),n)})),e("#lp-invoice__update").click((function(){let t=e(this).data("id"),a=e('input[name="site_title"]'),n=e('input[name="order_date"]'),o=e('input[name="invoice_no"]'),l=e('input[name="order_customer"]'),s=e('input[name="order_email"]'),i=e('input[name="order_payment"]');a=a.is(":checked")?"check":"uncheck",n=n.is(":checked")?"check":"uncheck",o=o.is(":checked")?"check":"uncheck",l=l.is(":checked")?"check":"uncheck",s=s.is(":checked")?"check":"uncheck",i=i.is(":checked")?"check":"uncheck",e.ajax({type:"post",dataType:"html",url:"admin-ajax.php",data:{site_title:a,order_date:n,invoice_no:o,order_customer:l,order_email:s,order_id:t,order_payment:i,action:"learnpress_update_order_exports"},beforeSend(){e(".export-options__loading").addClass("active")},success(t){e("#lp-invoice__content").html(""),e("#lp-invoice__content").append(t),e(".export-options__loading").removeClass("active"),e(".options-tab").removeClass("active"),e(".preview-tab").addClass("active"),e("#panels .export-options").removeClass("active"),e("#panels .pdf-preview").addClass("active")},error(e,t,a){console.log("The following error occured: "+t,a)}})}))}if(e.fn._filter_post_by_author(),window.location.hash){const t=window.location.hash;if("#_lp_passing_grade"==t){const a=document.querySelector(t);e("html, body").animate({scrollTop:e(t).offset().top},900,"swing"),a.parentNode.style.border="2px solid orangered"}}e("input").on("click",(function(t){const a=e(t.target),n=a.attr("id").replace("learn_press_",""),o=e(".show_if_"+n);a.is(":checked")?o.show():o.hide()}))}))}(jQuery);
assets/js/dist/frontend/checkout.js CHANGED
@@ -176,7 +176,12 @@ var __webpack_exports__ = {};
176
  message = '<div class="learn-press-message ' + (typeof wrap === 'string' ? wrap : '') + '">' + message + '</div>';
177
  }
178
 
179
- $formCheckout.prepend(message);
 
 
 
 
 
180
  $('html, body').animate({
181
  scrollTop: $formCheckout.offset().top - 100
182
  }, 1000);
176
  message = '<div class="learn-press-message ' + (typeof wrap === 'string' ? wrap : '') + '">' + message + '</div>';
177
  }
178
 
179
+ if (Array.isArray(message)) {
180
+ message.map(msg => $formCheckout.prepend('<div class="learn-press-message error">' + msg + '</div>'));
181
+ } else {
182
+ $formCheckout.prepend('<div class="learn-press-message error">' + message + '</div>');
183
+ }
184
+
185
  $('html, body').animate({
186
  scrollTop: $formCheckout.offset().top - 100
187
  }, 1000);
assets/js/dist/frontend/checkout.min.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"use strict";void 0===window.LP&&(window.LP={});const n=LP.Checkout=function(t){const n=e("#learn-press-checkout-form"),s=e("#learn-press-checkout-login"),o=e("#learn-press-checkout-register"),i=e(".payment-methods"),r=e("#learn-press-checkout-place-order"),c=e('input[name="guest_email"]');let a="";void 0===String.prototype.isEmail&&(String.prototype.isEmail=function(){return new RegExp("^[-!#$%&'*+\\./0-9=?A-Z^_`a-z{|}~]+@[-!#$%&'*+\\/0-9=?A-Z^_`a-z{|}~]+.[-!#$%&'*+\\./0-9=?A-Z^_`a-z{|}~]+$").test(this)});const l=function(){const t=n.toggle().is(":visible");s.toggle(!t),o.toggle(!t),e("#learn-press-button-guest-checkout").toggle(!t)},u=function(t){let s=arguments.length>1&&void 0!==arguments[1]&&arguments[1];d(),e.isPlainObject(t)?Object.keys(t).reverse().forEach((e=>{const s=t[e];let o=Array.isArray(s)?s[0]:s;const i=Array.isArray(s)?s[1]:"";o='<div class="learn-press-message '+("string"==typeof i?i:"")+'">'+o+"</div>",n.prepend(o)})):(s&&(t='<div class="learn-press-message '+("string"==typeof s?s:"")+'">'+t+"</div>"),n.prepend(t),e("html, body").animate({scrollTop:n.offset().top-100},1e3),e(document).trigger("learn-press/checkout-error"))},d=function(){e(".learn-press-error, .learn-press-notice, .learn-press-message").remove()},g=function(e,t){t=o.find(".learn-press-form-register").toggle(t).is(":visible"),o.find('.checkout-form-register-toggle[data-toggle="show"]').toggle(!t),e&&(e.preventDefault(),h(null,!t))},h=function(e,t){t=s.find(".learn-press-form-login").toggle(t).is(":visible"),s.find('.checkout-form-login-toggle[data-toggle="show"]').toggle(!t),e&&(e.preventDefault(),g(null,!t))};r.on("click",(function(e){})),e(".lp-button-guest-checkout").on("click",l),e("#learn-press-button-cancel-guest-checkout").on("click",l),c.on("keyup changex",(function(){this.value.isEmail()&&(this.timer&&clearTimeout(this.timer),c.addClass("loading"),this.timer=setTimeout((function(){e.post({url:window.location.href,data:{"lp-ajax":"checkout-user-email-exists",email:c.val()},success(t){const n=LP.parseJSON(t);c.removeClass("loading"),e(".lp-guest-checkout-output").remove(),n&&n.output&&c.after(n.output)}})}),500))})).trigger("changex"),i.on("change select",'input[name="payment_method"]',(function(){const t=e(this).val(),n=i.children().filter(".selected").removeClass("selected"),s=n.find("#payment_method_"+a).data("order_button_text");n.find(".payment-method-form").slideUp(),n.end().filter("#learn-press-payment-method-"+t).addClass("selected").find(".payment-method-form").hide().slideDown(),a=n.find("payment_method").val(),s&&r.html(s)})),n.on("submit",(function(s){if(s.preventDefault(),i.length>0&&!i.find('input[name="payment_method"]:checked').val())return u("Please select payment method",!0),!1;let o={};(n.find('input[name="checkout-account-switch-form"]:checked').length=0)||(o=e.extend(o,function(){const t=n.find('input[name="checkout-account-switch-form"]:checked').val();return e("#checkout-account-"+t).serializeJSON()}(),e(".learn-press-checkout-comment").serializeJSON())),o=e.extend(o,e("#checkout-payment").serializeJSON()),d();const c=r.text(),a=new URL(t.ajaxurl);return a.searchParams.set("lp-ajax","checkout"),e.ajax({url:a,dataType:"html",data:o,type:"POST",beforeSend(){e("#learn-press-checkout-place-order").addClass("loading"),r.html(t.i18n_processing)},success(n){(n=LP.parseJSON(n)).messages?function(t){u(t);const n=Object.keys(t)[0];e('input[name="'+n+'"]:visible').trigger("focus")}(n.messages):n.message&&u('<div class="learn-press-message error">'+n.message+"</div>"),e("#learn-press-checkout-place-order").removeClass("loading"),"success"===n.result?n.redirect&&n.redirect.match(/https?/)&&(r.html(t.i18n_redirecting),window.location=n.redirect):r.html(c)},error(t,n,s){e("#learn-press-checkout-place-order").removeClass("loading"),u('<div class="learn-press-message error">'+s+"</div>"),r.html(c),LP.unblockContent()}}),!1})),i.children(".selected").find('input[name="payment_method"]').trigger("select"),s.on("click",".checkout-form-login-toggle",h),o.on("click",".checkout-form-register-toggle",g),o.find("input").each((function(){if(-1!==e.inArray(e(this).attr("type").toLowerCase(),["text","email","number"])&&e(this).val())return g(),!1})),s.find('input:not([type="hidden"])').each((function(){if(-1!==e.inArray(e(this).attr("type").toLowerCase(),["text","email","number"])&&e(this).val())return h(),!1})),o.length&&!s.length?g():!o.length&&s.length&&h(),n.on("change",'input[name="checkout-account-switch-form"]',(function(){e(this).next().find('input:not([type="hidden"]):visible').first().trigger("focus")})).on("change","#guest_email",(function(){n.find("#reg_email").val(this.value)})).on("change","#reg_email",(function(){n.find("#guest_email").val(this.value)})),setTimeout((function(){n.find('input:not([type="hidden"]):visible').first().trigger("focus")}),300)};e(document).ready((function(){"undefined"!=typeof lpCheckoutSettings&&(LP.$checkout=new n(lpCheckoutSettings))}))}(jQuery);
1
+ !function(e,t){"use strict";void 0===window.LP&&(window.LP={});const n=LP.Checkout=function(t){const n=e("#learn-press-checkout-form"),s=e("#learn-press-checkout-login"),r=e("#learn-press-checkout-register"),i=e(".payment-methods"),o=e("#learn-press-checkout-place-order"),a=e('input[name="guest_email"]');let c="";void 0===String.prototype.isEmail&&(String.prototype.isEmail=function(){return new RegExp("^[-!#$%&'*+\\./0-9=?A-Z^_`a-z{|}~]+@[-!#$%&'*+\\/0-9=?A-Z^_`a-z{|}~]+.[-!#$%&'*+\\./0-9=?A-Z^_`a-z{|}~]+$").test(this)});const l=function(){const t=n.toggle().is(":visible");s.toggle(!t),r.toggle(!t),e("#learn-press-button-guest-checkout").toggle(!t)},u=function(t){let s=arguments.length>1&&void 0!==arguments[1]&&arguments[1];d(),e.isPlainObject(t)?Object.keys(t).reverse().forEach((e=>{const s=t[e];let r=Array.isArray(s)?s[0]:s;const i=Array.isArray(s)?s[1]:"";r='<div class="learn-press-message '+("string"==typeof i?i:"")+'">'+r+"</div>",n.prepend(r)})):(s&&(t='<div class="learn-press-message '+("string"==typeof s?s:"")+'">'+t+"</div>"),Array.isArray(t)?t.map((e=>n.prepend('<div class="learn-press-message error">'+e+"</div>"))):n.prepend('<div class="learn-press-message error">'+t+"</div>"),e("html, body").animate({scrollTop:n.offset().top-100},1e3),e(document).trigger("learn-press/checkout-error"))},d=function(){e(".learn-press-error, .learn-press-notice, .learn-press-message").remove()},g=function(e,t){t=r.find(".learn-press-form-register").toggle(t).is(":visible"),r.find('.checkout-form-register-toggle[data-toggle="show"]').toggle(!t),e&&(e.preventDefault(),m(null,!t))},m=function(e,t){t=s.find(".learn-press-form-login").toggle(t).is(":visible"),s.find('.checkout-form-login-toggle[data-toggle="show"]').toggle(!t),e&&(e.preventDefault(),g(null,!t))};o.on("click",(function(e){})),e(".lp-button-guest-checkout").on("click",l),e("#learn-press-button-cancel-guest-checkout").on("click",l),a.on("keyup changex",(function(){this.value.isEmail()&&(this.timer&&clearTimeout(this.timer),a.addClass("loading"),this.timer=setTimeout((function(){e.post({url:window.location.href,data:{"lp-ajax":"checkout-user-email-exists",email:a.val()},success(t){const n=LP.parseJSON(t);a.removeClass("loading"),e(".lp-guest-checkout-output").remove(),n&&n.output&&a.after(n.output)}})}),500))})).trigger("changex"),i.on("change select",'input[name="payment_method"]',(function(){const t=e(this).val(),n=i.children().filter(".selected").removeClass("selected"),s=n.find("#payment_method_"+c).data("order_button_text");n.find(".payment-method-form").slideUp(),n.end().filter("#learn-press-payment-method-"+t).addClass("selected").find(".payment-method-form").hide().slideDown(),c=n.find("payment_method").val(),s&&o.html(s)})),n.on("submit",(function(s){if(s.preventDefault(),i.length>0&&!i.find('input[name="payment_method"]:checked').val())return u("Please select payment method",!0),!1;let r={};(n.find('input[name="checkout-account-switch-form"]:checked').length=0)||(r=e.extend(r,function(){const t=n.find('input[name="checkout-account-switch-form"]:checked').val();return e("#checkout-account-"+t).serializeJSON()}(),e(".learn-press-checkout-comment").serializeJSON())),r=e.extend(r,e("#checkout-payment").serializeJSON()),d();const a=o.text(),c=new URL(t.ajaxurl);return c.searchParams.set("lp-ajax","checkout"),e.ajax({url:c,dataType:"html",data:r,type:"POST",beforeSend(){e("#learn-press-checkout-place-order").addClass("loading"),o.html(t.i18n_processing)},success(n){(n=LP.parseJSON(n)).messages?function(t){u(t);const n=Object.keys(t)[0];e('input[name="'+n+'"]:visible').trigger("focus")}(n.messages):n.message&&u('<div class="learn-press-message error">'+n.message+"</div>"),e("#learn-press-checkout-place-order").removeClass("loading"),"success"===n.result?n.redirect&&n.redirect.match(/https?/)&&(o.html(t.i18n_redirecting),window.location=n.redirect):o.html(a)},error(t,n,s){e("#learn-press-checkout-place-order").removeClass("loading"),u('<div class="learn-press-message error">'+s+"</div>"),o.html(a),LP.unblockContent()}}),!1})),i.children(".selected").find('input[name="payment_method"]').trigger("select"),s.on("click",".checkout-form-login-toggle",m),r.on("click",".checkout-form-register-toggle",g),r.find("input").each((function(){if(-1!==e.inArray(e(this).attr("type").toLowerCase(),["text","email","number"])&&e(this).val())return g(),!1})),s.find('input:not([type="hidden"])').each((function(){if(-1!==e.inArray(e(this).attr("type").toLowerCase(),["text","email","number"])&&e(this).val())return m(),!1})),r.length&&!s.length?g():!r.length&&s.length&&m(),n.on("change",'input[name="checkout-account-switch-form"]',(function(){e(this).next().find('input:not([type="hidden"]):visible').first().trigger("focus")})).on("change","#guest_email",(function(){n.find("#reg_email").val(this.value)})).on("change","#reg_email",(function(){n.find("#guest_email").val(this.value)})),setTimeout((function(){n.find('input:not([type="hidden"]):visible').first().trigger("focus")}),300)};e(document).ready((function(){"undefined"!=typeof lpCheckoutSettings&&(LP.$checkout=new n(lpCheckoutSettings))}))}(jQuery);
assets/js/dist/frontend/courses.js CHANGED
@@ -6,6 +6,11 @@ var __webpack_exports__ = {};
6
  const urlCourses = lpGlobalSettings.courses_url || '';
7
  const urlCurrent = document.location.href;
8
  let filterCourses = JSON.parse(window.localStorage.getItem('lp_filter_courses')) || {};
 
 
 
 
 
9
 
10
  if (lpGlobalSettings.is_course_archive) {
11
  const queryString = window.location.search;
@@ -24,19 +29,22 @@ const lpArchiveAddQueryArgs = (endpoint, args) => {
24
  };
25
 
26
  const lpArchiveCourse = () => {
27
- const elements = document.querySelectorAll('.lp-archive-course-skeleton');
 
28
 
29
- if (!elements.length) {
30
  return;
31
  }
32
 
33
- lpArchiveRequestCourse(filterCourses);
34
- };
 
35
 
36
- let skeleton;
37
- let skeletonClone;
38
- let isLoading = false;
39
- let firstLoad = 1;
 
40
 
41
  window.lpArchiveRequestCourse = (args, callBackSuccess) => {
42
  const wpRestUrl = lpGlobalSettings.lp_rest_url;
@@ -45,6 +53,10 @@ window.lpArchiveRequestCourse = (args, callBackSuccess) => {
45
  return;
46
  }
47
 
 
 
 
 
48
  const archive = document.querySelector('.lp-archive-courses');
49
  const archiveCourse = archive && archive.querySelector('div.lp-archive-courses .lp-content-area');
50
  const listCourse = archiveCourse && archiveCourse.querySelector('ul.learn-press-courses');
@@ -60,7 +72,6 @@ window.lpArchiveRequestCourse = (args, callBackSuccess) => {
60
  isLoading = true;
61
 
62
  if (!skeletonClone) {
63
- skeleton = document.querySelector('.lp-archive-course-skeleton');
64
  skeletonClone = skeleton.outerHTML;
65
  } else {
66
  listCourse.append(skeleton); // return;
@@ -103,8 +114,8 @@ window.lpArchiveRequestCourse = (args, callBackSuccess) => {
103
  }).catch(error => {
104
  listCourse.innerHTML += `<div class="lp-ajax-message error" style="display:block">${error.message || 'Error: Query lp/v1/courses/archive-course'}</div>`;
105
  }).finally(() => {
106
- isLoading = false;
107
- skeleton && skeleton.remove();
108
  jQuery('form.search-courses button').removeClass('loading');
109
 
110
  if (!firstLoad) {
@@ -133,6 +144,10 @@ const lpArchiveSearchCourse = () => {
133
  const btn = s.querySelector('[type="submit"]');
134
  let timeOutSearch;
135
  search.addEventListener('keyup', event => {
 
 
 
 
136
  event.preventDefault();
137
  const s = event.target.value.trim();
138
 
@@ -163,6 +178,11 @@ const lpArchivePaginationCourse = () => {
163
  paginationEle.length > 0 && paginationEle.forEach(ele => ele.addEventListener('click', event => {
164
  event.preventDefault();
165
  event.stopPropagation();
 
 
 
 
 
166
  let filterCourses = JSON.parse(window.localStorage.getItem('lp_filter_courses')) || {};
167
  const urlString = event.currentTarget.getAttribute('href');
168
 
6
  const urlCourses = lpGlobalSettings.courses_url || '';
7
  const urlCurrent = document.location.href;
8
  let filterCourses = JSON.parse(window.localStorage.getItem('lp_filter_courses')) || {};
9
+ let skeleton;
10
+ let skeletonClone;
11
+ let isLoading = false;
12
+ let firstLoad = 1;
13
+ let elNoLoadAjaxFirst = null;
14
 
15
  if (lpGlobalSettings.is_course_archive) {
16
  const queryString = window.location.search;
29
  };
30
 
31
  const lpArchiveCourse = () => {
32
+ skeleton = document.querySelector('.lp-archive-course-skeleton');
33
+ elNoLoadAjaxFirst = document.querySelector('.no-first-load-ajax');
34
 
35
+ if (!skeleton) {
36
  return;
37
  }
38
 
39
+ if (skeleton && !elNoLoadAjaxFirst) {
40
+ lpArchiveRequestCourse(filterCourses);
41
+ }
42
 
43
+ if (elNoLoadAjaxFirst) {
44
+ lpArchivePaginationCourse();
45
+ lpArchiveSearchCourse();
46
+ }
47
+ };
48
 
49
  window.lpArchiveRequestCourse = (args, callBackSuccess) => {
50
  const wpRestUrl = lpGlobalSettings.lp_rest_url;
53
  return;
54
  }
55
 
56
+ if (!skeleton) {
57
+ return;
58
+ }
59
+
60
  const archive = document.querySelector('.lp-archive-courses');
61
  const archiveCourse = archive && archive.querySelector('div.lp-archive-courses .lp-content-area');
62
  const listCourse = archiveCourse && archiveCourse.querySelector('ul.learn-press-courses');
72
  isLoading = true;
73
 
74
  if (!skeletonClone) {
 
75
  skeletonClone = skeleton.outerHTML;
76
  } else {
77
  listCourse.append(skeleton); // return;
114
  }).catch(error => {
115
  listCourse.innerHTML += `<div class="lp-ajax-message error" style="display:block">${error.message || 'Error: Query lp/v1/courses/archive-course'}</div>`;
116
  }).finally(() => {
117
+ isLoading = false; // skeleton && skeleton.remove();
118
+
119
  jQuery('form.search-courses button').removeClass('loading');
120
 
121
  if (!firstLoad) {
144
  const btn = s.querySelector('[type="submit"]');
145
  let timeOutSearch;
146
  search.addEventListener('keyup', event => {
147
+ if (skeleton) {
148
+ skeleton.style.display = 'block';
149
+ }
150
+
151
  event.preventDefault();
152
  const s = event.target.value.trim();
153
 
178
  paginationEle.length > 0 && paginationEle.forEach(ele => ele.addEventListener('click', event => {
179
  event.preventDefault();
180
  event.stopPropagation();
181
+
182
+ if (skeleton) {
183
+ skeleton.style.display = 'block';
184
+ }
185
+
186
  let filterCourses = JSON.parse(window.localStorage.getItem('lp_filter_courses')) || {};
187
  const urlString = event.currentTarget.getAttribute('href');
188
 
assets/js/dist/frontend/courses.min.js CHANGED
@@ -1 +1 @@
1
- !function(){lpGlobalSettings.courses_url;const e=document.location.href;let t=JSON.parse(window.localStorage.getItem("lp_filter_courses"))||{};lpGlobalSettings.is_course_archive&&(window.location.search.length||-1!==e.search("page")||(t={}));const r=(e,t)=>{const r=new URL(e);return Object.keys(t).forEach((e=>{r.searchParams.set(e,t[e])})),r};let o,s,n=!1,c=1;window.lpArchiveRequestCourse=(e,t)=>{const u=lpGlobalSettings.lp_rest_url;if(!u)return;const i=document.querySelector(".lp-archive-courses"),p=i&&i.querySelector("div.lp-archive-courses .lp-content-area"),d=p&&p.querySelector("ul.learn-press-courses");if(!d)return;if(n)return;n=!0,s?d.append(o):(o=document.querySelector(".lp-archive-course-skeleton"),s=o.outerHTML);const h=r(u+"lp/v1/courses/archive-course",{...lpArchiveSkeleton,...e});wp.apiFetch({path:"lp/v1/courses/archive-course"+h.search,method:"GET"}).then((e=>{void 0!==e.data.content&&d&&(d.innerHTML=e.data.content||"");const r=e.data.pagination;a();const o=document.querySelector(".learn-press-pagination");if(o&&o.remove(),void 0!==r){const e=(new DOMParser).parseFromString(r,"text/html").querySelector(".learn-press-pagination");e&&(d.after(e),l())}wp.hooks.doAction("lp-js-get-courses",e),"function"==typeof t&&t(e)})).catch((e=>{d.innerHTML+=`<div class="lp-ajax-message error" style="display:block">${e.message||"Error: Query lp/v1/courses/archive-course"}</div>`})).finally((()=>{if(n=!1,o&&o.remove(),jQuery("form.search-courses button").removeClass("loading"),c)c=0;else{const e={behavior:"smooth"};i.scrollIntoView(e)}window.localStorage.setItem("lp_filter_courses",JSON.stringify(e));const t=r(document.location,e);window.history.pushState("","",t)}))};const a=()=>{const e=document.querySelectorAll("form.search-courses");let t=JSON.parse(window.localStorage.getItem("lp_filter_courses"))||{};e.forEach((e=>{const r=e.querySelector('input[name="c_search"]'),o=e.querySelector('[type="submit"]');let s;r.addEventListener("keyup",(e=>{e.preventDefault();const r=e.target.value.trim();(!r||r&&r.length>2)&&(void 0!==s&&clearTimeout(s),s=setTimeout((function(){o.classList.add("loading"),t.c_search=r,t.paged=1,lpArchiveRequestCourse({...t})}),800))})),e.addEventListener("submit",(t=>{t.preventDefault();const r=e.querySelector('input[name="c_search"]');r&&r.dispatchEvent(new Event("keyup"))}))}))},l=()=>{const e=document.querySelectorAll(".lp-archive-courses .learn-press-pagination .page-numbers");e.length>0&&e.forEach((t=>t.addEventListener("click",(r=>{r.preventDefault(),r.stopPropagation();let o=JSON.parse(window.localStorage.getItem("lp_filter_courses"))||{};if(r.currentTarget.getAttribute("href")){const s=[...e].filter((e=>e.classList.contains("current"))),n=r.currentTarget.textContent||t.classList.contains("next")&&parseInt(s[0].textContent)+1||t.classList.contains("prev")&&parseInt(s[0].textContent)-1;o.paged=n,lpArchiveRequestCourse({...o})}}))))};document.addEventListener("DOMContentLoaded",(function(e){document.querySelectorAll(".lp-archive-course-skeleton").length&&lpArchiveRequestCourse(t),(()=>{const e=document.querySelectorAll('.lp-archive-courses input[name="lp-switch-layout-btn"]');e.length>0&&e.forEach((e=>e.addEventListener("change",(e=>{e.preventDefault();const t=e.target.value;if(t){const e=document.querySelector(".lp-archive-courses .learn-press-courses[data-layout]");e&&(e.dataset.layout=t),LP.Cookies.set("courses-layout",t)}}))))})(),(()=>{const e=LP.Cookies.get("courses-layout"),t=document.querySelectorAll('.lp-courses-bar .switch-layout [name="lp-switch-layout-btn"]');t.length>0&&[...t].map((t=>t.value===e&&(t.checked=!0)))})()}))}();
1
+ !function(){lpGlobalSettings.courses_url;const e=document.location.href;let t,r,o=JSON.parse(window.localStorage.getItem("lp_filter_courses"))||{},s=!1,n=1,c=null;lpGlobalSettings.is_course_archive&&(window.location.search.length||-1!==e.search("page")||(o={}));const a=(e,t)=>{const r=new URL(e);return Object.keys(t).forEach((e=>{r.searchParams.set(e,t[e])})),r};window.lpArchiveRequestCourse=(e,o)=>{const c=lpGlobalSettings.lp_rest_url;if(!c)return;if(!t)return;const i=document.querySelector(".lp-archive-courses"),p=i&&i.querySelector("div.lp-archive-courses .lp-content-area"),d=p&&p.querySelector("ul.learn-press-courses");if(!d)return;if(s)return;s=!0,r?d.append(t):r=t.outerHTML;const h=a(c+"lp/v1/courses/archive-course",{...lpArchiveSkeleton,...e});wp.apiFetch({path:"lp/v1/courses/archive-course"+h.search,method:"GET"}).then((e=>{void 0!==e.data.content&&d&&(d.innerHTML=e.data.content||"");const t=e.data.pagination;l();const r=document.querySelector(".learn-press-pagination");if(r&&r.remove(),void 0!==t){const e=(new DOMParser).parseFromString(t,"text/html").querySelector(".learn-press-pagination");e&&(d.after(e),u())}wp.hooks.doAction("lp-js-get-courses",e),"function"==typeof o&&o(e)})).catch((e=>{d.innerHTML+=`<div class="lp-ajax-message error" style="display:block">${e.message||"Error: Query lp/v1/courses/archive-course"}</div>`})).finally((()=>{if(s=!1,jQuery("form.search-courses button").removeClass("loading"),n)n=0;else{const e={behavior:"smooth"};i.scrollIntoView(e)}window.localStorage.setItem("lp_filter_courses",JSON.stringify(e));const t=a(document.location,e);window.history.pushState("","",t)}))};const l=()=>{const e=document.querySelectorAll("form.search-courses");let r=JSON.parse(window.localStorage.getItem("lp_filter_courses"))||{};e.forEach((e=>{const o=e.querySelector('input[name="c_search"]'),s=e.querySelector('[type="submit"]');let n;o.addEventListener("keyup",(e=>{t&&(t.style.display="block"),e.preventDefault();const o=e.target.value.trim();(!o||o&&o.length>2)&&(void 0!==n&&clearTimeout(n),n=setTimeout((function(){s.classList.add("loading"),r.c_search=o,r.paged=1,lpArchiveRequestCourse({...r})}),800))})),e.addEventListener("submit",(t=>{t.preventDefault();const r=e.querySelector('input[name="c_search"]');r&&r.dispatchEvent(new Event("keyup"))}))}))},u=()=>{const e=document.querySelectorAll(".lp-archive-courses .learn-press-pagination .page-numbers");e.length>0&&e.forEach((r=>r.addEventListener("click",(o=>{o.preventDefault(),o.stopPropagation(),t&&(t.style.display="block");let s=JSON.parse(window.localStorage.getItem("lp_filter_courses"))||{};if(o.currentTarget.getAttribute("href")){const t=[...e].filter((e=>e.classList.contains("current"))),n=o.currentTarget.textContent||r.classList.contains("next")&&parseInt(t[0].textContent)+1||r.classList.contains("prev")&&parseInt(t[0].textContent)-1;s.paged=n,lpArchiveRequestCourse({...s})}}))))};document.addEventListener("DOMContentLoaded",(function(e){t=document.querySelector(".lp-archive-course-skeleton"),c=document.querySelector(".no-first-load-ajax"),t&&(t&&!c&&lpArchiveRequestCourse(o),c&&(u(),l())),(()=>{const e=document.querySelectorAll('.lp-archive-courses input[name="lp-switch-layout-btn"]');e.length>0&&e.forEach((e=>e.addEventListener("change",(e=>{e.preventDefault();const t=e.target.value;if(t){const e=document.querySelector(".lp-archive-courses .learn-press-courses[data-layout]");e&&(e.dataset.layout=t),LP.Cookies.set("courses-layout",t)}}))))})(),(()=>{const e=LP.Cookies.get("courses-layout"),t=document.querySelectorAll('.lp-courses-bar .switch-layout [name="lp-switch-layout-btn"]');t.length>0&&[...t].map((t=>t.value===e&&(t.checked=!0)))})()}))}();
assets/src/apps/js/frontend/checkout.js CHANGED
@@ -183,7 +183,11 @@
183
  message = '<div class="learn-press-message ' + ( typeof ( wrap ) === 'string' ? wrap : '' ) + '">' + message + '</div>';
184
  }
185
 
186
- $formCheckout.prepend( message );
 
 
 
 
187
 
188
  $( 'html, body' ).animate( {
189
  scrollTop: ( $formCheckout.offset().top - 100 ),
183
  message = '<div class="learn-press-message ' + ( typeof ( wrap ) === 'string' ? wrap : '' ) + '">' + message + '</div>';
184
  }
185
 
186
+ if ( Array.isArray( message ) ) {
187
+ message.map( ( msg ) => $formCheckout.prepend( '<div class="learn-press-message error">' + msg + '</div>') );
188
+ } else {
189
+ $formCheckout.prepend( '<div class="learn-press-message error">' + message + '</div>' );
190
+ }
191
 
192
  $( 'html, body' ).animate( {
193
  scrollTop: ( $formCheckout.offset().top - 100 ),
assets/src/apps/js/frontend/courses.js CHANGED
@@ -1,6 +1,11 @@
1
  const urlCourses = lpGlobalSettings.courses_url || '';
2
  const urlCurrent = document.location.href;
3
  let filterCourses = JSON.parse(window.localStorage.getItem('lp_filter_courses')) || {};
 
 
 
 
 
4
 
5
  if( lpGlobalSettings.is_course_archive ) {
6
  const queryString = window.location.search;
@@ -21,19 +26,23 @@ const lpArchiveAddQueryArgs = ( endpoint, args ) => {
21
  };
22
 
23
  const lpArchiveCourse = () => {
24
- const elements = document.querySelectorAll( '.lp-archive-course-skeleton' );
 
25
 
26
- if ( ! elements.length ) {
27
  return;
28
  }
29
 
30
- lpArchiveRequestCourse( filterCourses );
 
 
 
 
 
 
 
31
  };
32
 
33
- let skeleton;
34
- let skeletonClone;
35
- let isLoading = false;
36
- let firstLoad = 1;
37
  window.lpArchiveRequestCourse = ( args, callBackSuccess ) => {
38
  const wpRestUrl = lpGlobalSettings.lp_rest_url;
39
 
@@ -41,6 +50,10 @@ window.lpArchiveRequestCourse = ( args, callBackSuccess ) => {
41
  return;
42
  }
43
 
 
 
 
 
44
  const archive = document.querySelector( '.lp-archive-courses' );
45
  const archiveCourse = archive && archive.querySelector( 'div.lp-archive-courses .lp-content-area' );
46
  const listCourse = archiveCourse && archiveCourse.querySelector( 'ul.learn-press-courses' );
@@ -56,10 +69,9 @@ window.lpArchiveRequestCourse = ( args, callBackSuccess ) => {
56
  isLoading = true;
57
 
58
  if ( ! skeletonClone ) {
59
- skeleton = document.querySelector( '.lp-archive-course-skeleton' );
60
  skeletonClone = skeleton.outerHTML;
61
  } else {
62
- listCourse.append(skeleton);
63
  // return;
64
  }
65
 
@@ -102,7 +114,7 @@ window.lpArchiveRequestCourse = ( args, callBackSuccess ) => {
102
  listCourse.innerHTML += `<div class="lp-ajax-message error" style="display:block">${ error.message || 'Error: Query lp/v1/courses/archive-course' }</div>`;
103
  } ).finally( () => {
104
  isLoading = false;
105
- skeleton && skeleton.remove();
106
 
107
  jQuery( 'form.search-courses button' ).removeClass( 'loading' );
108
 
@@ -132,6 +144,9 @@ const lpArchiveSearchCourse = () => {
132
  let timeOutSearch;
133
 
134
  search.addEventListener( 'keyup', ( event ) => {
 
 
 
135
  event.preventDefault();
136
 
137
  const s = event.target.value.trim();
@@ -168,6 +183,10 @@ const lpArchivePaginationCourse = () => {
168
  event.preventDefault();
169
  event.stopPropagation();
170
 
 
 
 
 
171
  let filterCourses = JSON.parse(window.localStorage.getItem('lp_filter_courses')) || {};
172
 
173
  const urlString = event.currentTarget.getAttribute( 'href' );
1
  const urlCourses = lpGlobalSettings.courses_url || '';
2
  const urlCurrent = document.location.href;
3
  let filterCourses = JSON.parse(window.localStorage.getItem('lp_filter_courses')) || {};
4
+ let skeleton;
5
+ let skeletonClone;
6
+ let isLoading = false;
7
+ let firstLoad = 1;
8
+ let elNoLoadAjaxFirst = null;
9
 
10
  if( lpGlobalSettings.is_course_archive ) {
11
  const queryString = window.location.search;
26
  };
27
 
28
  const lpArchiveCourse = () => {
29
+ skeleton = document.querySelector( '.lp-archive-course-skeleton' );
30
+ elNoLoadAjaxFirst = document.querySelector( '.no-first-load-ajax' );
31
 
32
+ if ( ! skeleton ) {
33
  return;
34
  }
35
 
36
+ if ( skeleton && ! elNoLoadAjaxFirst ) {
37
+ lpArchiveRequestCourse( filterCourses );
38
+ }
39
+
40
+ if ( elNoLoadAjaxFirst ) {
41
+ lpArchivePaginationCourse();
42
+ lpArchiveSearchCourse();
43
+ }
44
  };
45
 
 
 
 
 
46
  window.lpArchiveRequestCourse = ( args, callBackSuccess ) => {
47
  const wpRestUrl = lpGlobalSettings.lp_rest_url;
48
 
50
  return;
51
  }
52
 
53
+ if ( ! skeleton ) {
54
+ return;
55
+ }
56
+
57
  const archive = document.querySelector( '.lp-archive-courses' );
58
  const archiveCourse = archive && archive.querySelector( 'div.lp-archive-courses .lp-content-area' );
59
  const listCourse = archiveCourse && archiveCourse.querySelector( 'ul.learn-press-courses' );
69
  isLoading = true;
70
 
71
  if ( ! skeletonClone ) {
 
72
  skeletonClone = skeleton.outerHTML;
73
  } else {
74
+ listCourse.append( skeleton );
75
  // return;
76
  }
77
 
114
  listCourse.innerHTML += `<div class="lp-ajax-message error" style="display:block">${ error.message || 'Error: Query lp/v1/courses/archive-course' }</div>`;
115
  } ).finally( () => {
116
  isLoading = false;
117
+ // skeleton && skeleton.remove();
118
 
119
  jQuery( 'form.search-courses button' ).removeClass( 'loading' );
120
 
144
  let timeOutSearch;
145
 
146
  search.addEventListener( 'keyup', ( event ) => {
147
+ if( skeleton ) {
148
+ skeleton.style.display = 'block';
149
+ }
150
  event.preventDefault();
151
 
152
  const s = event.target.value.trim();
183
  event.preventDefault();
184
  event.stopPropagation();
185
 
186
+ if( skeleton ) {
187
+ skeleton.style.display = 'block';
188
+ }
189
+
190
  let filterCourses = JSON.parse(window.localStorage.getItem('lp_filter_courses')) || {};
191
 
192
  const urlString = event.currentTarget.getAttribute( 'href' );
assets/src/js/admin/admin.js CHANGED
@@ -104,7 +104,7 @@
104
  dataType: 'json',
105
  s: '',
106
  },
107
- placeholder: 'Search by user',
108
  minimumInputLength: 3,
109
  allowClear: true,
110
  } ).on( 'select2:select', function() {
@@ -496,6 +496,20 @@
496
  ele.parentNode.style.border = '2px solid orangered';
497
  }
498
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
499
  };
500
 
501
  $( document ).ready( onReady );
104
  dataType: 'json',
105
  s: '',
106
  },
107
+ placeholder: wp.i18n.__( 'Search by user', 'learnpress' ),
108
  minimumInputLength: 3,
109
  allowClear: true,
110
  } ).on( 'select2:select', function() {
496
  ele.parentNode.style.border = '2px solid orangered';
497
  }
498
  }
499
+
500
+ // Show/hide meta-box field with type checkbox
501
+ $( 'input' ).on( 'click' , function ( e ) {
502
+ const el = $( e.target );
503
+ const id = el.attr( 'id' );
504
+ const classHide = id.replace('learn_press_', '');
505
+ const elHide = $(`.show_if_${classHide}`);
506
+
507
+ if ( el.is(':checked') ) {
508
+ elHide.show();
509
+ } else {
510
+ elHide.hide();
511
+ }
512
+ });
513
  };
514
 
515
  $( document ).ready( onReady );
config/settings/course.php ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Settings Courses
4
+ */
5
+ $generate_course_thumbnail = get_option( 'learn_press_generate_course_thumbnail', 'no' );
6
+ $des_option_redirect_finish_course = wp_sprintf(
7
+ '%s<br>%s',
8
+ esc_html__( 'The site will be redirected to the URL added after clicking finish course button.', 'learnpress' ),
9
+ esc_html__( 'Set blank, the site will be redirected to the single course page', 'learnpress' )
10
+ );
11
+
12
+ return apply_filters(
13
+ 'learn-press/courses-settings-fields',
14
+ array_merge(
15
+ apply_filters(
16
+ 'learn-press/course-settings-fields/general',
17
+ array(
18
+ array(
19
+ 'title' => esc_html__( 'General', 'learnpress' ),
20
+ 'type' => 'title',
21
+ ),
22
+ 'review_course' => array(
23
+ 'title' => esc_html__( 'Review courses', 'learnpress' ),
24
+ 'desc' => esc_html__( 'Courses created by instructors will be pending in review first.', 'learnpress' ),
25
+ 'id' => 'required_review',
26
+ 'default' => 'yes',
27
+ 'type' => 'checkbox',
28
+ ),
29
+ 'auto_start' => array(
30
+ 'title' => esc_html__( 'Auto start', 'learnpress' ),
31
+ 'id' => 'auto_enroll',
32
+ 'default' => 'yes',
33
+ 'type' => 'checkbox',
34
+ 'desc' => esc_html__( 'Students will get started courses immediately after successfully purchased.', 'learnpress' ),
35
+ ),
36
+ 'enable_popup_confirm_finish' => array(
37
+ 'title' => __( 'Enable confirmation popup finish course, complete item', 'learnpress' ),
38
+ 'desc' => __( 'Show confirmation popup before finishing course or completing item.', 'learnpress' ),
39
+ 'id' => 'enable_popup_confirm_finish',
40
+ 'default' => 'yes',
41
+ 'type' => 'checkbox',
42
+ ),
43
+ 'archive_courses_layout' => array(
44
+ 'title' => esc_html__( 'Archive page layout', 'learnpress' ),
45
+ 'desc' => esc_html__( 'Type display list course on Course Archive page', 'learnpress' ),
46
+ 'id' => 'archive_courses_layout',
47
+ 'default' => 'list',
48
+ 'type' => 'select',
49
+ 'options' => learn_press_courses_layouts(),
50
+ ),
51
+ 'archive_course_limit' => array(
52
+ 'title' => esc_html__( 'Courses per page', 'learnpress' ),
53
+ 'desc' => esc_html__( 'Number of courses displayed per page.', 'learnpress' ),
54
+ 'id' => 'archive_course_limit',
55
+ 'default' => '8',
56
+ 'type' => 'number',
57
+ 'custom_attributes' => array(
58
+ 'min' => '1',
59
+ ),
60
+ 'css' => 'min-width: 50px; width: 50px;',
61
+ ),
62
+ 'courses_load_ajax' => array(
63
+ 'title' => esc_html__( 'Enable loading ajax Courses on the Course Archive page', 'learnpress' ),
64
+ 'desc' => __( 'On/Off <i>loading ajax Courses</i>', 'learnpress' ),
65
+ 'id' => 'courses_load_ajax',
66
+ 'default' => 'yes',
67
+ 'type' => 'checkbox',
68
+ ),
69
+ 'course_no_first_page_ajax' => array(
70
+ 'title' => esc_html__( 'Not run Ajax when reloading Course Archive page', 'learnpress' ),
71
+ 'desc' => esc_html__( 'Ajax is only applied when selecting pagination, filtering, searching and sorting. Not applicable when reloading Course Archive page.', 'learnpress' ),
72
+ 'id' => 'courses_first_no_ajax',
73
+ 'default' => 'no',
74
+ 'type' => 'checkbox',
75
+ 'show_if_checked' => 'courses_load_ajax',
76
+ ),
77
+ 'course_thumbnail_dimensions' => array(
78
+ 'title' => esc_html__( 'Thumbnail dimensions', 'learnpress' ),
79
+ 'id' => 'course_thumbnail_dimensions',
80
+ 'default' => array( 500, 300, 'yes' ),
81
+ 'type' => 'image-dimensions',
82
+ ),
83
+ 'course_finish_redirect' => array(
84
+ 'title' => esc_html__( 'Redirect when finish course', 'learnpress' ),
85
+ 'id' => 'course_finish_redirect',
86
+ 'default' => '',
87
+ 'type' => 'url',
88
+ 'placeholder' => 'https://learnpress.com/',
89
+ 'desc' => $des_option_redirect_finish_course,
90
+ ),
91
+ array(
92
+ 'type' => 'sectionend',
93
+ ),
94
+ )
95
+ ),
96
+ apply_filters(
97
+ 'learn-press/course-settings-fields/curriculum',
98
+ array(
99
+ array(
100
+ 'type' => 'title',
101
+ 'title' => esc_html__( 'Curriculum Settings', 'learnpress' ),
102
+ 'id' => 'lp_metabox_curriculum_setting',
103
+ ),
104
+ 'section_per_page' => array(
105
+ 'title' => esc_html__( 'Section Per Page', 'learnpress' ),
106
+ 'id' => 'section_per_page',
107
+ 'default' => 2,
108
+ 'type' => 'number',
109
+ 'desc' => esc_html__( 'Number of sections displayed per page ( Enter -1 for display all sections).', 'learnpress' ),
110
+ ),
111
+ 'course_item_per_page' => array(
112
+ 'title' => esc_html__( 'Course Item Per Page', 'learnpress' ),
113
+ 'id' => 'course_item_per_page',
114
+ 'default' => 5,
115
+ 'type' => 'number',
116
+ 'desc' => esc_html__( 'Number of course items displayed per page in section ( Enter -1 for display all course items).', 'learnpress' ),
117
+ ),
118
+ array(
119
+ 'type' => 'sectionend',
120
+ 'id' => 'lp_metabox_curriculum_setting',
121
+ ),
122
+ )
123
+ ),
124
+ apply_filters(
125
+ 'learn-press/course-settings-fields/single',
126
+ array(
127
+ array(
128
+ 'title' => esc_html__( 'Permalinks', 'learnpress' ),
129
+ 'type' => 'title',
130
+ ),
131
+ array(
132
+ 'title' => esc_html__( 'Course', 'learnpress' ),
133
+ 'type' => 'course-permalink',
134
+ 'default' => '',
135
+ 'id' => 'course_base',
136
+ ),
137
+ 'lesson_slug' => array(
138
+ 'title' => esc_html__( 'Lesson', 'learnpress' ),
139
+ 'type' => 'text',
140
+ 'id' => 'lesson_slug',
141
+ 'desc' => sprintf( 'e.g. %s/course/sample-course/<code>lessons</code>/sample-lesson/', home_url() ),
142
+ 'default' => 'lessons',
143
+ 'placeholder' => 'lesson',
144
+ ),
145
+ 'quiz_slug' => array(
146
+ 'title' => esc_html__( 'Quiz', 'learnpress' ),
147
+ 'type' => 'text',
148
+ 'id' => 'quiz_slug',
149
+ 'desc' => sprintf( 'e.g. %s/course/sample-course/<code>quizzes</code>/sample-quiz/', home_url() ),
150
+ 'default' => 'quizzes',
151
+ 'placeholder' => 'quizzes',
152
+ ),
153
+ 'course_category_base' => array(
154
+ 'title' => esc_html__( 'Category base', 'learnpress' ),
155
+ 'id' => 'course_category_base',
156
+ 'default' => 'course-category',
157
+ 'type' => 'text',
158
+ 'placeholder' => 'course-category',
159
+ 'desc' => sprintf( 'e.g. %s/course/%s/sample-course/', home_url(), '<code>course-category</code>' ),
160
+ ),
161
+ 'course_tag_base' => array(
162
+ 'title' => esc_html__( 'Tag base', 'learnpress' ),
163
+ 'id' => 'course_tag_base',
164
+ 'default' => 'course-tag',
165
+ 'type' => 'text',
166
+ 'placeholder' => 'course-tag',
167
+ 'desc' => sprintf( 'e.g. %s/course/%s/sample-course/', home_url(), '<code>course-tag</code>' ),
168
+ ),
169
+ array(
170
+ 'type' => 'sectionend',
171
+ ),
172
+ )
173
+ )
174
+ )
175
+ );
inc/abstract-settings.php CHANGED
@@ -192,7 +192,7 @@ abstract class LP_Abstract_Settings {
192
 
193
  // Single value
194
  } else {
195
- $option_value = LP()->settings()->get( preg_replace( '!^learn_press_!', '', $option_name ), null );
196
  }
197
 
198
  if ( is_array( $option_value ) ) {
192
 
193
  // Single value
194
  } else {
195
+ $option_value = LP_Settings::instance()->get( preg_replace( '!^learn_press_!', '', $option_name ), null );
196
  }
197
 
198
  if ( is_array( $option_value ) ) {
inc/abstracts/abstract-assets.php CHANGED
@@ -124,6 +124,7 @@ abstract class LP_Abstract_Assets {
124
  * Path translate of a string on file ".pot" if have must map to js/dist
125
  */
126
  wp_set_script_translations( 'lp-quiz', 'learnpress' );
 
127
  }
128
 
129
  /**
124
  * Path translate of a string on file ".pot" if have must map to js/dist
125
  */
126
  wp_set_script_translations( 'lp-quiz', 'learnpress' );
127
+ wp_set_script_translations( 'lp-admin', 'learnpress' );
128
  }
129
 
130
  /**
inc/admin/class-lp-admin-ajax.php CHANGED
@@ -117,170 +117,6 @@ if ( ! class_exists( 'LP_Admin_Ajax' ) ) {
117
  }
118
  }
119
 
120
- /**
121
- * @editor tungnx
122
- * @model 4.1.4 comment - not use
123
- */
124
- /*public static function sync_calculate_course_results() {
125
- if ( ! isset( $_REQUEST['sync'] ) ) {
126
- return;
127
- }
128
-
129
- $sync = LP_Helper::sanitize_params_submitted( $_REQUEST['sync'] );
130
-
131
- if ( empty( $sync ) ) {
132
- die();
133
- }
134
-
135
- global $wpdb;
136
- $api = LP_Repair_Database::instance();
137
-
138
- if ( $sync === 'get-users' ) {
139
- $query = $wpdb->prepare(
140
- "
141
- SELECT ID
142
- FROM {$wpdb->users}
143
- WHERE 1
144
- ",
145
- 1
146
- );
147
-
148
- $users = $wpdb->get_col( $query );
149
-
150
- learn_press_send_json( array( 'users' => $users ) );
151
- }
152
-
153
- $api->calculate_course_results( $sync );
154
- learn_press_send_json( array( 'result' => 'success' ) );
155
-
156
- die();
157
- }*/
158
-
159
- /**
160
- * Sync orders for each course
161
- *
162
- * @since 3.1.0
163
- * @editor tungnx
164
- * @modify 4.1.4 comment - not use
165
- */
166
- /*public static function sync_course_orders() {
167
- if ( empty( $_REQUEST['sync'] ) ) {
168
- die();
169
- }
170
-
171
- global $wpdb;
172
- $api = LP_Repair_Database::instance();
173
- $sync = $_REQUEST['sync'];
174
-
175
- if ( $sync === 'get-courses' ) {
176
- learn_press_send_json( array( 'courses' => $api->get_all_courses() ) );
177
- }
178
-
179
- $api->sync_course_orders( $sync );
180
- learn_press_send_json( array( 'result' => 'success' ) );
181
-
182
- die();
183
- }*/
184
-
185
- /**
186
- * Sync orders for each user
187
- *
188
- * @since 3.1.0
189
- * @editor tungnx
190
- * @modify 4.1.4 comment - not use
191
- */
192
- /*public static function sync_user_orders() {
193
- if ( empty( $_REQUEST['sync'] ) ) {
194
- die();
195
- }
196
-
197
- global $wpdb;
198
- $api = LP_Repair_Database::instance();
199
- $sync = $_REQUEST['sync'];
200
-
201
- if ( $sync === 'get-users' ) {
202
- $query = $wpdb->prepare(
203
- "
204
- SELECT ID
205
- FROM {$wpdb->users}
206
- WHERE 1
207
- ",
208
- 1
209
- );
210
-
211
- $users = $wpdb->get_col( $query );
212
-
213
- learn_press_send_json( array( 'users' => $users ) );
214
- }
215
-
216
- $api->sync_user_orders( $sync );
217
- learn_press_send_json( array( 'result' => 'success' ) );
218
-
219
- die();
220
- }*/
221
-
222
- /**
223
- * Remap final quiz for each course
224
- *
225
- * @since 3.1.0
226
- * @editor tungnx
227
- * @deprecated 4.1.5
228
- */
229
- /*public static function sync_course_final_quiz() {
230
- if ( empty( $_REQUEST['sync'] ) ) {
231
- die();
232
- }
233
-
234
- global $wpdb;
235
- $api = LP_Repair_Database::instance();
236
- $sync = $_REQUEST['sync'];
237
-
238
- if ( $sync === 'get-courses' ) {
239
- learn_press_send_json( array( 'courses' => $api->get_all_courses() ) );
240
- }
241
-
242
- $api->sync_course_final_quiz( $sync );
243
- learn_press_send_json( array( 'result' => 'success' ) );
244
-
245
- die();
246
- }*/
247
-
248
- /**
249
- * @editor tungnx
250
- * @comment 4.1.4 comment - not use
251
- */
252
- /*public static function sync_remove_older_data() {
253
- $api = LP_Repair_Database::instance();
254
- $api->remove_older_post_meta();
255
- learn_press_send_json( array( 'result' => 'success' ) );
256
- die();
257
- }*/
258
-
259
- /**
260
- * Get html of order status to display in WP Dashboad
261
- * @editor tungnx
262
- * @modify 4.1.4 comment - not use
263
- */
264
- /*public static function dashboard_order_status() {
265
- learn_press_admin_view( 'dashboard/order-status' );
266
- die();
267
- }*/
268
-
269
- /**
270
- * @editor tungnx
271
- * @modify 4.1.4 comment - not use
272
- */
273
- /*public static function dashboard_plugin_status() {
274
- $dashboard = new LP_Admin_Dashboard();
275
- $plugin_data = $dashboard->get_data();
276
- if ( ! $plugin_data || is_wp_error( $plugin_data ) ) {
277
- learn_press_admin_view( 'dashboard/plugin-status/html-no-data' );
278
- } else {
279
- learn_press_admin_view( 'dashboard/plugin-status/html-results', array( 'plugin_data' => $plugin_data ) );
280
- }
281
- die();
282
- }*/
283
-
284
  /**
285
  * Search user on some pages on the Backend
286
  */
@@ -366,61 +202,6 @@ if ( ! class_exists( 'LP_Admin_Ajax' ) ) {
366
  learn_press_send_json_success( $result );
367
  }
368
 
369
- /**
370
- * Send data to join newsletter or dismiss.
371
- *
372
- * [
373
- * This function has deprecated since 3.2.6 from this class.
374
- * Please check class LP_Admin and hook learn-press/dismissed-notice-response for more details.
375
- * Newsletter function be hooked to the hook above to send subscription when
376
- * notice has already dismissed.
377
- * ]
378
- *
379
- * @deprecated
380
- *
381
- * @since 3.0.10
382
- * @editable tungnx
383
- * @model 4.1.4 comment - not use
384
- */
385
- /*public static function join_newsletter() {
386
- $context = LP_Request::get_string( 'context' );
387
- if ( ! $context || $context != 'newsletter' ) {
388
- update_option( 'learn-press-dismissed-newsletter-button', 1 );
389
- learn_press_send_json_success( __( 'Dismissed!', 'learnpress' ) );
390
- }
391
- $user = learn_press_get_current_user();
392
- if ( ! $user || $user->get_email() == '' ) {
393
- learn_press_send_json_error( __( 'Fail while joining newsletter! Please try again!', 'learnpress' ) );
394
- }
395
- $url = 'https://thimpress.com/mailster/subscribe';
396
- $response = wp_remote_post(
397
- $url,
398
- array(
399
- 'method' => 'POST',
400
- 'timeout' => 45,
401
- 'redirection' => 5,
402
- 'httpversion' => '1.0',
403
- 'blocking' => true,
404
- 'headers' => array(),
405
- 'body' => array(
406
- '_referer' => 'extern',
407
- '_nonce' => '4b266caf7b',
408
- 'formid' => '19',
409
- 'email' => $user->get_email(),
410
- 'website' => site_url(),
411
- ),
412
- 'cookies' => array(),
413
- )
414
- );
415
- if ( is_wp_error( $response ) ) {
416
- $error_message = $response->get_error_message();
417
- learn_press_send_json_error( __( 'Something went wrong: ', 'learnpress' ) . $error_message );
418
- } else {
419
- update_option( 'learn-press-dismissed-newsletter-button', 1 );
420
- learn_press_send_json_success( __( 'Thank you for subscribing! Please check and click the confirmation link from the email we\'ve just sent to your mail box.', 'learnpress' ) );
421
- }
422
- }*/
423
-
424
  /**
425
  * Duplicate course, lesson, quiz, question.
426
  *
@@ -547,30 +328,6 @@ if ( ! class_exists( 'LP_Admin_Ajax' ) ) {
547
  learn_press_send_json( $response );
548
  }
549
 
550
- /**
551
- * Toggle lesson preview.
552
- */
553
- /*public static function toggle_item_preview() {
554
- $id = learn_press_get_request( 'item_id' );
555
- if ( in_array(
556
- get_post_type( $id ),
557
- apply_filters(
558
- 'learn-press/reviewable-post-types',
559
- array(
560
- 'lp_lesson',
561
- 'lp_quiz',
562
- )
563
- )
564
- ) && wp_verify_nonce( learn_press_get_request( 'nonce' ), 'learn-press-toggle-item-preview' )
565
- ) {
566
- $previewable = learn_press_get_request( 'previewable' );
567
- if ( is_null( $previewable ) ) {
568
- $previewable = '0';
569
- }
570
- update_post_meta( $id, '_lp_preview', $previewable );
571
- }
572
- }*/
573
-
574
  /**
575
  * Search items by requesting params.
576
  */
@@ -809,57 +566,6 @@ if ( ! class_exists( 'LP_Admin_Ajax' ) ) {
809
  $statistic->load_chart();
810
  }
811
 
812
- /**
813
- * @param $query
814
- *
815
- * @editor tungnx
816
- * @model 4.1.4 comment - not use
817
- */
818
- /*public static function search_users() {
819
- if ( ! current_user_can( 'edit_lp_orders' ) ) {
820
- die( - 1 );
821
- }
822
-
823
- $term = LP_Helper::sanitize_params_submitted( $_REQUEST['term'] );
824
-
825
- if ( empty( $term ) ) {
826
- die( __FILE__ . '::' . __FUNCTION__ );
827
-
828
- }
829
-
830
- $found_customers = array();
831
-
832
- add_action( 'pre_user_query', array( __CLASS__, 'json_search_customer_name' ) );
833
-
834
- $customers_query = new WP_User_Query(
835
- apply_filters(
836
- 'learn_press_search_customers_query',
837
- array(
838
- 'fields' => 'all',
839
- 'orderby' => 'display_name',
840
- 'search' => '*' . $term . '*',
841
- 'search_columns' => array( 'ID', 'user_login', 'user_email', 'user_nicename' ),
842
- )
843
- )
844
- );
845
-
846
- remove_action( 'pre_user_query', array( __CLASS__, 'json_search_customer_name' ) );
847
-
848
- $customers = $customers_query->get_results();
849
-
850
- if ( ! empty( $customers ) ) {
851
- foreach ( $customers as $customer ) {
852
- $found_customers[] = array(
853
- 'label' => $customer->display_name . ' (#' . $customer->ID . ' &ndash; ' . sanitize_email( $customer->user_email ) . ')',
854
- 'value' => $customer->ID,
855
- );
856
- }
857
- }
858
-
859
- echo json_encode( $found_customers );
860
- die();
861
- }*/
862
-
863
  public static function json_search_customer_name( $query ) {
864
  global $wpdb;
865
 
@@ -874,38 +580,6 @@ if ( ! class_exists( 'LP_Admin_Ajax' ) ) {
874
  $query->query_where .= $wpdb->prepare( ' OR user_name.meta_value LIKE %s ', '%' . $term . '%' );
875
  }
876
 
877
- /**
878
- * Dismiss notice
879
- *
880
- * @update 3.2.6
881
- * @editor tungnx
882
- * @comment 4.1.4 comment - not use
883
- */
884
- /*public static function dismiss_notice() {
885
- $name = learn_press_get_request( 'name' );
886
- $value = learn_press_get_request( 'value' );
887
- $expired = learn_press_get_request( 'expired' );
888
-
889
- // LP_Admin_Notice::instance()->dismiss_notice_2( $name, $value, $expired );
890
-
891
- die();
892
- }*/
893
-
894
- /*
895
- * comment by tungnnx
896
- * @reason not uses - low security
897
- * @since 3.2.6.8
898
- */
899
- /*
900
- public static function plugin_action() {
901
- $url = learn_press_get_request( 'url' );
902
- ob_start();
903
- wp_remote_get( $url );
904
- ob_get_clean();
905
- echo wp_remote_get( admin_url( 'admin.php?page=learn-press-addons&tab=installed' ) );
906
- die();
907
- }*/
908
-
909
  /**
910
  * create new page on LP Settings
911
  *
@@ -955,179 +629,6 @@ if ( ! class_exists( 'LP_Admin_Ajax' ) ) {
955
  learn_press_send_json( $response );
956
  }
957
 
958
- /**
959
- * Create LP static pages
960
- *
961
- * @editor tungnx
962
- * @model 4.1.4 comment - not use
963
- */
964
- /*public static function create_pages() {
965
- check_admin_referer( 'create-pages' );
966
-
967
- $pages = LP_Request::get_list_array( 'pages' );
968
- $pages = array_fill_keys( $pages, '' );
969
- $all_pages = learn_press_static_page_ids();
970
- $page_names = learn_press_static_pages();
971
-
972
- if ( empty( $pages ) ) {
973
- $pages = $all_pages;
974
- }
975
-
976
- foreach ( $pages as $id => $page_id ) {
977
- if ( ! empty( $all_pages[ $id ] ) ) {
978
- continue;
979
- }
980
-
981
- $page_id = LP_Helper::create_page( isset( $page_names[ $id ] ) ? $page_names[ $id ] : ucfirst( $id ), $id );
982
- }
983
-
984
- LP()->flush_rewrite_rules();
985
-
986
- echo esc_html__( 'The required pages are successfully created.', 'learnpress' );
987
-
988
- die();
989
- }*/
990
-
991
- /**
992
- * Install sample data or dismiss the notice depending on user's option
993
- */
994
- /*public static function install_sample_data() {
995
- $yes = ! empty( $_REQUEST['yes'] ) ? $_REQUEST['yes'] : '';
996
- $response = array( 'result' => 'fail' );
997
- $retry_button = sprintf( '<a href="" class="button yes" data-action="yes">%s</a>', __( 'Please try again.', 'learnpress' ) );
998
- $dismiss_button = sprintf( '<a href="" class="button disabled no" data-action="no">%s</a>', __( 'Cancel', 'learnpress' ) );
999
- $buttons = sprintf( '<p>%s %s</p>', $retry_button, $dismiss_button );
1000
- if ( 'no' == $yes ) {
1001
- set_transient( 'learn_press_install_sample_data', 'off', 12 * HOUR_IN_SECONDS );
1002
- } else {
1003
- $result = array( 'status' => 'activate' );// learn_press_install_and_active_add_on( 'learnpress-import-export' );
1004
- if ( 'activate' == $result['status'] ) {
1005
- // copy dummy-data.xml to import folder of the add-on
1006
- lpie_mkdir( lpie_import_path() );
1007
- if ( file_exists( lpie_import_path() ) ) {
1008
- $import_source = LP_PLUGIN_PATH . '/dummy-data/dummy-data.xml';
1009
- $file = 'dummy-data-' . time() . '.xml';
1010
- $copy = lpie_import_path() . '/' . $file;
1011
- copy( $import_source, $copy );
1012
- if ( file_exists( $copy ) ) {
1013
- $url = admin_url( 'admin-ajax.php?page=learn_press_import_export&tab=import-course' );
1014
- $postdata = array(
1015
- 'step' => 2,
1016
- 'action' => 'learn_press_import',
1017
- 'import-file' => 'import/' . $file,
1018
- 'nonce' => wp_create_nonce( 'lpie-import-file' ),
1019
- 'x' => 1,
1020
- );
1021
- $response['url'] = $url = $url . '&' . http_build_query( $postdata ) . "\n";
1022
- $response['result'] = 'success';
1023
- $response['message'] = sprintf( '<p>%s <a href="edit.php?post_type=lp_course">%s</a> </p>', __( 'Successfully import sample data.', 'learnpress' ), __( 'View courses', 'learnpress' ) );
1024
- }
1025
- }
1026
- if ( $response['result'] == 'fail' ) {
1027
- $response['message'] = sprintf( '<p>%s</p>%s', __( 'Failed to import sample data. Please try again.', 'learnpress' ), $buttons );
1028
- }
1029
- } else {
1030
- $response['result'] = 'fail';
1031
- $response['message'] = sprintf( '<p>%s</p>', __( 'Unknown error when installing/activating Import/Export add-on. Please try again!', 'learnpress' ) ) . $buttons;
1032
- }
1033
- }
1034
- learn_press_send_json( $response );
1035
- die();
1036
- }*/
1037
-
1038
- /**
1039
- * Activate a bundle of add-ons, if an add-on is not installed then install it first
1040
- *
1041
- * @editor tungnx
1042
- * @model 4.1.4 comment - not use
1043
- */
1044
- /*public static function bundle_activate_add_ons() {
1045
- global $learn_press_add_ons;
1046
- include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; // for plugins_api..
1047
- $response = array( 'addons' => array() );
1048
-
1049
- if ( ! current_user_can( 'activate_plugins' ) ) {
1050
- $response['error'] = __( 'You do not have the permission to deactivate plugins on this site.', 'learnpress' );
1051
- } else {
1052
-
1053
- $add_ons = $learn_press_add_ons['bundle_activate'];
1054
-
1055
- if ( $add_ons ) {
1056
- foreach ( $add_ons as $slug ) {
1057
- $response['addons'][ $slug ] = learn_press_install_and_active_add_on( $slug );
1058
- }
1059
- }
1060
- }
1061
- learn_press_send_json( $response );
1062
- }*/
1063
-
1064
- /**
1065
- * Activate a bundle of add-ons, if an add-on is not installed then install it first
1066
- *
1067
- * @editor tungnx
1068
- * @model 4.1.4 comment - not use
1069
- */
1070
- /*public static function bundle_activate_add_on() {
1071
- $response = array();
1072
- include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; // for plugins_api..
1073
- if ( ! current_user_can( 'activate_plugins' ) ) {
1074
- $response['error'] = __( 'You do not have the permission to deactivate plugins on this site.', 'learnpress' );
1075
- } else {
1076
- $slug = ! empty( $_REQUEST['plugin'] ) ? $_REQUEST['plugin'] : null;
1077
- $response[ $slug ] = learn_press_install_and_active_add_on( $slug );
1078
- }
1079
- learn_press_send_json( $response );
1080
- }*/
1081
-
1082
- /**
1083
- * @editor tungnx
1084
- * @reason not use
1085
- * @deprecated 4.0.0.
1086
- */
1087
- /*
1088
- public static function plugin_install() {
1089
- $plugin_name = ! empty( $_REQUEST['plugin'] ) ? $_REQUEST['plugin'] : '';
1090
- $response = learn_press_install_add_on( $plugin_name );
1091
- learn_press_send_json( $response );
1092
- die();
1093
- }*/
1094
-
1095
- /*
1096
- * @editor tungnx
1097
- * @reason not use
1098
- * @since 3.2.6.8
1099
- */
1100
- /*
1101
- public static function update_add_on_status() {
1102
- $plugin = ! empty( $_REQUEST['plugin'] ) ? $_REQUEST['plugin'] : '';
1103
- $t = ! empty( $_REQUEST['t'] ) ? $_REQUEST['t'] : '';
1104
- $response = array();
1105
- if ( ! current_user_can( 'activate_plugins' ) ) {
1106
- $response['error'] = __( 'You do not have the permission to deactivate plugins on this site.', 'learnpress' );
1107
- }
1108
- if ( $plugin && $t ) {
1109
- if ( $t == 'activate' ) {
1110
- activate_plugin( $plugin, false, is_network_admin() );
1111
- } else {
1112
- deactivate_plugins( $plugin, false, is_network_admin() );
1113
- }
1114
- $is_activate = is_plugin_active( $plugin );
1115
- $response['status'] = $is_activate ? 'activate' : 'deactivate';
1116
-
1117
- }
1118
- wp_send_json( $response );
1119
- die();
1120
- }*/
1121
-
1122
- /**
1123
- * Output the image to browser with text and params passed via $_GET
1124
- */
1125
- /*public static function dummy_image() {
1126
- $text = LP_Helper::sanitize_params_submitted( $_REQUEST['text'] ?? '' );
1127
- learn_press_text_image( $text, $_GET );
1128
- die();
1129
- }*/
1130
-
1131
  /**
1132
  * Get edit|view link of a page
1133
  */
@@ -1158,176 +659,6 @@ if ( ! class_exists( 'LP_Admin_Ajax' ) ) {
1158
  die();
1159
  }
1160
 
1161
- /**
1162
- * @editor tungnx
1163
- * @model 4.1.4 comment - not use
1164
- */
1165
- /*public static function ignore_setting_up() {
1166
- update_option( '_lpr_ignore_setting_up', 1, true );
1167
- die;
1168
- }*/
1169
-
1170
- /**
1171
- * @editor tungnx
1172
- * @model 4.1.4 comment - not use
1173
- */
1174
- /*public static function remove_notice_popup() {
1175
- if ( isset( $_POST['action'] ) && $_POST['action'] === 'learnpress_remove_notice_popup' && isset( $_POST['slug'] ) && ! empty( $_POST['slug'] ) && isset( $_POST['user'] ) && ! empty( $_POST['user'] ) ) {
1176
- $slug = 'learnpress_notice_' . $_POST['slug'] . '_' . $_POST['user'];
1177
- set_transient( $slug, true, 30 * DAY_IN_SECONDS );
1178
- }
1179
-
1180
- wp_die();
1181
- }*/
1182
-
1183
- /*
1184
- public static function update_order_status() {
1185
-
1186
- $order_id = learn_press_get_request( 'order_id' );
1187
- $value = learn_press_get_request( 'value' );
1188
-
1189
- $order = array(
1190
- 'ID' => $order_id,
1191
- 'post_status' => $value,
1192
- );
1193
-
1194
- wp_update_post( $order ) ? $response['success'] = true : $response['success'] = false;
1195
-
1196
- learn_press_send_json( $response );
1197
-
1198
- die();
1199
- }*/
1200
-
1201
- /**
1202
- * Upload avatar of user
1203
- *
1204
- * @editor tungnx
1205
- * @modify 4.1.5
1206
- */
1207
- // public static function upload_user_avatar() {
1208
- // $user_id = get_current_user_id();
1209
-
1210
- // if ( ! $user_id ) {
1211
- // return;
1212
- // }
1213
-
1214
- // $file = $_FILES['lp-upload-avatar'];
1215
- // $upload_dir = learn_press_user_profile_picture_upload_dir();
1216
-
1217
- // add_filter( 'upload_dir', array( __CLASS__, '_user_avatar_upload_dir' ), 10000 );
1218
-
1219
- // $file_info_arr = explode( '.', $file['name'] );
1220
- // $file_info_arr_length = count( $file_info_arr );
1221
- // $file_ext_index = $file_info_arr_length - 1;
1222
- // $file_ext = $file_info_arr[ $file_ext_index ];
1223
- // $file['name'] = $user_id . '.' . $file_ext;
1224
-
1225
- // // Delete old image if exists
1226
- // $path_img = get_user_meta( $user_id, '_lp_profile_picture', true );
1227
- // if ( $path_img ) {
1228
- // $path = $upload_dir['basedir'] . '/' . $path_img;
1229
- // if ( file_exists( $path ) ) {
1230
- // @unlink( $path );
1231
- // }
1232
- // }
1233
-
1234
- // $result = wp_handle_upload(
1235
- // $file,
1236
- // array(
1237
- // 'test_form' => false,
1238
- // )
1239
- // );
1240
-
1241
- // remove_filter( 'upload_dir', array( __CLASS__, '_user_avatar_upload_dir' ), 10000 );
1242
- // if ( is_array( $result ) ) {
1243
- // $result['name'] = $upload_dir['subdir'] . '/' . basename( $result['file'] );
1244
- // update_user_meta( $user_id, '_lp_profile_picture', $result['name'] );
1245
- // unset( $result['file'] );
1246
- // } else {
1247
- // $result = array(
1248
- // 'error' => __( 'Profile picture upload failed', 'learnpress' ),
1249
- // );
1250
- // }
1251
- // learn_press_send_json( $result );
1252
- // }
1253
-
1254
- // /**
1255
- // * Crop avatar of user
1256
- // *
1257
- // * @editor tungnx
1258
- // * @return void
1259
- // */
1260
- // public static function save_uploaded_user_avatar() {
1261
- // $avatar_data = wp_parse_args(
1262
- // LP_Request::get( 'lp-user-avatar-crop' ),
1263
- // array(
1264
- // 'name' => '',
1265
- // 'width' => '',
1266
- // 'height' => '',
1267
- // 'points' => '',
1268
- // 'nonce' => '',
1269
- // )
1270
- // );
1271
-
1272
- // $current_user_id = get_current_user_id();
1273
-
1274
- // if ( ! wp_verify_nonce( $avatar_data['nonce'], 'save-uploaded-profile-' . $current_user_id ) ) {
1275
- // die( 'ERROR VERIFY NONCE!' );
1276
- // }
1277
-
1278
- // $url = learn_press_update_user_profile_avatar();
1279
- // if ( $url ) {
1280
- // learn_press_send_json(
1281
- // array(
1282
- // 'success' => true,
1283
- // 'avatar' => sprintf( '<img src="%s" />', $url ),
1284
- // )
1285
- // );
1286
- // };
1287
-
1288
- // wp_die();
1289
- // }
1290
-
1291
- // /**
1292
- // * Remove avatar of user
1293
- // *
1294
- // * @author tungnx
1295
- // * @since 4.1.5
1296
- // * @version 1.0.0
1297
- // * @return void
1298
- // */
1299
- // public static function remove_avatar() {
1300
- // $response = new LP_REST_Response();
1301
-
1302
- // try {
1303
- // $user_id = get_current_user_id();
1304
- // if ( ! $user_id ) {
1305
- // throw new Exception( __( 'User is invalid', 'learnpress' ) );
1306
- // }
1307
-
1308
- // // Delete old image if exists
1309
- // $path_img = get_user_meta( $user_id, '_lp_profile_picture', true );
1310
- // if ( $path_img ) {
1311
- // $upload_dir = learn_press_user_profile_picture_upload_dir();
1312
- // $path = $upload_dir['basedir'] . '/' . $path_img;
1313
- // if ( file_exists( $path ) ) {
1314
- // unlink( $path );
1315
- // $response->status = 'success';
1316
- // }
1317
- // }
1318
- // } catch ( Throwable $e ) {
1319
- // $response->message = $e->getMessage();
1320
- // }
1321
-
1322
- // wp_send_json( $response );
1323
- // }
1324
-
1325
- // public static function _user_avatar_upload_dir( $dir ) {
1326
- // $dir = learn_press_user_profile_picture_upload_dir();
1327
-
1328
- // return $dir;
1329
- // }
1330
-
1331
  /**
1332
  * Export Order invoice to PDF
1333
  *
@@ -1336,12 +667,6 @@ if ( ! class_exists( 'LP_Admin_Ajax' ) ) {
1336
  */
1337
  public static function update_order_exports() {
1338
  $order_id = absint( $_POST['order_id'] );
1339
- //$site_title = LP_Helper::sanitize_params_submitted( $_POST['site_title'] );
1340
- //$order_date = LP_Helper::sanitize_params_submitted( $_POST['order_date'] );
1341
- //$invoice_no = LP_Helper::sanitize_params_submitted( $_POST['invoice_no'] );
1342
- //$order_customer = LP_Helper::sanitize_params_submitted( $_POST['order_customer'] );
1343
- //$order_email = LP_Helper::sanitize_params_submitted( $_POST['order_email'] );
1344
- //$order_payment = LP_Helper::sanitize_params_submitted( $_POST['order_payment'] );
1345
  $order = learn_press_get_order( $order_id );
1346
  $currency_symbol = learn_press_get_currency_symbol( $order->get_currency() );
1347
 
@@ -1359,11 +684,5 @@ if ( ! class_exists( 'LP_Admin_Ajax' ) ) {
1359
  }
1360
  }
1361
 
1362
- // if ( defined( 'DOING_AJAX' ) ) {
1363
- // add_action( 'wp_ajax_learnpress_upload-user-avatar', array( 'LP_Admin_Ajax', 'upload_user_avatar' ) );
1364
- // add_action( 'wp_ajax_learnpress_save-uploaded-user-avatar', array( 'LP_Admin_Ajax', 'save_uploaded_user_avatar' ) );
1365
- // add_action( 'wp_ajax_learnpress_remove-avatar', array( 'LP_Admin_Ajax', 'remove_avatar' ) );
1366
- // }
1367
-
1368
  add_action( 'init', array( 'LP_Admin_Ajax', 'init' ) );
1369
  }
117
  }
118
  }
119
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
  /**
121
  * Search user on some pages on the Backend
122
  */
202
  learn_press_send_json_success( $result );
203
  }
204
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
205
  /**
206
  * Duplicate course, lesson, quiz, question.
207
  *
328
  learn_press_send_json( $response );
329
  }
330
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
331
  /**
332
  * Search items by requesting params.
333
  */
566
  $statistic->load_chart();
567
  }
568
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
569
  public static function json_search_customer_name( $query ) {
570
  global $wpdb;
571
 
580
  $query->query_where .= $wpdb->prepare( ' OR user_name.meta_value LIKE %s ', '%' . $term . '%' );
581
  }
582
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
583
  /**
584
  * create new page on LP Settings
585
  *
629
  learn_press_send_json( $response );
630
  }
631
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
632
  /**
633
  * Get edit|view link of a page
634
  */
659
  die();
660
  }
661
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
662
  /**
663
  * Export Order invoice to PDF
664
  *
667
  */
668
  public static function update_order_exports() {
669
  $order_id = absint( $_POST['order_id'] );
 
 
 
 
 
 
670
  $order = learn_press_get_order( $order_id );
671
  $currency_symbol = learn_press_get_currency_symbol( $order->get_currency() );
672
 
684
  }
685
  }
686
 
 
 
 
 
 
 
687
  add_action( 'init', array( 'LP_Admin_Ajax', 'init' ) );
688
  }
inc/admin/class-lp-admin-assets.php CHANGED
@@ -62,14 +62,14 @@ class LP_Admin_Assets extends LP_Abstract_Assets {
62
  protected function _get_scripts(): array {
63
  $lp_admin_js = new LP_Asset_Key(
64
  $this->url( self::$_folder_source . 'js/admin/admin' . self::$_min_assets . '.js' ),
65
- array( 'learn-press-global', 'lp-utils', 'wp-color-picker', 'jspdf' ),
66
  array(),
67
  0,
68
  1
69
  );
70
  $lp_admin_js->exclude_screen( array( 'plugin-install' ) );
71
 
72
- return apply_filters(
73
  'learn-press/admin-default-scripts',
74
  array(
75
  // need build if change source vue
@@ -277,6 +277,8 @@ class LP_Admin_Assets extends LP_Abstract_Assets {
277
  ),
278
  )
279
  );
 
 
280
  }
281
 
282
  /**
62
  protected function _get_scripts(): array {
63
  $lp_admin_js = new LP_Asset_Key(
64
  $this->url( self::$_folder_source . 'js/admin/admin' . self::$_min_assets . '.js' ),
65
+ array( 'learn-press-global', 'lp-utils', 'wp-color-picker', 'jspdf', 'vue-libs', 'wp-i18n' ),
66
  array(),
67
  0,
68
  1
69
  );
70
  $lp_admin_js->exclude_screen( array( 'plugin-install' ) );
71
 
72
+ $scripts = apply_filters(
73
  'learn-press/admin-default-scripts',
74
  array(
75
  // need build if change source vue
277
  ),
278
  )
279
  );
280
+
281
+ return $scripts;
282
  }
283
 
284
  /**
inc/admin/class-lp-setup-wizard.php CHANGED
@@ -56,7 +56,7 @@ class LP_Setup_Wizard {
56
  */
57
  public static function get_price_format() {
58
  self::instance()->save();
59
- LP()->settings()->refresh();
60
  echo learn_press_format_price( 1234.56, true );
61
  die();
62
  }
@@ -123,7 +123,7 @@ class LP_Setup_Wizard {
123
  $this->save();
124
 
125
  // Refresh new changes
126
- // LP()->settings()->refresh();
127
 
128
  $assets = learn_press_admin_assets();
129
 
@@ -314,7 +314,7 @@ class LP_Setup_Wizard {
314
  $at ++;
315
  }
316
 
317
- return add_query_arg( 'step', $steps[ $at ], admin_url( $this->_base_url ) );
318
  }
319
 
320
  /**
@@ -330,7 +330,7 @@ class LP_Setup_Wizard {
330
  $at --;
331
  }
332
 
333
- return add_query_arg( 'step', $steps[ $at ], admin_url( $this->_base_url ) );
334
  }
335
 
336
  /**
56
  */
57
  public static function get_price_format() {
58
  self::instance()->save();
59
+ // LP_Settings::instance()->refresh();
60
  echo learn_press_format_price( 1234.56, true );
61
  die();
62
  }
123
  $this->save();
124
 
125
  // Refresh new changes
126
+ // LP_Settings::instance()->refresh();
127
 
128
  $assets = learn_press_admin_assets();
129
 
314
  $at ++;
315
  }
316
 
317
+ return esc_url( add_query_arg( 'step', $steps[ $at ], admin_url( $this->_base_url ) ) );
318
  }
319
 
320
  /**
330
  $at --;
331
  }
332
 
333
+ return esc_url( add_query_arg( 'step', $steps[ $at ], admin_url( $this->_base_url ) ) );
334
  }
335
 
336
  /**
inc/admin/lp-admin-actions.php CHANGED
@@ -261,9 +261,17 @@ function learn_press_admin_course_tabs() {
261
  echo '<h2 class="nav-tab-wrapper lp-nav-tab-wrapper">';
262
 
263
  foreach ( $admin_tabs_on_page[ $current_page_id ] as $admin_tab_id ) {
264
-
265
  $class = ( $admin_tabs[ $admin_tab_id ]['id'] == $current_page_id ) ? 'nav-tab nav-tab-active' : 'nav-tab';
266
- echo '<a href="' . admin_url( $admin_tabs[ $admin_tab_id ]['link'] ) . '" class="' . $class . ' nav-tab-' . $admin_tabs[ $admin_tab_id ]['id'] . '">' . $admin_tabs[ $admin_tab_id ]['name'] . '</a>';
 
 
 
 
 
 
 
 
 
267
  }
268
 
269
  echo '</h2>';
261
  echo '<h2 class="nav-tab-wrapper lp-nav-tab-wrapper">';
262
 
263
  foreach ( $admin_tabs_on_page[ $current_page_id ] as $admin_tab_id ) {
 
264
  $class = ( $admin_tabs[ $admin_tab_id ]['id'] == $current_page_id ) ? 'nav-tab nav-tab-active' : 'nav-tab';
265
+ // echo '<a href="' . admin_url( $admin_tabs[ $admin_tab_id ]['link'] ) . '" class="' . $class . ' nav-tab-' . $admin_tabs[ $admin_tab_id ]['id'] . '">' . $admin_tabs[ $admin_tab_id ]['name'] . '</a>';
266
+ echo wp_kses(
267
+ sprintf(
268
+ '<a href="%s" class="%s">%s</a>',
269
+ admin_url( $admin_tabs[ $admin_tab_id ]['link'] ),
270
+ $class . ' nav-tab-' . $admin_tabs[ $admin_tab_id ]['id'],
271
+ $admin_tabs[ $admin_tab_id ]['name']
272
+ ),
273
+ true
274
+ );
275
  }
276
 
277
  echo '</h2>';
inc/admin/lp-admin-functions.php CHANGED