LearnPress – WordPress LMS Plugin - Version 4.1.6.3

Version Description

(2022-04-20) = ~ Fixed: sort section of course. ~ Fixed: sort item of course's section when edit course. ~ Fixed: sometime call get_curriculum empty. ~ Modified: fixed when set seconds big (about 100 hours), can't convert to format time right. ~ Fixed: duplicate course not duplicate sections, items. ~ Fixed: error wp.media on page Email setting. ~ Fixed: count wrong order on the backend.

Download this release

Release Info

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

Code changes from version 4.1.6.2 to 4.1.6.3

assets/js/dist/frontend/single-course.js CHANGED
@@ -395,9 +395,9 @@ function courseCurriculumSkeleton() {
395
  const {
396
  data,
397
  status,
398
- message,
399
- section_ids
400
  } = response;
 
401
 
402
  if (status === 'error') {
403
  throw new Error(message || 'Error');
@@ -408,6 +408,7 @@ function courseCurriculumSkeleton() {
408
  if (undefined === returnData) {
409
  // For old Eduma <= 4.6.0
410
  returnData = data;
 
411
  }
412
 
413
  if (sectionID) {
@@ -497,7 +498,7 @@ function courseCurriculumSkeleton() {
497
  if (pages3 <= paged3 || pages3 <= page) {
498
  itemLoadMore.remove();
499
  } else {
500
- itemLoadMore.dataset.page = paged3;
501
  }
502
 
503
  if (data3 && sectionContent) {
395
  const {
396
  data,
397
  status,
398
+ message
 
399
  } = response;
400
+ let section_ids = data.section_ids;
401
 
402
  if (status === 'error') {
403
  throw new Error(message || 'Error');
408
  if (undefined === returnData) {
409
  // For old Eduma <= 4.6.0
410
  returnData = data;
411
+ section_ids = response.section_ids;
412
  }
413
 
414
  if (sectionID) {
498
  if (pages3 <= paged3 || pages3 <= page) {
499
  itemLoadMore.remove();
500
  } else {
501
+ itemLoadMore.dataset.page = page;
502
  }
503
 
504
  if (data3 && sectionContent) {
assets/js/dist/frontend/single-course.min.js CHANGED
@@ -1 +1 @@
1
- !function(){"use strict";var e={n:function(t){var s=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(s,{a:s}),s},d:function(t,s){for(var o in s)e.o(s,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:s[o]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}};window.wp.element,window.LP.quiz;const t=jQuery,{throttle:s}=lodash,o=()=>{const e=document.querySelector("#sidebar-toggle");e&&(t(window).innerWidth()<=768||LP.Cookies.get("sidebar-toggle")?e.setAttribute("checked","checked"):e.removeAttribute("checked"),document.querySelector("#popup-course").addEventListener("click",(e=>{var s;"sidebar-toggle"===e.target.id&&(LP.Cookies.set("sidebar-toggle",!!e.target.checked),s=LP.Cookies.get("sidebar-toggle"),t("body").removeClass("lp-sidebar-toggle__open"),t("body").removeClass("lp-sidebar-toggle__close"),s?t("body").addClass("lp-sidebar-toggle__close"):t("body").addClass("lp-sidebar-toggle__open"))}))),t("#learn-press-course-curriculum").find(".section-desc").each(((e,s)=>{const o=t('<span class="show-desc"></span>').on("click",(()=>{r.toggleClass("c")})),r=t(s).siblings(".section-title").append(o)})),t(".section").each((function(){const e=t(this);e.find(".section-left").on("click",(function(){const t=e.toggleClass("closed").hasClass("closed"),s=LP.Cookies.get("closed-section-"+lpGlobalSettings.post_id)||[],o=parseInt(e.data("section-id")),r=s.findIndex((e=>e==o));t?s.push(parseInt(e.data("section-id"))):s.splice(r,1),LP.Cookies.remove("closed-section-(.*)"),LP.Cookies.set("closed-section-"+lpGlobalSettings.post_id,[...new Set(s)])}))}))};document.addEventListener("DOMContentLoaded",(()=>{o()}));var r=window.wp.url;const a=jQuery;let n=null;const l={elLPOverlay:null,elMainContent:null,elTitle:null,elBtnYes:null,elBtnNo:null,elFooter:null,elCalledModal:null,callBackYes:null,instance:null,init(){return!!this.instance||(this.elLPOverlay=a(".lp-overlay"),!!this.elLPOverlay.length&&(n=this.elLPOverlay,this.elMainContent=n.find(".main-content"),this.elTitle=n.find(".modal-title"),this.elBtnYes=n.find(".btn-yes"),this.elBtnNo=n.find(".btn-no"),this.elFooter=n.find(".lp-modal-footer"),a(document).on("click",".close, .btn-no",(function(){n.hide()})),a(document).on("click",".btn-yes",(function(e){e.preventDefault(),e.stopPropagation(),"function"==typeof l.callBackYes&&l.callBackYes()})),this.instance=this,!0))},setElCalledModal(e){this.elCalledModal=e},setContentModal(e,t){this.elMainContent.html(e),"function"==typeof t&&t()},setTitleModal(e){this.elTitle.html(e)}};var c=l;jQuery;var i={elBtnFinishCourse:null,elBtnCompleteItem:null,init(){c.init()&&void 0!==lpGlobalSettings&&"yes"===lpGlobalSettings.option_enable_popup_confirm_finish&&(this.elBtnFinishCourse=document.querySelectorAll(".lp-btn-finish-course"),this.elBtnCompleteItem=document.querySelector(".lp-btn-complete-item"),this.elBtnCompleteItem&&this.elBtnCompleteItem.addEventListener("click",(e=>{e.preventDefault();const t=e.target.closest("form");c.elLPOverlay.show(),c.setTitleModal(t.dataset.title),c.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),c.callBackYes=()=>{t.submit()}})),this.elBtnFinishCourse&&this.elBtnFinishCourse.forEach((e=>e.addEventListener("click",(e=>{e.preventDefault();const t=e.target.closest("form");c.elLPOverlay.show(),c.setTitleModal(t.dataset.title),c.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),c.callBackYes=()=>{t.submit()}})))))}},d=window.wp.apiFetch,u=e.n(d);const p=jQuery;var m={init(){this.scrollToItemViewing=function(){const e=p(".viewing-course-item");if(e.length){const t=p("#learn-press-course-curriculum"),s=(p("#popup-sidebar").outerHeight(),p(".section-title").outerHeight(),p(".section-header").outerHeight()),o=new RegExp("^viewing-course-item-([0-9].*)"),r=e.attr("class").split(/\s+/);let a=0;if(p.each(r,(function(e,t){const s=o.exec(t);if(s)return a=s[1],!1})),0===a)return;const n=p(".course-item-"+a),l=(n.offset().top,n.offset().top-t.offset().top+t.scrollTop());t.animate({scrollTop:LP.Hook.applyFilters("scroll-item-current",l-s)},800)}},this.scrollToItemViewing()}};const g=()=>{const e=document.querySelector("#popup-course"),t=document.querySelector("#learn-press-course-curriculum");if(e&&t){const s=t.querySelector(".curriculum-sections"),o=e.querySelector(".search-course"),r=e.querySelector('.search-course input[type="text"]');if(!r||!s||!o)return;const a=s.querySelectorAll("li.section"),n=s.querySelectorAll("li.course-item"),l=[];n.forEach((e=>{const t=e.dataset.id,s=e.querySelector(".item-name");l.push({id:t,name:s?s.textContent.toLowerCase():""})}));const c=e=>{e.preventDefault();const t=r.value;o.classList.add("searching"),t||o.classList.remove("searching");const s=[];l.forEach((e=>{t&&!e.name.match(t.toLowerCase())||(s.push(e.id),n.forEach((e=>{-1!==s.indexOf(e.dataset.id)?e.classList.remove("hide-if-js"):e.classList.add("hide-if-js")})))})),a.forEach((e=>{const t=e.querySelectorAll(".course-item"),o=[];t.forEach((e=>{s.includes(e.dataset.id)&&o.push(e.dataset.id)})),0===o.length?e.classList.add("hide-if-js"):e.classList.remove("hide-if-js")}))},i=o.querySelector(".clear");i&&i.addEventListener("click",(e=>{e.preventDefault(),r.value="",c(e)})),o.addEventListener("submit",c),r.addEventListener("keyup",c)}};function h(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";const t=()=>{const e=document.querySelector(".learnpress-course-curriculum");e&&s(e)},s=async t=>{const s=t.querySelector(".lp-skeleton-animation"),a=t.dataset.id,l=t.dataset.section;try{const s=1,c=await u()({path:(0,r.addQueryArgs)("lp/v1/lazy-load/course-curriculum",{courseId:e||lpGlobalSettings.post_id||"",page:s,sectionID:l||""}),method:"GET"}),{data:i,status:d,message:p,section_ids:m}=c;if("error"===d)throw new Error(p||"Error");let g=i.content;if(void 0===g&&(g=i),l)if(m&&!m.includes(l)){const e=await n("",s+1,l);if(e){const{data2:s,pages2:r,page2:n}=e;await o({ele:t,returnData:g,sectionID:l,itemID:a,data2:s,pages2:r,page2:n})}}else await o({ele:t,returnData:g,sectionID:l,itemID:a});else g&&t.insertAdjacentHTML("beforeend",g)}catch(e){t.insertAdjacentHTML("beforeend",`<div class="lp-ajax-message error" style="display:block">${e.message||"Error: Query lp/v1/lazy-load/course-curriculum"}</div>`)}s&&s.remove(),g()},o=async e=>{let{ele:t,returnData:s,sectionID:o,itemID:r,data2:n,pages2:l,page2:c}=e;const i=(new DOMParser).parseFromString(s,"text/html");if(n){const e=i.querySelector(".curriculum-sections"),t=i.querySelector(".curriculum-more__button");t&&(l<=c?t.remove():t.dataset.page=c),e.insertAdjacentHTML("beforeend",n)}const d=i.querySelector(`[data-section-id="${o}"]`);if(d){const e=[...d.querySelectorAll(".course-item")].map((e=>e.dataset.id)),t=d.querySelector(".section-content"),s=d.querySelector(".section-item__loadmore");if(r&&!e.includes(r)){const e=await a("",2,o,r),{data3:n,pages3:l,paged3:c,page:i}=e;l<=c||l<=i?s.remove():s.dataset.page=c,n&&t&&t.insertAdjacentHTML("beforeend",n)}}t.insertAdjacentHTML("beforeend",i.body.innerHTML),m.init()},a=async(e,t,s,o)=>{const n=await u()({path:(0,r.addQueryArgs)("lp/v1/lazy-load/course-curriculum-items",{sectionId:s||"",page:t}),method:"GET"}),{data:l,status:c,pages:i,message:d}=n,{page:p}=l;let m;if("success"===c){let r=l.content;if(m=l.item_ids,void 0===r&&(r=l,m=n.item_ids),e+=r,s&&m&&o&&!m.includes(o))return a(e,t+1,s,o)}return{data3:e,pages3:i||l.pages,status3:c,message3:d,page:p||0}},n=async(t,s,o)=>{const a=await u()({path:(0,r.addQueryArgs)("lp/v1/lazy-load/course-curriculum",{courseId:e||lpGlobalSettings.post_id||"",page:s,sectionID:o||"",loadMore:!0}),method:"GET"}),{data:l,pages:c,status:i,message:d,section_ids:p}=a;let m=l.content;return void 0===m&&(m=l),"success"===i&&(t+=m,o&&p&&p.length>0&&!p.includes(o))?n(t,s+1,o):{data2:t,pages2:c||l.pages,page2:s,status2:i,message2:d}};t(),document.addEventListener("click",(e=>{[...document.querySelectorAll(".section-item__loadmore")].map((async t=>{if(t.contains(e.target)){const e=t.parentNode,s=e.getAttribute("data-section-id"),o=e.querySelector(".section-content"),r=parseInt(t.dataset.page);t.classList.add("loading");try{const e=await a("",r+1,s,""),{data3:n,pages3:l,status3:c,message3:i}=e;if("error"===c)throw new Error(i||"Error");l<=r+1?t.remove():t.dataset.page=r+1,o.insertAdjacentHTML("beforeend",n)}catch(e){o.insertAdjacentHTML("beforeend",`<div class="lp-ajax-message error" style="display:block">${e.message||"Error: Query lp/v1/lazy-load/course-curriculum"}</div>`)}t.classList.remove("loading"),g()}})),[...document.querySelectorAll(".curriculum-more__button")].map((async t=>{if(t.contains(e.target)){const e=parseInt(t.dataset.page),s=t.parentNode.parentNode.querySelector(".curriculum-sections");if(e&&s){t.classList.add("loading");try{const o=await n("",e+1,""),{data2:r,pages2:a,status2:l,message2:c}=o;if("error"===l)throw new Error(c||"Error");a<=e+1?t.remove():t.dataset.page=e+1,s.insertAdjacentHTML("beforeend",r)}catch(e){s.insertAdjacentHTML("beforeend",`<div class="lp-ajax-message error" style="display:block">${e.message||"Error: Query lp/v1/lazy-load/course-curriculum"}</div>`)}t.classList.remove("loading"),g()}}})),document.querySelector(".learnpress-course-curriculum")&&[...document.querySelectorAll(".section")].map((t=>{t.contains(e.target)&&t.querySelector(".section-left").contains(e.target)&&t.classList.toggle("closed")}))}))}const y=jQuery;y(window).on("load",(()=>{y("#popup-course"),y("#learn-press-course-curriculum"),[...document.querySelectorAll(".course-extra-box")].map((e=>{const t=e.querySelector(".course-extra-box__title");t.addEventListener("click",(()=>{const s=t.nextElementSibling,o=document.querySelector(".course-extra-box.active");o&&!e.classList.contains("active")&&(o.classList.remove("active"),o.querySelector(".course-extra-box__content").style.display="none"),e.classList.contains("active")?(e.classList.remove("active"),s.style.display="none"):(e.classList.add("active"),s.style.display="block")}))})),y("#learn-press-course-tabs").on("change",'input[name="learn-press-course-tab-radio"]',(function(e){const t=y('input[name="learn-press-course-tab-radio"]:checked').val();LP.Cookies.set("course-tab",t),y('label[for="'+y(e.target).attr("id")+'"]').closest("li").addClass("active").siblings().removeClass("active")})),function(){const e=y(".course-summary-sidebar");if(!e.length)return;const t=y(window),s=e.children(),o=e.offset();let r=0;const a=e.height(),n=s.height();t.on("scroll.fixed-course-sidebar",(function(){r=t.scrollTop();const l=r-o.top+32;if(l<0)return e.removeClass("slide-top slide-down"),void s.css("top","");l>a-n?(e.removeClass("slide-down").addClass("slide-top"),s.css("top",a-n)):(e.removeClass("slide-top").addClass("slide-down"),s.css("top",32))})).trigger("scroll.fixed-course-sidebar")}(),(()=>{const e=document.querySelectorAll("form.enroll-course");e.length>0&&e.forEach((e=>{e.addEventListener("submit",(t=>{t.preventDefault();const s=e.querySelector("input[name=enroll-course]").value,o=e.querySelector("button.button-enroll-course");o.classList.add("loading"),o.disabled=!0,(async(t,s)=>{try{const o=await wp.apiFetch({path:"lp/v1/courses/enroll-course",method:"POST",data:{id:t}});s.classList.remove("loading"),s.disabled=!1;const{status:r,data:{redirect:a},message:n}=o;n&&r&&(s.style.display="none",e.innerHTML+=`<div class="lp-enroll-notice ${r}">${n}</div>`,a&&(window.location.href=a))}catch(e){form.innerHTML+=`<div class="lp-enroll-notice error">${e.message&&e.message}</div>`}})(s,o)}))})),null!==document.querySelector(".course-detail-info")&&window.addEventListener("pageshow",(e=>{(e.persisted||void 0!==window.performance&&"back_forward"==String(window.performance.getEntriesByType("navigation")[0].type))&&location.reload()}))})(),(()=>{const e=document.querySelectorAll("form.purchase-course");e.length>0&&e.forEach((e=>{const t=()=>{document.querySelectorAll(".lp_allow_repuchase_select").forEach((t=>{const o=t.querySelectorAll("[name=_lp_allow_repurchase_type]");for(let t=0,r=o.length;t<r;t++)if(o[t].checked){const r=o[t].value,a=e.querySelector("input[name=purchase-course]").value,n=e.querySelector("button.button-purchase-course");n.classList.add("loading"),n.disabled=!0,s(a,n,r);break}}))},s=async function(s,o){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];try{const a=await wp.apiFetch({path:"lp/v1/courses/purchase-course",method:"POST",data:{id:s,repurchaseType:r}});o&&(o.classList.remove("loading"),o.disabled=!1);const{status:n,data:{redirect:l,type:i,html:d,titlePopup:u},message:p}=a;if("allow_repurchase"===i&&"success"===n){if(!e.querySelector(".lp_allow_repuchase_select")){if(!c.init())return;c.elLPOverlay.show(),c.setTitleModal(u||""),c.setContentModal(d),c.callBackYes=()=>{c.elLPOverlay.hide(),t()}}}else p&&n&&(e.innerHTML+=`<div class="lp-enroll-notice ${n}">${p}</div>`,"success"===n&&l&&(window.location.href=l))}catch(t){e.innerHTML+=`<div class="lp-enroll-notice error">${t.message&&t.message}</div>`}};e.addEventListener("submit",(t=>{t.preventDefault();const o=e.querySelector("input[name=purchase-course]").value,r=e.querySelector("button.button-purchase-course");r.classList.add("loading"),r.disabled=!0,s(o,r)}))}))})(),(()=>{const e=document.querySelectorAll(".lp-form-retake-course");e.length&&e.forEach((e=>{const t=e.querySelector(".button-retake-course"),s=e.querySelector("[name=retake-course]").value,o=e.querySelector(".lp-ajax-message");e.addEventListener("submit",(e=>{e.preventDefault()})),t.addEventListener("click",(e=>{var r;e.preventDefault(),t.classList.add("loading"),t.disabled=!0,r=t,wp.apiFetch({path:"/lp/v1/courses/retake-course",method:"POST",data:{id:s}}).then((e=>{const{status:t,message:s,data:a}=e;o.innerHTML=s,null!=t&&"success"===t?(r.style.display="none",setTimeout((()=>{window.location.replace(a.url_redirect)}),1e3)):o.classList.add("error")})).catch((e=>{o.classList.add("error"),o.innerHTML="error: "+e.message})).then((()=>{r.classList.remove("loading"),r.disabled=!1,o.style.display="block"}))}))}))})(),(()=>{const e=document.querySelectorAll(".lp-course-progress-wrapper");if(!e.length)return;if("IntersectionObserver"in window){const s=new IntersectionObserver(((e,o)=>{e.forEach((e=>{if(e.isIntersecting){const o=e.target;setTimeout((function(){t(o)}),600),s.unobserve(o)}}))}));[...e].map((e=>s.observe(e)))}const t=async e=>{const t=await wp.apiFetch({path:"lp/v1/lazy-load/course-progress",method:"POST",data:{courseId:lpGlobalSettings.post_id||"",userId:lpGlobalSettings.user_id||""}}),{data:s}=t;e.innerHTML=s}})(),(()=>{const e=document.querySelector("form.continue-course");null!=e&&(async e=>await wp.apiFetch({path:"lp/v1/courses/continue-course",method:"POST",data:{courseId:lpGlobalSettings.post_id||"",userId:lpGlobalSettings.user_id||""}}))().then((function(t){"success"===t.status&&(e.style.display="block",e.action=t.data)}))})(),i.init(),h()})),LP.Hook.addAction("lp_course_curriculum_skeleton",(function(e){h(e)}))}();
1
+ !function(){"use strict";var e={n:function(t){var s=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(s,{a:s}),s},d:function(t,s){for(var o in s)e.o(s,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:s[o]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}};window.wp.element,window.LP.quiz;const t=jQuery,{throttle:s}=lodash,o=()=>{const e=document.querySelector("#sidebar-toggle");e&&(t(window).innerWidth()<=768||LP.Cookies.get("sidebar-toggle")?e.setAttribute("checked","checked"):e.removeAttribute("checked"),document.querySelector("#popup-course").addEventListener("click",(e=>{var s;"sidebar-toggle"===e.target.id&&(LP.Cookies.set("sidebar-toggle",!!e.target.checked),s=LP.Cookies.get("sidebar-toggle"),t("body").removeClass("lp-sidebar-toggle__open"),t("body").removeClass("lp-sidebar-toggle__close"),s?t("body").addClass("lp-sidebar-toggle__close"):t("body").addClass("lp-sidebar-toggle__open"))}))),t("#learn-press-course-curriculum").find(".section-desc").each(((e,s)=>{const o=t('<span class="show-desc"></span>').on("click",(()=>{r.toggleClass("c")})),r=t(s).siblings(".section-title").append(o)})),t(".section").each((function(){const e=t(this);e.find(".section-left").on("click",(function(){const t=e.toggleClass("closed").hasClass("closed"),s=LP.Cookies.get("closed-section-"+lpGlobalSettings.post_id)||[],o=parseInt(e.data("section-id")),r=s.findIndex((e=>e==o));t?s.push(parseInt(e.data("section-id"))):s.splice(r,1),LP.Cookies.remove("closed-section-(.*)"),LP.Cookies.set("closed-section-"+lpGlobalSettings.post_id,[...new Set(s)])}))}))};document.addEventListener("DOMContentLoaded",(()=>{o()}));var r=window.wp.url;const a=jQuery;let n=null;const l={elLPOverlay:null,elMainContent:null,elTitle:null,elBtnYes:null,elBtnNo:null,elFooter:null,elCalledModal:null,callBackYes:null,instance:null,init(){return!!this.instance||(this.elLPOverlay=a(".lp-overlay"),!!this.elLPOverlay.length&&(n=this.elLPOverlay,this.elMainContent=n.find(".main-content"),this.elTitle=n.find(".modal-title"),this.elBtnYes=n.find(".btn-yes"),this.elBtnNo=n.find(".btn-no"),this.elFooter=n.find(".lp-modal-footer"),a(document).on("click",".close, .btn-no",(function(){n.hide()})),a(document).on("click",".btn-yes",(function(e){e.preventDefault(),e.stopPropagation(),"function"==typeof l.callBackYes&&l.callBackYes()})),this.instance=this,!0))},setElCalledModal(e){this.elCalledModal=e},setContentModal(e,t){this.elMainContent.html(e),"function"==typeof t&&t()},setTitleModal(e){this.elTitle.html(e)}};var c=l;jQuery;var i={elBtnFinishCourse:null,elBtnCompleteItem:null,init(){c.init()&&void 0!==lpGlobalSettings&&"yes"===lpGlobalSettings.option_enable_popup_confirm_finish&&(this.elBtnFinishCourse=document.querySelectorAll(".lp-btn-finish-course"),this.elBtnCompleteItem=document.querySelector(".lp-btn-complete-item"),this.elBtnCompleteItem&&this.elBtnCompleteItem.addEventListener("click",(e=>{e.preventDefault();const t=e.target.closest("form");c.elLPOverlay.show(),c.setTitleModal(t.dataset.title),c.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),c.callBackYes=()=>{t.submit()}})),this.elBtnFinishCourse&&this.elBtnFinishCourse.forEach((e=>e.addEventListener("click",(e=>{e.preventDefault();const t=e.target.closest("form");c.elLPOverlay.show(),c.setTitleModal(t.dataset.title),c.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),c.callBackYes=()=>{t.submit()}})))))}},d=window.wp.apiFetch,u=e.n(d);const p=jQuery;var m={init(){this.scrollToItemViewing=function(){const e=p(".viewing-course-item");if(e.length){const t=p("#learn-press-course-curriculum"),s=(p("#popup-sidebar").outerHeight(),p(".section-title").outerHeight(),p(".section-header").outerHeight()),o=new RegExp("^viewing-course-item-([0-9].*)"),r=e.attr("class").split(/\s+/);let a=0;if(p.each(r,(function(e,t){const s=o.exec(t);if(s)return a=s[1],!1})),0===a)return;const n=p(".course-item-"+a),l=(n.offset().top,n.offset().top-t.offset().top+t.scrollTop());t.animate({scrollTop:LP.Hook.applyFilters("scroll-item-current",l-s)},800)}},this.scrollToItemViewing()}};const g=()=>{const e=document.querySelector("#popup-course"),t=document.querySelector("#learn-press-course-curriculum");if(e&&t){const s=t.querySelector(".curriculum-sections"),o=e.querySelector(".search-course"),r=e.querySelector('.search-course input[type="text"]');if(!r||!s||!o)return;const a=s.querySelectorAll("li.section"),n=s.querySelectorAll("li.course-item"),l=[];n.forEach((e=>{const t=e.dataset.id,s=e.querySelector(".item-name");l.push({id:t,name:s?s.textContent.toLowerCase():""})}));const c=e=>{e.preventDefault();const t=r.value;o.classList.add("searching"),t||o.classList.remove("searching");const s=[];l.forEach((e=>{t&&!e.name.match(t.toLowerCase())||(s.push(e.id),n.forEach((e=>{-1!==s.indexOf(e.dataset.id)?e.classList.remove("hide-if-js"):e.classList.add("hide-if-js")})))})),a.forEach((e=>{const t=e.querySelectorAll(".course-item"),o=[];t.forEach((e=>{s.includes(e.dataset.id)&&o.push(e.dataset.id)})),0===o.length?e.classList.add("hide-if-js"):e.classList.remove("hide-if-js")}))},i=o.querySelector(".clear");i&&i.addEventListener("click",(e=>{e.preventDefault(),r.value="",c(e)})),o.addEventListener("submit",c),r.addEventListener("keyup",c)}};function h(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";const t=()=>{const e=document.querySelector(".learnpress-course-curriculum");e&&s(e)},s=async t=>{const s=t.querySelector(".lp-skeleton-animation"),a=t.dataset.id,l=t.dataset.section;try{const s=1,c=await u()({path:(0,r.addQueryArgs)("lp/v1/lazy-load/course-curriculum",{courseId:e||lpGlobalSettings.post_id||"",page:s,sectionID:l||""}),method:"GET"}),{data:i,status:d,message:p}=c;let m=i.section_ids;if("error"===d)throw new Error(p||"Error");let g=i.content;if(void 0===g&&(g=i,m=c.section_ids),l)if(m&&!m.includes(l)){const e=await n("",s+1,l);if(e){const{data2:s,pages2:r,page2:n}=e;await o({ele:t,returnData:g,sectionID:l,itemID:a,data2:s,pages2:r,page2:n})}}else await o({ele:t,returnData:g,sectionID:l,itemID:a});else g&&t.insertAdjacentHTML("beforeend",g)}catch(e){t.insertAdjacentHTML("beforeend",`<div class="lp-ajax-message error" style="display:block">${e.message||"Error: Query lp/v1/lazy-load/course-curriculum"}</div>`)}s&&s.remove(),g()},o=async e=>{let{ele:t,returnData:s,sectionID:o,itemID:r,data2:n,pages2:l,page2:c}=e;const i=(new DOMParser).parseFromString(s,"text/html");if(n){const e=i.querySelector(".curriculum-sections"),t=i.querySelector(".curriculum-more__button");t&&(l<=c?t.remove():t.dataset.page=c),e.insertAdjacentHTML("beforeend",n)}const d=i.querySelector(`[data-section-id="${o}"]`);if(d){const e=[...d.querySelectorAll(".course-item")].map((e=>e.dataset.id)),t=d.querySelector(".section-content"),s=d.querySelector(".section-item__loadmore");if(r&&!e.includes(r)){const e=await a("",2,o,r),{data3:n,pages3:l,paged3:c,page:i}=e;l<=c||l<=i?s.remove():s.dataset.page=i,n&&t&&t.insertAdjacentHTML("beforeend",n)}}t.insertAdjacentHTML("beforeend",i.body.innerHTML),m.init()},a=async(e,t,s,o)=>{const n=await u()({path:(0,r.addQueryArgs)("lp/v1/lazy-load/course-curriculum-items",{sectionId:s||"",page:t}),method:"GET"}),{data:l,status:c,pages:i,message:d}=n,{page:p}=l;let m;if("success"===c){let r=l.content;if(m=l.item_ids,void 0===r&&(r=l,m=n.item_ids),e+=r,s&&m&&o&&!m.includes(o))return a(e,t+1,s,o)}return{data3:e,pages3:i||l.pages,status3:c,message3:d,page:p||0}},n=async(t,s,o)=>{const a=await u()({path:(0,r.addQueryArgs)("lp/v1/lazy-load/course-curriculum",{courseId:e||lpGlobalSettings.post_id||"",page:s,sectionID:o||"",loadMore:!0}),method:"GET"}),{data:l,pages:c,status:i,message:d,section_ids:p}=a;let m=l.content;return void 0===m&&(m=l),"success"===i&&(t+=m,o&&p&&p.length>0&&!p.includes(o))?n(t,s+1,o):{data2:t,pages2:c||l.pages,page2:s,status2:i,message2:d}};t(),document.addEventListener("click",(e=>{[...document.querySelectorAll(".section-item__loadmore")].map((async t=>{if(t.contains(e.target)){const e=t.parentNode,s=e.getAttribute("data-section-id"),o=e.querySelector(".section-content"),r=parseInt(t.dataset.page);t.classList.add("loading");try{const e=await a("",r+1,s,""),{data3:n,pages3:l,status3:c,message3:i}=e;if("error"===c)throw new Error(i||"Error");l<=r+1?t.remove():t.dataset.page=r+1,o.insertAdjacentHTML("beforeend",n)}catch(e){o.insertAdjacentHTML("beforeend",`<div class="lp-ajax-message error" style="display:block">${e.message||"Error: Query lp/v1/lazy-load/course-curriculum"}</div>`)}t.classList.remove("loading"),g()}})),[...document.querySelectorAll(".curriculum-more__button")].map((async t=>{if(t.contains(e.target)){const e=parseInt(t.dataset.page),s=t.parentNode.parentNode.querySelector(".curriculum-sections");if(e&&s){t.classList.add("loading");try{const o=await n("",e+1,""),{data2:r,pages2:a,status2:l,message2:c}=o;if("error"===l)throw new Error(c||"Error");a<=e+1?t.remove():t.dataset.page=e+1,s.insertAdjacentHTML("beforeend",r)}catch(e){s.insertAdjacentHTML("beforeend",`<div class="lp-ajax-message error" style="display:block">${e.message||"Error: Query lp/v1/lazy-load/course-curriculum"}</div>`)}t.classList.remove("loading"),g()}}})),document.querySelector(".learnpress-course-curriculum")&&[...document.querySelectorAll(".section")].map((t=>{t.contains(e.target)&&t.querySelector(".section-left").contains(e.target)&&t.classList.toggle("closed")}))}))}const y=jQuery;y(window).on("load",(()=>{y("#popup-course"),y("#learn-press-course-curriculum"),[...document.querySelectorAll(".course-extra-box")].map((e=>{const t=e.querySelector(".course-extra-box__title");t.addEventListener("click",(()=>{const s=t.nextElementSibling,o=document.querySelector(".course-extra-box.active");o&&!e.classList.contains("active")&&(o.classList.remove("active"),o.querySelector(".course-extra-box__content").style.display="none"),e.classList.contains("active")?(e.classList.remove("active"),s.style.display="none"):(e.classList.add("active"),s.style.display="block")}))})),y("#learn-press-course-tabs").on("change",'input[name="learn-press-course-tab-radio"]',(function(e){const t=y('input[name="learn-press-course-tab-radio"]:checked').val();LP.Cookies.set("course-tab",t),y('label[for="'+y(e.target).attr("id")+'"]').closest("li").addClass("active").siblings().removeClass("active")})),function(){const e=y(".course-summary-sidebar");if(!e.length)return;const t=y(window),s=e.children(),o=e.offset();let r=0;const a=e.height(),n=s.height();t.on("scroll.fixed-course-sidebar",(function(){r=t.scrollTop();const l=r-o.top+32;if(l<0)return e.removeClass("slide-top slide-down"),void s.css("top","");l>a-n?(e.removeClass("slide-down").addClass("slide-top"),s.css("top",a-n)):(e.removeClass("slide-top").addClass("slide-down"),s.css("top",32))})).trigger("scroll.fixed-course-sidebar")}(),(()=>{const e=document.querySelectorAll("form.enroll-course");e.length>0&&e.forEach((e=>{e.addEventListener("submit",(t=>{t.preventDefault();const s=e.querySelector("input[name=enroll-course]").value,o=e.querySelector("button.button-enroll-course");o.classList.add("loading"),o.disabled=!0,(async(t,s)=>{try{const o=await wp.apiFetch({path:"lp/v1/courses/enroll-course",method:"POST",data:{id:t}});s.classList.remove("loading"),s.disabled=!1;const{status:r,data:{redirect:a},message:n}=o;n&&r&&(s.style.display="none",e.innerHTML+=`<div class="lp-enroll-notice ${r}">${n}</div>`,a&&(window.location.href=a))}catch(e){form.innerHTML+=`<div class="lp-enroll-notice error">${e.message&&e.message}</div>`}})(s,o)}))})),null!==document.querySelector(".course-detail-info")&&window.addEventListener("pageshow",(e=>{(e.persisted||void 0!==window.performance&&"back_forward"==String(window.performance.getEntriesByType("navigation")[0].type))&&location.reload()}))})(),(()=>{const e=document.querySelectorAll("form.purchase-course");e.length>0&&e.forEach((e=>{const t=()=>{document.querySelectorAll(".lp_allow_repuchase_select").forEach((t=>{const o=t.querySelectorAll("[name=_lp_allow_repurchase_type]");for(let t=0,r=o.length;t<r;t++)if(o[t].checked){const r=o[t].value,a=e.querySelector("input[name=purchase-course]").value,n=e.querySelector("button.button-purchase-course");n.classList.add("loading"),n.disabled=!0,s(a,n,r);break}}))},s=async function(s,o){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];try{const a=await wp.apiFetch({path:"lp/v1/courses/purchase-course",method:"POST",data:{id:s,repurchaseType:r}});o&&(o.classList.remove("loading"),o.disabled=!1);const{status:n,data:{redirect:l,type:i,html:d,titlePopup:u},message:p}=a;if("allow_repurchase"===i&&"success"===n){if(!e.querySelector(".lp_allow_repuchase_select")){if(!c.init())return;c.elLPOverlay.show(),c.setTitleModal(u||""),c.setContentModal(d),c.callBackYes=()=>{c.elLPOverlay.hide(),t()}}}else p&&n&&(e.innerHTML+=`<div class="lp-enroll-notice ${n}">${p}</div>`,"success"===n&&l&&(window.location.href=l))}catch(t){e.innerHTML+=`<div class="lp-enroll-notice error">${t.message&&t.message}</div>`}};e.addEventListener("submit",(t=>{t.preventDefault();const o=e.querySelector("input[name=purchase-course]").value,r=e.querySelector("button.button-purchase-course");r.classList.add("loading"),r.disabled=!0,s(o,r)}))}))})(),(()=>{const e=document.querySelectorAll(".lp-form-retake-course");e.length&&e.forEach((e=>{const t=e.querySelector(".button-retake-course"),s=e.querySelector("[name=retake-course]").value,o=e.querySelector(".lp-ajax-message");e.addEventListener("submit",(e=>{e.preventDefault()})),t.addEventListener("click",(e=>{var r;e.preventDefault(),t.classList.add("loading"),t.disabled=!0,r=t,wp.apiFetch({path:"/lp/v1/courses/retake-course",method:"POST",data:{id:s}}).then((e=>{const{status:t,message:s,data:a}=e;o.innerHTML=s,null!=t&&"success"===t?(r.style.display="none",setTimeout((()=>{window.location.replace(a.url_redirect)}),1e3)):o.classList.add("error")})).catch((e=>{o.classList.add("error"),o.innerHTML="error: "+e.message})).then((()=>{r.classList.remove("loading"),r.disabled=!1,o.style.display="block"}))}))}))})(),(()=>{const e=document.querySelectorAll(".lp-course-progress-wrapper");if(!e.length)return;if("IntersectionObserver"in window){const s=new IntersectionObserver(((e,o)=>{e.forEach((e=>{if(e.isIntersecting){const o=e.target;setTimeout((function(){t(o)}),600),s.unobserve(o)}}))}));[...e].map((e=>s.observe(e)))}const t=async e=>{const t=await wp.apiFetch({path:"lp/v1/lazy-load/course-progress",method:"POST",data:{courseId:lpGlobalSettings.post_id||"",userId:lpGlobalSettings.user_id||""}}),{data:s}=t;e.innerHTML=s}})(),(()=>{const e=document.querySelector("form.continue-course");null!=e&&(async e=>await wp.apiFetch({path:"lp/v1/courses/continue-course",method:"POST",data:{courseId:lpGlobalSettings.post_id||"",userId:lpGlobalSettings.user_id||""}}))().then((function(t){"success"===t.status&&(e.style.display="block",e.action=t.data)}))})(),i.init(),h()})),LP.Hook.addAction("lp_course_curriculum_skeleton",(function(e){h(e)}))}();
assets/js/dist/frontend/single-curriculum.js CHANGED
@@ -637,9 +637,9 @@ function courseCurriculumSkeleton() {
637
  const {
638
  data,
639
  status,
640
- message,
641
- section_ids
642
  } = response;
 
643
 
644
  if (status === 'error') {
645
  throw new Error(message || 'Error');
@@ -650,6 +650,7 @@ function courseCurriculumSkeleton() {
650
  if (undefined === returnData) {
651
  // For old Eduma <= 4.6.0
652
  returnData = data;
 
653
  }
654
 
655
  if (sectionID) {
@@ -739,7 +740,7 @@ function courseCurriculumSkeleton() {
739
  if (pages3 <= paged3 || pages3 <= page) {
740
  itemLoadMore.remove();
741
  } else {
742
- itemLoadMore.dataset.page = paged3;
743
  }
744
 
745
  if (data3 && sectionContent) {
637
  const {
638
  data,
639
  status,
640
+ message
 
641
  } = response;
642
+ let section_ids = data.section_ids;
643
 
644
  if (status === 'error') {
645
  throw new Error(message || 'Error');
650
  if (undefined === returnData) {
651
  // For old Eduma <= 4.6.0
652
  returnData = data;
653
+ section_ids = response.section_ids;
654
  }
655
 
656
  if (sectionID) {
740
  if (pages3 <= paged3 || pages3 <= page) {
741
  itemLoadMore.remove();
742
  } else {
743
+ itemLoadMore.dataset.page = page;
744
  }
745
 
746
  if (data3 && sectionContent) {
assets/js/dist/frontend/single-curriculum.min.js CHANGED
@@ -1 +1 @@
1
- !function(){var e={605:function(){LP.Hook.addAction("lp-compatible-builder",(()=>{LP.Hook.removeAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend&&[...document.querySelectorAll("#popup-content")][0].addEventListener("scroll",(()=>{Waypoint.refreshAll(),window.dispatchEvent(new Event("resize"))})),"undefined"!=typeof vc_js&&"undefined"!=typeof VcWaypoint&&[...document.querySelectorAll("#popup-content")][0].addEventListener("scroll",(()=>{VcWaypoint.refreshAll()}))})),LP.Hook.addAction("lp-quiz-compatible-builder",(()=>(LP.Hook.removeAction("lp-quiz-compatible-builder"),LP.Hook.doAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend?window.elementorFrontend.init():"undefined"!=typeof vc_js?("undefined"!=typeof vc_round_charts&&vc_round_charts(),"undefined"!=typeof vc_pieChart&&vc_pieChart(),"undefined"!=typeof vc_line_charts&&vc_line_charts(),window.vc_js()):void 0))),LP.Hook.addAction("lp-question-compatible-builder",(()=>(LP.Hook.removeAction("lp-question-compatible-builder"),LP.Hook.removeAction("lp-quiz-compatible-builder"),LP.Hook.doAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend?window.elementorFrontend.init():"undefined"!=typeof vc_js?("undefined"!=typeof vc_round_charts&&vc_round_charts(),"undefined"!=typeof vc_pieChart&&vc_pieChart(),"undefined"!=typeof vc_line_charts&&vc_line_charts(),window.vc_js()):void 0)))}},t={};function o(n){var s=t[n];if(void 0!==s)return s.exports;var r=t[n]={exports:{}};return e[n](r,r.exports,o),r.exports}o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,{a:t}),t},o.d=function(e,t){for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){"use strict";var e=window.wp.element;const t=()=>{const e=document.querySelector("#popup-course"),t=document.querySelector("#learn-press-course-curriculum");if(e&&t){const o=t.querySelector(".curriculum-sections"),n=e.querySelector(".search-course"),s=e.querySelector('.search-course input[type="text"]');if(!s||!o||!n)return;const r=o.querySelectorAll("li.section"),i=o.querySelectorAll("li.course-item"),a=[];i.forEach((e=>{const t=e.dataset.id,o=e.querySelector(".item-name");a.push({id:t,name:o?o.textContent.toLowerCase():""})}));const l=e=>{e.preventDefault();const t=s.value;n.classList.add("searching"),t||n.classList.remove("searching");const o=[];a.forEach((e=>{t&&!e.name.match(t.toLowerCase())||(o.push(e.id),i.forEach((e=>{-1!==o.indexOf(e.dataset.id)?e.classList.remove("hide-if-js"):e.classList.add("hide-if-js")})))})),r.forEach((e=>{const t=e.querySelectorAll(".course-item"),n=[];t.forEach((e=>{o.includes(e.dataset.id)&&n.push(e.dataset.id)})),0===n.length?e.classList.add("hide-if-js"):e.classList.remove("hide-if-js")}))},c=n.querySelector(".clear");c&&c.addEventListener("click",(e=>{e.preventDefault(),s.value="",l(e)})),n.addEventListener("submit",l),s.addEventListener("keyup",l)}},n=jQuery,{throttle:s}=lodash,r=()=>{const e=document.querySelector("#sidebar-toggle");e&&(n(window).innerWidth()<=768||LP.Cookies.get("sidebar-toggle")?e.setAttribute("checked","checked"):e.removeAttribute("checked"),document.querySelector("#popup-course").addEventListener("click",(e=>{var t;"sidebar-toggle"===e.target.id&&(LP.Cookies.set("sidebar-toggle",!!e.target.checked),t=LP.Cookies.get("sidebar-toggle"),n("body").removeClass("lp-sidebar-toggle__open"),n("body").removeClass("lp-sidebar-toggle__close"),t?n("body").addClass("lp-sidebar-toggle__close"):n("body").addClass("lp-sidebar-toggle__open"))}))),n("#learn-press-course-curriculum").find(".section-desc").each(((e,t)=>{const o=n('<span class="show-desc"></span>').on("click",(()=>{s.toggleClass("c")})),s=n(t).siblings(".section-title").append(o)})),n(".section").each((function(){const e=n(this);e.find(".section-left").on("click",(function(){const t=e.toggleClass("closed").hasClass("closed"),o=LP.Cookies.get("closed-section-"+lpGlobalSettings.post_id)||[],n=parseInt(e.data("section-id")),s=o.findIndex((e=>e==n));t?o.push(parseInt(e.data("section-id"))):o.splice(s,1),LP.Cookies.remove("closed-section-(.*)"),LP.Cookies.set("closed-section-"+lpGlobalSettings.post_id,[...new Set(o)])}))}))},i=jQuery,a=()=>{i(".learn-press-progress").each((function(){const e=i(this).find(".learn-press-progress__active"),t=e.data("value");void 0!==t&&e.css("left",-(100-parseInt(t))+"%")}))};var l=window.wp.url;const c=jQuery;let d=null;const u={elLPOverlay:null,elMainContent:null,elTitle:null,elBtnYes:null,elBtnNo:null,elFooter:null,elCalledModal:null,callBackYes:null,instance:null,init(){return!!this.instance||(this.elLPOverlay=c(".lp-overlay"),!!this.elLPOverlay.length&&(d=this.elLPOverlay,this.elMainContent=d.find(".main-content"),this.elTitle=d.find(".modal-title"),this.elBtnYes=d.find(".btn-yes"),this.elBtnNo=d.find(".btn-no"),this.elFooter=d.find(".lp-modal-footer"),c(document).on("click",".close, .btn-no",(function(){d.hide()})),c(document).on("click",".btn-yes",(function(e){e.preventDefault(),e.stopPropagation(),"function"==typeof u.callBackYes&&u.callBackYes()})),this.instance=this,!0))},setElCalledModal(e){this.elCalledModal=e},setContentModal(e,t){this.elMainContent.html(e),"function"==typeof t&&t()},setTitleModal(e){this.elTitle.html(e)}};var p=u;jQuery;var m={elBtnFinishCourse:null,elBtnCompleteItem:null,init(){p.init()&&void 0!==lpGlobalSettings&&"yes"===lpGlobalSettings.option_enable_popup_confirm_finish&&(this.elBtnFinishCourse=document.querySelectorAll(".lp-btn-finish-course"),this.elBtnCompleteItem=document.querySelector(".lp-btn-complete-item"),this.elBtnCompleteItem&&this.elBtnCompleteItem.addEventListener("click",(e=>{e.preventDefault();const t=e.target.closest("form");p.elLPOverlay.show(),p.setTitleModal(t.dataset.title),p.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),p.callBackYes=()=>{t.submit()}})),this.elBtnFinishCourse&&this.elBtnFinishCourse.forEach((e=>e.addEventListener("click",(e=>{e.preventDefault();const t=e.target.closest("form");p.elLPOverlay.show(),p.setTitleModal(t.dataset.title),p.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),p.callBackYes=()=>{t.submit()}})))))}};o(605),jQuery;class f extends e.Component{checkCourseDurationExpire(){const e=document.getElementsByName("lp-course-timestamp-remaining");if(e.length){const t=e[0].value;t<86400&&setTimeout((function(){window.location.reload(!0)}),1e3*t)}}render(){return(0,e.createElement)("div",null)}}document.addEventListener("DOMContentLoaded",(()=>{LP.Hook.doAction("lp-compatible-builder"),t(),r(),a(),(()=>{const e=document.querySelectorAll(".popup-header__inner");if(e.length&&null===document.querySelector("#learn-press-quiz-app div.quiz-result")&&0===e[0].querySelectorAll("form.form-button-finish-course").length&&"IntersectionObserver"in window){const t=new IntersectionObserver(((e,o)=>{e.forEach((e=>{if(e.isIntersecting){const o=e.target;(async e=>{const t=await wp.apiFetch({path:(0,l.addQueryArgs)("lp/v1/lazy-load/items-progress",{courseId:lpGlobalSettings.post_id||"",userId:lpGlobalSettings.user_id||""}),method:"GET"}),{data:o}=t;e.innerHTML+=o,m.init()})(o),t.unobserve(o)}}))}));[...e].map((e=>t.observe(e)))}})(),(new f).checkCourseDurationExpire()}));var g=window.wp.apiFetch,h=o.n(g);const y=jQuery;var v={init(){this.scrollToItemViewing=function(){const e=y(".viewing-course-item");if(e.length){const t=y("#learn-press-course-curriculum"),o=(y("#popup-sidebar").outerHeight(),y(".section-title").outerHeight(),y(".section-header").outerHeight()),n=new RegExp("^viewing-course-item-([0-9].*)"),s=e.attr("class").split(/\s+/);let r=0;if(y.each(s,(function(e,t){const o=n.exec(t);if(o)return r=o[1],!1})),0===r)return;const i=y(".course-item-"+r),a=(i.offset().top,i.offset().top-t.offset().top+t.scrollTop());t.animate({scrollTop:LP.Hook.applyFilters("scroll-item-current",a-o)},800)}},this.scrollToItemViewing()}};jQuery,document.addEventListener("DOMContentLoaded",(function(e){LP.Hook.doAction("course-ready"),m.init(),function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";const o=()=>{const e=document.querySelector(".learnpress-course-curriculum");e&&n(e)},n=async o=>{const n=o.querySelector(".lp-skeleton-animation"),r=o.dataset.id,a=o.dataset.section;try{const t=1,n=await h()({path:(0,l.addQueryArgs)("lp/v1/lazy-load/course-curriculum",{courseId:e||lpGlobalSettings.post_id||"",page:t,sectionID:a||""}),method:"GET"}),{data:c,status:d,message:u,section_ids:p}=n;if("error"===d)throw new Error(u||"Error");let m=c.content;if(void 0===m&&(m=c),a)if(p&&!p.includes(a)){const e=await i("",t+1,a);if(e){const{data2:t,pages2:n,page2:i}=e;await s({ele:o,returnData:m,sectionID:a,itemID:r,data2:t,pages2:n,page2:i})}}else await s({ele:o,returnData:m,sectionID:a,itemID:r});else m&&o.insertAdjacentHTML("beforeend",m)}catch(e){o.insertAdjacentHTML("beforeend",`<div class="lp-ajax-message error" style="display:block">${e.message||"Error: Query lp/v1/lazy-load/course-curriculum"}</div>`)}n&&n.remove(),t()},s=async e=>{let{ele:t,returnData:o,sectionID:n,itemID:s,data2:i,pages2:a,page2:l}=e;const c=(new DOMParser).parseFromString(o,"text/html");if(i){const e=c.querySelector(".curriculum-sections"),t=c.querySelector(".curriculum-more__button");t&&(a<=l?t.remove():t.dataset.page=l),e.insertAdjacentHTML("beforeend",i)}const d=c.querySelector(`[data-section-id="${n}"]`);if(d){const e=[...d.querySelectorAll(".course-item")].map((e=>e.dataset.id)),t=d.querySelector(".section-content"),o=d.querySelector(".section-item__loadmore");if(s&&!e.includes(s)){const e=await r("",2,n,s),{data3:i,pages3:a,paged3:l,page:c}=e;a<=l||a<=c?o.remove():o.dataset.page=l,i&&t&&t.insertAdjacentHTML("beforeend",i)}}t.insertAdjacentHTML("beforeend",c.body.innerHTML),v.init()},r=async(e,t,o,n)=>{const s=await h()({path:(0,l.addQueryArgs)("lp/v1/lazy-load/course-curriculum-items",{sectionId:o||"",page:t}),method:"GET"}),{data:i,status:a,pages:c,message:d}=s,{page:u}=i;let p;if("success"===a){let a=i.content;if(p=i.item_ids,void 0===a&&(a=i,p=s.item_ids),e+=a,o&&p&&n&&!p.includes(n))return r(e,t+1,o,n)}return{data3:e,pages3:c||i.pages,status3:a,message3:d,page:u||0}},i=async(t,o,n)=>{const s=await h()({path:(0,l.addQueryArgs)("lp/v1/lazy-load/course-curriculum",{courseId:e||lpGlobalSettings.post_id||"",page:o,sectionID:n||"",loadMore:!0}),method:"GET"}),{data:r,pages:a,status:c,message:d,section_ids:u}=s;let p=r.content;return void 0===p&&(p=r),"success"===c&&(t+=p,n&&u&&u.length>0&&!u.includes(n))?i(t,o+1,n):{data2:t,pages2:a||r.pages,page2:o,status2:c,message2:d}};o(),document.addEventListener("click",(e=>{[...document.querySelectorAll(".section-item__loadmore")].map((async o=>{if(o.contains(e.target)){const e=o.parentNode,n=e.getAttribute("data-section-id"),s=e.querySelector(".section-content"),i=parseInt(o.dataset.page);o.classList.add("loading");try{const e=await r("",i+1,n,""),{data3:t,pages3:a,status3:l,message3:c}=e;if("error"===l)throw new Error(c||"Error");a<=i+1?o.remove():o.dataset.page=i+1,s.insertAdjacentHTML("beforeend",t)}catch(e){s.insertAdjacentHTML("beforeend",`<div class="lp-ajax-message error" style="display:block">${e.message||"Error: Query lp/v1/lazy-load/course-curriculum"}</div>`)}o.classList.remove("loading"),t()}})),[...document.querySelectorAll(".curriculum-more__button")].map((async o=>{if(o.contains(e.target)){const e=parseInt(o.dataset.page),n=o.parentNode.parentNode.querySelector(".curriculum-sections");if(e&&n){o.classList.add("loading");try{const t=await i("",e+1,""),{data2:s,pages2:r,status2:a,message2:l}=t;if("error"===a)throw new Error(l||"Error");r<=e+1?o.remove():o.dataset.page=e+1,n.insertAdjacentHTML("beforeend",s)}catch(e){n.insertAdjacentHTML("beforeend",`<div class="lp-ajax-message error" style="display:block">${e.message||"Error: Query lp/v1/lazy-load/course-curriculum"}</div>`)}o.classList.remove("loading"),t()}}})),document.querySelector(".learnpress-course-curriculum")&&[...document.querySelectorAll(".section")].map((t=>{t.contains(e.target)&&t.querySelector(".section-left").contains(e.target)&&t.classList.toggle("closed")}))}))}()}))}()}();
1
+ !function(){var e={605:function(){LP.Hook.addAction("lp-compatible-builder",(()=>{LP.Hook.removeAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend&&[...document.querySelectorAll("#popup-content")][0].addEventListener("scroll",(()=>{Waypoint.refreshAll(),window.dispatchEvent(new Event("resize"))})),"undefined"!=typeof vc_js&&"undefined"!=typeof VcWaypoint&&[...document.querySelectorAll("#popup-content")][0].addEventListener("scroll",(()=>{VcWaypoint.refreshAll()}))})),LP.Hook.addAction("lp-quiz-compatible-builder",(()=>(LP.Hook.removeAction("lp-quiz-compatible-builder"),LP.Hook.doAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend?window.elementorFrontend.init():"undefined"!=typeof vc_js?("undefined"!=typeof vc_round_charts&&vc_round_charts(),"undefined"!=typeof vc_pieChart&&vc_pieChart(),"undefined"!=typeof vc_line_charts&&vc_line_charts(),window.vc_js()):void 0))),LP.Hook.addAction("lp-question-compatible-builder",(()=>(LP.Hook.removeAction("lp-question-compatible-builder"),LP.Hook.removeAction("lp-quiz-compatible-builder"),LP.Hook.doAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend?window.elementorFrontend.init():"undefined"!=typeof vc_js?("undefined"!=typeof vc_round_charts&&vc_round_charts(),"undefined"!=typeof vc_pieChart&&vc_pieChart(),"undefined"!=typeof vc_line_charts&&vc_line_charts(),window.vc_js()):void 0)))}},t={};function o(n){var s=t[n];if(void 0!==s)return s.exports;var r=t[n]={exports:{}};return e[n](r,r.exports,o),r.exports}o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,{a:t}),t},o.d=function(e,t){for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){"use strict";var e=window.wp.element;const t=()=>{const e=document.querySelector("#popup-course"),t=document.querySelector("#learn-press-course-curriculum");if(e&&t){const o=t.querySelector(".curriculum-sections"),n=e.querySelector(".search-course"),s=e.querySelector('.search-course input[type="text"]');if(!s||!o||!n)return;const r=o.querySelectorAll("li.section"),i=o.querySelectorAll("li.course-item"),a=[];i.forEach((e=>{const t=e.dataset.id,o=e.querySelector(".item-name");a.push({id:t,name:o?o.textContent.toLowerCase():""})}));const l=e=>{e.preventDefault();const t=s.value;n.classList.add("searching"),t||n.classList.remove("searching");const o=[];a.forEach((e=>{t&&!e.name.match(t.toLowerCase())||(o.push(e.id),i.forEach((e=>{-1!==o.indexOf(e.dataset.id)?e.classList.remove("hide-if-js"):e.classList.add("hide-if-js")})))})),r.forEach((e=>{const t=e.querySelectorAll(".course-item"),n=[];t.forEach((e=>{o.includes(e.dataset.id)&&n.push(e.dataset.id)})),0===n.length?e.classList.add("hide-if-js"):e.classList.remove("hide-if-js")}))},c=n.querySelector(".clear");c&&c.addEventListener("click",(e=>{e.preventDefault(),s.value="",l(e)})),n.addEventListener("submit",l),s.addEventListener("keyup",l)}},n=jQuery,{throttle:s}=lodash,r=()=>{const e=document.querySelector("#sidebar-toggle");e&&(n(window).innerWidth()<=768||LP.Cookies.get("sidebar-toggle")?e.setAttribute("checked","checked"):e.removeAttribute("checked"),document.querySelector("#popup-course").addEventListener("click",(e=>{var t;"sidebar-toggle"===e.target.id&&(LP.Cookies.set("sidebar-toggle",!!e.target.checked),t=LP.Cookies.get("sidebar-toggle"),n("body").removeClass("lp-sidebar-toggle__open"),n("body").removeClass("lp-sidebar-toggle__close"),t?n("body").addClass("lp-sidebar-toggle__close"):n("body").addClass("lp-sidebar-toggle__open"))}))),n("#learn-press-course-curriculum").find(".section-desc").each(((e,t)=>{const o=n('<span class="show-desc"></span>').on("click",(()=>{s.toggleClass("c")})),s=n(t).siblings(".section-title").append(o)})),n(".section").each((function(){const e=n(this);e.find(".section-left").on("click",(function(){const t=e.toggleClass("closed").hasClass("closed"),o=LP.Cookies.get("closed-section-"+lpGlobalSettings.post_id)||[],n=parseInt(e.data("section-id")),s=o.findIndex((e=>e==n));t?o.push(parseInt(e.data("section-id"))):o.splice(s,1),LP.Cookies.remove("closed-section-(.*)"),LP.Cookies.set("closed-section-"+lpGlobalSettings.post_id,[...new Set(o)])}))}))},i=jQuery,a=()=>{i(".learn-press-progress").each((function(){const e=i(this).find(".learn-press-progress__active"),t=e.data("value");void 0!==t&&e.css("left",-(100-parseInt(t))+"%")}))};var l=window.wp.url;const c=jQuery;let d=null;const u={elLPOverlay:null,elMainContent:null,elTitle:null,elBtnYes:null,elBtnNo:null,elFooter:null,elCalledModal:null,callBackYes:null,instance:null,init(){return!!this.instance||(this.elLPOverlay=c(".lp-overlay"),!!this.elLPOverlay.length&&(d=this.elLPOverlay,this.elMainContent=d.find(".main-content"),this.elTitle=d.find(".modal-title"),this.elBtnYes=d.find(".btn-yes"),this.elBtnNo=d.find(".btn-no"),this.elFooter=d.find(".lp-modal-footer"),c(document).on("click",".close, .btn-no",(function(){d.hide()})),c(document).on("click",".btn-yes",(function(e){e.preventDefault(),e.stopPropagation(),"function"==typeof u.callBackYes&&u.callBackYes()})),this.instance=this,!0))},setElCalledModal(e){this.elCalledModal=e},setContentModal(e,t){this.elMainContent.html(e),"function"==typeof t&&t()},setTitleModal(e){this.elTitle.html(e)}};var p=u;jQuery;var m={elBtnFinishCourse:null,elBtnCompleteItem:null,init(){p.init()&&void 0!==lpGlobalSettings&&"yes"===lpGlobalSettings.option_enable_popup_confirm_finish&&(this.elBtnFinishCourse=document.querySelectorAll(".lp-btn-finish-course"),this.elBtnCompleteItem=document.querySelector(".lp-btn-complete-item"),this.elBtnCompleteItem&&this.elBtnCompleteItem.addEventListener("click",(e=>{e.preventDefault();const t=e.target.closest("form");p.elLPOverlay.show(),p.setTitleModal(t.dataset.title),p.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),p.callBackYes=()=>{t.submit()}})),this.elBtnFinishCourse&&this.elBtnFinishCourse.forEach((e=>e.addEventListener("click",(e=>{e.preventDefault();const t=e.target.closest("form");p.elLPOverlay.show(),p.setTitleModal(t.dataset.title),p.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),p.callBackYes=()=>{t.submit()}})))))}};o(605),jQuery;class f extends e.Component{checkCourseDurationExpire(){const e=document.getElementsByName("lp-course-timestamp-remaining");if(e.length){const t=e[0].value;t<86400&&setTimeout((function(){window.location.reload(!0)}),1e3*t)}}render(){return(0,e.createElement)("div",null)}}document.addEventListener("DOMContentLoaded",(()=>{LP.Hook.doAction("lp-compatible-builder"),t(),r(),a(),(()=>{const e=document.querySelectorAll(".popup-header__inner");if(e.length&&null===document.querySelector("#learn-press-quiz-app div.quiz-result")&&0===e[0].querySelectorAll("form.form-button-finish-course").length&&"IntersectionObserver"in window){const t=new IntersectionObserver(((e,o)=>{e.forEach((e=>{if(e.isIntersecting){const o=e.target;(async e=>{const t=await wp.apiFetch({path:(0,l.addQueryArgs)("lp/v1/lazy-load/items-progress",{courseId:lpGlobalSettings.post_id||"",userId:lpGlobalSettings.user_id||""}),method:"GET"}),{data:o}=t;e.innerHTML+=o,m.init()})(o),t.unobserve(o)}}))}));[...e].map((e=>t.observe(e)))}})(),(new f).checkCourseDurationExpire()}));var g=window.wp.apiFetch,h=o.n(g);const y=jQuery;var v={init(){this.scrollToItemViewing=function(){const e=y(".viewing-course-item");if(e.length){const t=y("#learn-press-course-curriculum"),o=(y("#popup-sidebar").outerHeight(),y(".section-title").outerHeight(),y(".section-header").outerHeight()),n=new RegExp("^viewing-course-item-([0-9].*)"),s=e.attr("class").split(/\s+/);let r=0;if(y.each(s,(function(e,t){const o=n.exec(t);if(o)return r=o[1],!1})),0===r)return;const i=y(".course-item-"+r),a=(i.offset().top,i.offset().top-t.offset().top+t.scrollTop());t.animate({scrollTop:LP.Hook.applyFilters("scroll-item-current",a-o)},800)}},this.scrollToItemViewing()}};jQuery,document.addEventListener("DOMContentLoaded",(function(e){LP.Hook.doAction("course-ready"),m.init(),function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";const o=()=>{const e=document.querySelector(".learnpress-course-curriculum");e&&n(e)},n=async o=>{const n=o.querySelector(".lp-skeleton-animation"),r=o.dataset.id,a=o.dataset.section;try{const t=1,n=await h()({path:(0,l.addQueryArgs)("lp/v1/lazy-load/course-curriculum",{courseId:e||lpGlobalSettings.post_id||"",page:t,sectionID:a||""}),method:"GET"}),{data:c,status:d,message:u}=n;let p=c.section_ids;if("error"===d)throw new Error(u||"Error");let m=c.content;if(void 0===m&&(m=c,p=n.section_ids),a)if(p&&!p.includes(a)){const e=await i("",t+1,a);if(e){const{data2:t,pages2:n,page2:i}=e;await s({ele:o,returnData:m,sectionID:a,itemID:r,data2:t,pages2:n,page2:i})}}else await s({ele:o,returnData:m,sectionID:a,itemID:r});else m&&o.insertAdjacentHTML("beforeend",m)}catch(e){o.insertAdjacentHTML("beforeend",`<div class="lp-ajax-message error" style="display:block">${e.message||"Error: Query lp/v1/lazy-load/course-curriculum"}</div>`)}n&&n.remove(),t()},s=async e=>{let{ele:t,returnData:o,sectionID:n,itemID:s,data2:i,pages2:a,page2:l}=e;const c=(new DOMParser).parseFromString(o,"text/html");if(i){const e=c.querySelector(".curriculum-sections"),t=c.querySelector(".curriculum-more__button");t&&(a<=l?t.remove():t.dataset.page=l),e.insertAdjacentHTML("beforeend",i)}const d=c.querySelector(`[data-section-id="${n}"]`);if(d){const e=[...d.querySelectorAll(".course-item")].map((e=>e.dataset.id)),t=d.querySelector(".section-content"),o=d.querySelector(".section-item__loadmore");if(s&&!e.includes(s)){const e=await r("",2,n,s),{data3:i,pages3:a,paged3:l,page:c}=e;a<=l||a<=c?o.remove():o.dataset.page=c,i&&t&&t.insertAdjacentHTML("beforeend",i)}}t.insertAdjacentHTML("beforeend",c.body.innerHTML),v.init()},r=async(e,t,o,n)=>{const s=await h()({path:(0,l.addQueryArgs)("lp/v1/lazy-load/course-curriculum-items",{sectionId:o||"",page:t}),method:"GET"}),{data:i,status:a,pages:c,message:d}=s,{page:u}=i;let p;if("success"===a){let a=i.content;if(p=i.item_ids,void 0===a&&(a=i,p=s.item_ids),e+=a,o&&p&&n&&!p.includes(n))return r(e,t+1,o,n)}return{data3:e,pages3:c||i.pages,status3:a,message3:d,page:u||0}},i=async(t,o,n)=>{const s=await h()({path:(0,l.addQueryArgs)("lp/v1/lazy-load/course-curriculum",{courseId:e||lpGlobalSettings.post_id||"",page:o,sectionID:n||"",loadMore:!0}),method:"GET"}),{data:r,pages:a,status:c,message:d,section_ids:u}=s;let p=r.content;return void 0===p&&(p=r),"success"===c&&(t+=p,n&&u&&u.length>0&&!u.includes(n))?i(t,o+1,n):{data2:t,pages2:a||r.pages,page2:o,status2:c,message2:d}};o(),document.addEventListener("click",(e=>{[...document.querySelectorAll(".section-item__loadmore")].map((async o=>{if(o.contains(e.target)){const e=o.parentNode,n=e.getAttribute("data-section-id"),s=e.querySelector(".section-content"),i=parseInt(o.dataset.page);o.classList.add("loading");try{const e=await r("",i+1,n,""),{data3:t,pages3:a,status3:l,message3:c}=e;if("error"===l)throw new Error(c||"Error");a<=i+1?o.remove():o.dataset.page=i+1,s.insertAdjacentHTML("beforeend",t)}catch(e){s.insertAdjacentHTML("beforeend",`<div class="lp-ajax-message error" style="display:block">${e.message||"Error: Query lp/v1/lazy-load/course-curriculum"}</div>`)}o.classList.remove("loading"),t()}})),[...document.querySelectorAll(".curriculum-more__button")].map((async o=>{if(o.contains(e.target)){const e=parseInt(o.dataset.page),n=o.parentNode.parentNode.querySelector(".curriculum-sections");if(e&&n){o.classList.add("loading");try{const t=await i("",e+1,""),{data2:s,pages2:r,status2:a,message2:l}=t;if("error"===a)throw new Error(l||"Error");r<=e+1?o.remove():o.dataset.page=e+1,n.insertAdjacentHTML("beforeend",s)}catch(e){n.insertAdjacentHTML("beforeend",`<div class="lp-ajax-message error" style="display:block">${e.message||"Error: Query lp/v1/lazy-load/course-curriculum"}</div>`)}o.classList.remove("loading"),t()}}})),document.querySelector(".learnpress-course-curriculum")&&[...document.querySelectorAll(".section")].map((t=>{t.contains(e.target)&&t.querySelector(".section-left").contains(e.target)&&t.classList.toggle("closed")}))}))}()}))}()}();
assets/src/apps/js/frontend/single-curriculum/skeleton.js CHANGED
@@ -32,7 +32,8 @@ export default function courseCurriculumSkeleton( courseID = '' ) {
32
  method: 'GET',
33
  } );
34
 
35
- const { data, status, message, section_ids } = response;
 
36
 
37
  if ( status === 'error' ) {
38
  throw new Error( message || 'Error' );
@@ -41,6 +42,7 @@ export default function courseCurriculumSkeleton( courseID = '' ) {
41
  let returnData = data.content;
42
  if ( undefined === returnData ) { // For old Eduma <= 4.6.0
43
  returnData = data;
 
44
  }
45
 
46
  if ( sectionID ) {
@@ -103,7 +105,7 @@ export default function courseCurriculumSkeleton( courseID = '' ) {
103
  if ( pages3 <= paged3 || pages3 <= page ) {
104
  itemLoadMore.remove();
105
  } else {
106
- itemLoadMore.dataset.page = paged3;
107
  }
108
 
109
  if ( data3 && sectionContent ) {
32
  method: 'GET',
33
  } );
34
 
35
+ const { data, status, message } = response;
36
+ let section_ids = data.section_ids;
37
 
38
  if ( status === 'error' ) {
39
  throw new Error( message || 'Error' );
42
  let returnData = data.content;
43
  if ( undefined === returnData ) { // For old Eduma <= 4.6.0
44
  returnData = data;
45
+ section_ids = response.section_ids;
46
  }
47
 
48
  if ( sectionID ) {
105
  if ( pages3 <= paged3 || pages3 <= page ) {
106
  itemLoadMore.remove();
107
  } else {
108
+ itemLoadMore.dataset.page = page;
109
  }
110
 
111
  if ( data3 && sectionContent ) {
inc/admin/class-lp-admin-assets.php CHANGED
@@ -330,6 +330,7 @@ class LP_Admin_Assets extends LP_Abstract_Assets {
330
  if ( empty( $screen_id ) ) {
331
  return;
332
  }
 
333
 
334
  $this->handle_js( $screen_id );
335
 
330
  if ( empty( $screen_id ) ) {
331
  return;
332
  }
333
+ wp_enqueue_media();
334
 
335
  $this->handle_js( $screen_id );
336
 
inc/admin/class-lp-admin.php CHANGED
@@ -129,13 +129,21 @@ if ( ! class_exists( 'LP_Admin' ) ) {
129
  }
130
 
131
  if ( $s && false !== stripos( $s, 'learnpress' ) ) {
132
- $views['learnpress'] = sprintf( '<a href="%s" class="current">%s <span class="count">(%d/%d)</span></a>',
133
- admin_url( 'plugins.php?s=learnpress' ), __( 'LearnPress', 'learnpress' ), $count_activated,
134
- sizeof( $search ) );
 
 
 
 
135
  } else {
136
- $views['learnpress'] = sprintf( '<a href="%s">%s <span class="count">(%d/%d)</span></a>',
137
- admin_url( 'plugins.php?s=learnpress' ), __( 'LearnPress', 'learnpress' ), $count_activated,
138
- sizeof( $search ) );
 
 
 
 
139
  }
140
 
141
  return $views;
@@ -376,8 +384,11 @@ if ( ! class_exists( 'LP_Admin' ) ) {
376
  }
377
 
378
  if ( ! empty( $pages[ $plugin ][ $post ] ) ) {
379
- echo sprintf( '<p class="for-plugin-page">(%s - %s)</p>', $plugin,
380
- $pages[ $plugin ][ $post ] );
 
 
 
381
  }
382
  }
383
  }
@@ -396,8 +407,11 @@ if ( ! class_exists( 'LP_Admin' ) ) {
396
  if ( $pages ) {
397
  $text = sprintf( __( 'LearnPress Pages (%d)', 'learnpress' ), sizeof( $pages ) );
398
  if ( 'yes' !== LP_Request::get( 'lp-page' ) ) {
399
- $actions['lp-page'] = sprintf( '<a href="%s">%s</a>',
400
- admin_url( 'edit.php?post_type=page&lp-page=yes' ), $text );
 
 
 
401
  } else {
402
  $actions['lp-page'] = $text;
403
  }
@@ -439,10 +453,14 @@ if ( ! class_exists( 'LP_Admin' ) ) {
439
  if ( LP_Request::get_string( 'lp-action' ) == 'pending-request' && $pending_request ) {
440
  $actions = array();
441
  if ( in_array( $user->ID, $pending_request ) ) {
442
- $actions['accept'] = sprintf( '<a href="' . admin_url( 'users.php?lp-action=accept-request&user_id=' . $user->ID ) . '">%s</a>',
443
- _x( 'Accept', 'pending-request', 'learnpress' ) );
444
- $actions['delete deny'] = sprintf( '<a class="submitdelete" href="' . admin_url( 'users.php?lp-action=deny-request&user_id=' . $user->ID ) . '">%s</a>',
445
- _x( 'Deny', 'pending-request', 'learnpress' ) );
 
 
 
 
446
  }
447
  }
448
 
@@ -510,8 +528,13 @@ if ( ! class_exists( 'LP_Admin' ) ) {
510
  } else {
511
  $class = '';
512
  }
513
- $views['pending-request'] = '<a href="' . admin_url( 'users.php?lp-action=pending-request' ) . '"' . $class . '>' . sprintf( __( 'Pending Request %s',
514
- 'learnpress' ), '<span class="count">(' . count( $pending_request ) . ')</span>' ) . '</a>';
 
 
 
 
 
515
  }
516
 
517
  return $views;
@@ -532,17 +555,27 @@ if ( ! class_exists( 'LP_Admin' ) ) {
532
  $action = LP_Request::get( 'lp-action' );
533
  $user_id = LP_Request::get_int( 'user_id' );
534
 
535
- if ( ( in_array( $action,
536
- array( 'accepted-request', 'denied-request' ) ) ) && ( $user_id ) && get_user_by( 'id',
537
- $user_id ) ) {
 
 
 
 
538
  if ( ! current_user_can( 'promote_user', $user_id ) ) {
539
  wp_die( __( 'Sorry, you are not allowed to edit this user.', 'learnpress' ) );
540
  }
541
  ?>
542
 
543
  <div class="updated notice">
544
- <p><?php echo sprintf( __( 'User has %s to become a teacher.', 'learnpress' ),
545
- $action == 'accepted-request' ? 'accepted' : 'denied' ); ?></p>
 
 
 
 
 
 
546
  </div>
547
 
548
  <?php
@@ -589,8 +622,16 @@ if ( ! class_exists( 'LP_Admin' ) ) {
589
  public function notice_required_permalink() {
590
  if ( current_user_can( 'manage_options' ) ) {
591
  if ( ! get_option( 'permalink_structure' ) ) {
592
- learn_press_add_notice( sprintf( __( 'LearnPress requires permalink option <strong>Post name</strong> is enabled. Please enable it <a href="%s">here</a> to ensure that all functions work properly.',
593
- 'learnpress' ), admin_url( 'options-permalink.php' ) ), 'error' );
 
 
 
 
 
 
 
 
594
  }
595
  }
596
  }
@@ -639,13 +680,22 @@ if ( ! class_exists( 'LP_Admin' ) ) {
639
  $current_screen = get_current_screen();
640
  $pages = learn_press_get_screens();
641
 
642
- if ( isset( $current_screen->id ) && apply_filters( 'learn_press_display_admin_footer_text',
643
- in_array( $current_screen->id, $pages ) ) ) {
 
 
644
  if ( ! get_option( 'learn_press_message_user_rated' ) ) {
645
- $footer_text = sprintf( __( 'If you like <strong>LearnPress</strong> please leave us a %1$s&#9733;&#9733;&#9733;&#9733;&#9733;%2$s rating. A huge thanks from LearnPress team for your generous.',
646
- 'learnpress' ),
647
- '<a href="https://wordpress.org/support/plugin/learnpress/reviews/?filter=5#postform" target="_blank" class="lp-rating-link" data-rated="' . esc_attr__( 'Thanks :)',
648
- 'learnpress' ) . '">', '</a>' );
 
 
 
 
 
 
 
649
 
650
  ob_start();
651
  ?>
@@ -737,8 +787,10 @@ if ( ! class_exists( 'LP_Admin' ) ) {
737
  $error_message = $response->get_error_message();
738
  $data['message'] = __( 'Something went wrong: ', 'learnpress' ) . $error_message;
739
  } else {
740
- $data['message'] = __( 'Thank you for subscribing! Please check and click the confirmation link from the email we\'ve just sent to your mail box.',
741
- 'learnpress' );
 
 
742
  }
743
  }
744
 
@@ -764,7 +816,7 @@ if ( ! class_exists( 'LP_Admin' ) ) {
764
  include_once 'class-lp-modal-search-items.php';
765
  include_once 'class-lp-modal-search-users.php';
766
  include_once 'class-lp-setup-wizard.php';
767
- // include_once 'class-lp-updater.php';
768
  include_once 'class-lp-install-sample-data.php';
769
  include_once 'class-lp-reset-data.php';
770
  include_once LP_PLUGIN_PATH . 'inc/admin/views/meta-boxes/course/settings.php';
@@ -823,13 +875,7 @@ if ( ! class_exists( 'LP_Admin' ) ) {
823
  * @author tungnx
824
  * @since 3.2.7.5
825
  */
826
- public function lp_course_set_link_item_backend(
827
- $post_link = '',
828
- $post_id = 0,
829
- $new_title = '',
830
- $new_slug = '',
831
- $post = null
832
- ) {
833
  if ( ! in_array( $post->post_type, learn_press_get_course_item_types() ) ) {
834
  return $post_link;
835
  }
@@ -844,14 +890,14 @@ if ( ! class_exists( 'LP_Admin' ) ) {
844
  $link_item = $course->get_item_link( $post->ID );
845
 
846
  $post_slug = $post->post_name;
847
- $link_item_edit_slug = preg_replace( '/' . $post_slug . '(\/)/', '', $link_item );
848
 
849
  // For update new slug
850
  if ( $new_slug ) {
851
  $post_slug = $new_slug;
852
  }
853
 
854
- $post_link = '<strong>Permalink: </strong>';
855
  $post_link .= '<span id="sample-permalink">';
856
  $post_link .= '<a href="' . $link_item . '">' . $link_item_edit_slug . '<span id="editable-post-name">' . $post_slug . '</span>/</a>';
857
  $post_link .= '</span>';
@@ -862,8 +908,10 @@ if ( ! class_exists( 'LP_Admin' ) ) {
862
  }
863
  } else {
864
  // $post_link_preview = sprintf( '<a class="button" href="%s" target="_blank">%s</a>', learn_press_get_preview_url( $post_id ), __( 'Preview', 'learnpress' ) );
865
- $post_link_message = '<span>' . __( 'Permalink only available if the item is already assigned to a course.',
866
- 'learnpress' ) . '</span>';
 
 
867
  $post_link = sprintf( '<div id="learn-press-box-edit-slug">%s</div>', $post_link_message );
868
  }
869
 
129
  }
130
 
131
  if ( $s && false !== stripos( $s, 'learnpress' ) ) {
132
+ $views['learnpress'] = sprintf(
133
+ '<a href="%s" class="current">%s <span class="count">(%d/%d)</span></a>',
134
+ admin_url( 'plugins.php?s=learnpress' ),
135
+ __( 'LearnPress', 'learnpress' ),
136
+ $count_activated,
137
+ sizeof( $search )
138
+ );
139
  } else {
140
+ $views['learnpress'] = sprintf(
141
+ '<a href="%s">%s <span class="count">(%d/%d)</span></a>',
142
+ admin_url( 'plugins.php?s=learnpress' ),
143
+ __( 'LearnPress', 'learnpress' ),
144
+ $count_activated,
145
+ sizeof( $search )
146
+ );
147
  }
148
 
149
  return $views;
384
  }
385
 
386
  if ( ! empty( $pages[ $plugin ][ $post ] ) ) {
387
+ echo sprintf(
388
+ '<p class="for-plugin-page">(%s - %s)</p>',
389
+ $plugin,
390
+ $pages[ $plugin ][ $post ]
391
+ );
392
  }
393
  }
394
  }
407
  if ( $pages ) {
408
  $text = sprintf( __( 'LearnPress Pages (%d)', 'learnpress' ), sizeof( $pages ) );
409
  if ( 'yes' !== LP_Request::get( 'lp-page' ) ) {
410
+ $actions['lp-page'] = sprintf(
411
+ '<a href="%s">%s</a>',
412
+ admin_url( 'edit.php?post_type=page&lp-page=yes' ),
413
+ $text
414
+ );
415
  } else {
416
  $actions['lp-page'] = $text;
417
  }
453
  if ( LP_Request::get_string( 'lp-action' ) == 'pending-request' && $pending_request ) {
454
  $actions = array();
455
  if ( in_array( $user->ID, $pending_request ) ) {
456
+ $actions['accept'] = sprintf(
457
+ '<a href="' . admin_url( 'users.php?lp-action=accept-request&user_id=' . $user->ID ) . '">%s</a>',
458
+ _x( 'Accept', 'pending-request', 'learnpress' )
459
+ );
460
+ $actions['delete deny'] = sprintf(
461
+ '<a class="submitdelete" href="' . admin_url( 'users.php?lp-action=deny-request&user_id=' . $user->ID ) . '">%s</a>',
462
+ _x( 'Deny', 'pending-request', 'learnpress' )
463
+ );
464
  }
465
  }
466
 
528
  } else {
529
  $class = '';
530
  }
531
+ $views['pending-request'] = '<a href="' . admin_url( 'users.php?lp-action=pending-request' ) . '"' . $class . '>' . sprintf(
532
+ __(
533
+ 'Pending Request %s',
534
+ 'learnpress'
535
+ ),
536
+ '<span class="count">(' . count( $pending_request ) . ')</span>'
537
+ ) . '</a>';
538
  }
539
 
540
  return $views;
555
  $action = LP_Request::get( 'lp-action' );
556
  $user_id = LP_Request::get_int( 'user_id' );
557
 
558
+ if ( ( in_array(
559
+ $action,
560
+ array( 'accepted-request', 'denied-request' )
561
+ ) ) && ( $user_id ) && get_user_by(
562
+ 'id',
563
+ $user_id
564
+ ) ) {
565
  if ( ! current_user_can( 'promote_user', $user_id ) ) {
566
  wp_die( __( 'Sorry, you are not allowed to edit this user.', 'learnpress' ) );
567
  }
568
  ?>
569
 
570
  <div class="updated notice">
571
+ <p>
572
+ <?php
573
+ echo sprintf(
574
+ __( 'User has %s to become a teacher.', 'learnpress' ),
575
+ $action == 'accepted-request' ? 'accepted' : 'denied'
576
+ );
577
+ ?>
578
+ </p>
579
  </div>
580
 
581
  <?php
622
  public function notice_required_permalink() {
623
  if ( current_user_can( 'manage_options' ) ) {
624
  if ( ! get_option( 'permalink_structure' ) ) {
625
+ learn_press_add_notice(
626
+ sprintf(
627
+ __(
628
+ 'LearnPress requires permalink option <strong>Post name</strong> is enabled. Please enable it <a href="%s">here</a> to ensure that all functions work properly.',
629
+ 'learnpress'
630
+ ),
631
+ admin_url( 'options-permalink.php' )
632
+ ),
633
+ 'error'
634
+ );
635
  }
636
  }
637
  }
680
  $current_screen = get_current_screen();
681
  $pages = learn_press_get_screens();
682
 
683
+ if ( isset( $current_screen->id ) && apply_filters(
684
+ 'learn_press_display_admin_footer_text',
685
+ in_array( $current_screen->id, $pages )
686
+ ) ) {
687
  if ( ! get_option( 'learn_press_message_user_rated' ) ) {
688
+ $footer_text = sprintf(
689
+ __(
690
+ 'If you like <strong>LearnPress</strong> please leave us a %1$s&#9733;&#9733;&#9733;&#9733;&#9733;%2$s rating. A huge thanks from LearnPress team for your generous.',
691
+ 'learnpress'
692
+ ),
693
+ '<a href="https://wordpress.org/support/plugin/learnpress/reviews/?filter=5#postform" target="_blank" class="lp-rating-link" data-rated="' . esc_attr__(
694
+ 'Thanks :)',
695
+ 'learnpress'
696
+ ) . '">',
697
+ '</a>'
698
+ );
699
 
700
  ob_start();
701
  ?>
787
  $error_message = $response->get_error_message();
788
  $data['message'] = __( 'Something went wrong: ', 'learnpress' ) . $error_message;
789
  } else {
790
+ $data['message'] = __(
791
+ 'Thank you for subscribing! Please check and click the confirmation link from the email we\'ve just sent to your mail box.',
792
+ 'learnpress'
793
+ );
794
  }
795
  }
796
 
816
  include_once 'class-lp-modal-search-items.php';
817
  include_once 'class-lp-modal-search-users.php';
818
  include_once 'class-lp-setup-wizard.php';
819
+ // include_once 'class-lp-updater.php';
820
  include_once 'class-lp-install-sample-data.php';
821
  include_once 'class-lp-reset-data.php';
822
  include_once LP_PLUGIN_PATH . 'inc/admin/views/meta-boxes/course/settings.php';
875
  * @author tungnx
876
  * @since 3.2.7.5
877
  */
878
+ public function lp_course_set_link_item_backend( $post_link = '', $post_id = 0, $new_title = '', $new_slug = '', $post = null ) {
 
 
 
 
 
 
879
  if ( ! in_array( $post->post_type, learn_press_get_course_item_types() ) ) {
880
  return $post_link;
881
  }
890
  $link_item = $course->get_item_link( $post->ID );
891
 
892
  $post_slug = $post->post_name;
893
+ $link_item_edit_slug = preg_replace( '/' . $post_slug . '$/', '', $link_item );
894
 
895
  // For update new slug
896
  if ( $new_slug ) {
897
  $post_slug = $new_slug;
898
  }
899
 
900
+ $post_link = '<strong>Permalink: </strong>';
901
  $post_link .= '<span id="sample-permalink">';
902
  $post_link .= '<a href="' . $link_item . '">' . $link_item_edit_slug . '<span id="editable-post-name">' . $post_slug . '</span>/</a>';
903
  $post_link .= '</span>';
908
  }
909
  } else {
910
  // $post_link_preview = sprintf( '<a class="button" href="%s" target="_blank">%s</a>', learn_press_get_preview_url( $post_id ), __( 'Preview', 'learnpress' ) );
911
+ $post_link_message = '<span>' . __(
912
+ 'Permalink only available if the item is already assigned to a course.',
913
+ 'learnpress'
914
+ ) . '</span>';
915
  $post_link = sprintf( '<div id="learn-press-box-edit-slug">%s</div>', $post_link_message );
916
  }
917
 
inc/admin/editor/class-lp-admin-editor-course.php CHANGED
@@ -110,6 +110,7 @@ class LP_Admin_Editor_Course extends LP_Admin_Editor {
110
  return;
111
  }
112
 
 
113
  $this->result = $this->section_curd->sort_sections( $order );
114
 
115
  // update final quiz
110
  return;
111
  }
112
 
113
+ $this->course ? $this->course->get_sections() : '';
114
  $this->result = $this->section_curd->sort_sections( $order );
115
 
116
  // update final quiz
inc/admin/meta-box/fields/textarea.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php $option_value = $value['value']; ?>
2
 
3
  <tr valign="top">
4
  <th scope="row" class="titledesc">
@@ -14,6 +14,6 @@
14
  class="<?php echo esc_attr( $value['class'] ); ?>"
15
  placeholder="<?php echo esc_attr( $value['placeholder'] ); ?>"
16
  <?php echo implode( ' ', $custom_attributes ); ?>
17
- ><?php echo esc_textarea( $option_value ); ?></textarea>
18
  </td>
19
  </tr>
1
+ <?php $option_value = apply_filters( 'lp_metabox_setting_ouput_textarea', esc_textarea( $value['value'] ), $value, $value['value'] ); ?>
2
 
3
  <tr valign="top">
4
  <th scope="row" class="titledesc">
14
  class="<?php echo esc_attr( $value['class'] ); ?>"
15
  placeholder="<?php echo esc_attr( $value['placeholder'] ); ?>"
16
  <?php echo implode( ' ', $custom_attributes ); ?>
17
+ ><?php echo $option_value; ?></textarea>
18
  </td>
19
  </tr>
inc/admin/views/setup/steps/finish.php CHANGED
@@ -14,18 +14,21 @@ defined( 'ABSPATH' ) or exit;
14
  <p><?php _e( 'LearnPress LMS is ready to go!', 'learnpress' ); ?></p>
15
 
16
  <p class="finish-buttons">
17
- <a class="button"
18
- id="install-sample-course"
19
- href="<?php echo esc_url( wp_nonce_url( admin_url( 'index.php?page=lp-install-sample-data' ), 'install-sample-course' ) ); ?>">
20
  <?php _e( 'Install a demo course', 'learnpress' ); ?>
21
- </a>
22
 
23
- <a class="button"
24
- href="https://docspress.thimpress.com/admin-learnpress-4-0/"><?php _e( 'View Documentation', 'learnpress' ); ?></a>
 
25
 
26
- <a class="button"
27
- href="<?php echo esc_url( admin_url( 'post-new.php?post_type=lp_course' ) ); ?>"><?php _e( 'Create a new course', 'learnpress' ); ?></a>
 
28
 
29
- <a class="button"
30
- href="<?php echo esc_url( admin_url( 'index.php' ) ); ?>"><?php _e( 'Back to Dashboard', 'learnpress' ); ?></a>
 
31
  </p>
14
  <p><?php _e( 'LearnPress LMS is ready to go!', 'learnpress' ); ?></p>
15
 
16
  <p class="finish-buttons">
17
+ <a class="button"
18
+ id="install-sample-course"
19
+ href="<?php echo esc_url( admin_url( 'admin.php?page=learn-press-tools' ) ); ?>">
20
  <?php _e( 'Install a demo course', 'learnpress' ); ?>
21
+ </a>
22
 
23
+ <a class="button" href="https://docspress.thimpress.com/admin-learnpress-4-0/">
24
+ <?php _e( 'View Documentation', 'learnpress' ); ?>
25
+ </a>
26
 
27
+ <a class="button" href="<?php echo esc_url( admin_url( 'post-new.php?post_type=lp_course' ) ); ?>">
28
+ <?php _e( 'Create a new course', 'learnpress' ); ?>
29
+ </a>
30
 
31
+ <a class="button" href="<?php echo esc_url( admin_url( 'index.php' ) ); ?>">
32
+ <?php _e( 'Back to Dashboard', 'learnpress' ); ?>
33
+ </a>
34
  </p>
inc/course/abstract-course.php CHANGED
@@ -137,7 +137,7 @@ if ( ! function_exists( 'LP_Abstract_Course' ) ) {
137
 
138
  $this->load_data();
139
 
140
- $can_load_curriculum = false;
141
  // Check if edit course, single course, single item can be load
142
  if ( in_array( LP_Page_Controller::page_current(), array( LP_PAGE_SINGLE_COURSE, LP_PAGE_SINGLE_COURSE_CURRICULUM ) ) ) {
143
  $can_load_curriculum = true;
@@ -154,7 +154,7 @@ if ( ! function_exists( 'LP_Abstract_Course' ) ) {
154
 
155
  if ( $can_load_curriculum ) {
156
  $this->load_curriculum();
157
- }
158
 
159
  $this->_loaded = true;
160
  }
@@ -522,6 +522,7 @@ if ( ! function_exists( 'LP_Abstract_Course' ) ) {
522
  public function get_item_types( $group = false ) {
523
  $cache_key = $group ? 'course-item-group-types' : 'course-item-types';
524
  $items = LP_Object_Cache::get( 'course-' . $this->get_id(), "learn-press/{$cache_key}" );
 
525
 
526
  if ( false === $items ) {
527
  $item_types = array();
@@ -1211,9 +1212,11 @@ if ( ! function_exists( 'LP_Abstract_Course' ) ) {
1211
  * Item Link = Course Permalink + SLUG + Item Slug
1212
  *
1213
  * @since 3.0.0
 
1214
  */
1215
- public function get_item_links() {
1216
  $item_links = LP_Object_Cache::get( 'course-' . $this->get_id(), 'learn-press/course-item-links' );
 
1217
 
1218
  if ( false === $item_links ) {
1219
  $items = $this->get_item_ids();
@@ -1292,22 +1295,37 @@ if ( ! function_exists( 'LP_Abstract_Course' ) ) {
1292
  }
1293
 
1294
  return $item_links;
1295
- }
1296
 
1297
  /**
 
 
1298
  * @param int $item_id
1299
  *
 
 
 
1300
  * @return string
1301
  */
1302
  public function get_item_link( int $item_id ): string {
1303
- $item_link = '';
1304
- $item_links = $this->get_item_links();
1305
 
1306
- if ( false !== $item_links ) {
1307
- if ( ! empty( $item_links[ $item_id ] ) ) {
1308
- $item_link = $item_links[ $item_id ];
1309
- }
1310
- }
 
 
 
 
 
 
 
 
 
 
1311
 
1312
  return apply_filters( 'learn-press/course/item-link', $item_link, $item_id, $this );
1313
  }
@@ -2105,6 +2123,7 @@ if ( ! function_exists( 'LP_Abstract_Course' ) ) {
2105
  * @version 4.0.0
2106
  */
2107
  public function get_sections( $return = 'object', $section_id = 0 ) {
 
2108
  $sections = LP_Course_Utils::get_cached_db_sections( $this->get_id() );
2109
 
2110
  if ( false === $sections ) {
137
 
138
  $this->load_data();
139
 
140
+ /*$can_load_curriculum = false;
141
  // Check if edit course, single course, single item can be load
142
  if ( in_array( LP_Page_Controller::page_current(), array( LP_PAGE_SINGLE_COURSE, LP_PAGE_SINGLE_COURSE_CURRICULUM ) ) ) {
143
  $can_load_curriculum = true;
154
 
155
  if ( $can_load_curriculum ) {
156
  $this->load_curriculum();
157
+ }*/
158
 
159
  $this->_loaded = true;
160
  }
522
  public function get_item_types( $group = false ) {
523
  $cache_key = $group ? 'course-item-group-types' : 'course-item-types';
524
  $items = LP_Object_Cache::get( 'course-' . $this->get_id(), "learn-press/{$cache_key}" );
525
+ $items = false;
526
 
527
  if ( false === $items ) {
528
  $item_types = array();
1212
  * Item Link = Course Permalink + SLUG + Item Slug
1213
  *
1214
  * @since 3.0.0
1215
+ * @deprecated 3.1.6.3
1216
  */
1217
+ /*public function get_item_links() {
1218
  $item_links = LP_Object_Cache::get( 'course-' . $this->get_id(), 'learn-press/course-item-links' );
1219
+ $item_links = false;
1220
 
1221
  if ( false === $item_links ) {
1222
  $items = $this->get_item_ids();
1295
  }
1296
 
1297
  return $item_links;
1298
+ }*/
1299
 
1300
  /**
1301
+ * Get item's link
1302
+ *
1303
  * @param int $item_id
1304
  *
1305
+ * @editor tungnx
1306
+ * @since 3.0.0
1307
+ * @version 1.0.1
1308
  * @return string
1309
  */
1310
  public function get_item_link( int $item_id ): string {
1311
+ $item_link = '';
1312
+ $item_type = get_post_type( $item_id );
1313
 
1314
+ $course_permalink = trailingslashit( $this->get_permalink() );
1315
+ $item_slug = get_post_field( 'post_name', $item_id );
1316
+
1317
+ $slug_prefixes = apply_filters(
1318
+ 'learn-press/course/custom-item-prefixes',
1319
+ array(
1320
+ LP_QUIZ_CPT => sanitize_title_with_dashes( LP()->settings->get( 'quiz_slug', 'quiz' ) ),
1321
+ LP_LESSON_CPT => sanitize_title_with_dashes( LP()->settings->get( 'lesson_slug', 'lesson' ) ),
1322
+ ),
1323
+ $this->get_id()
1324
+ );
1325
+
1326
+ $slug_prefix = trailingslashit( $slug_prefixes[ $item_type ] ?? '' );
1327
+
1328
+ $item_link = $course_permalink . $slug_prefix . $item_slug;
1329
 
1330
  return apply_filters( 'learn-press/course/item-link', $item_link, $item_id, $this );
1331
  }
2123
  * @version 4.0.0
2124
  */
2125
  public function get_sections( $return = 'object', $section_id = 0 ) {
2126
+ $this->load_curriculum();
2127
  $sections = LP_Course_Utils::get_cached_db_sections( $this->get_id() );
2128
 
2129
  if ( false === $sections ) {
inc/curds/class-lp-course-curd.php CHANGED
@@ -160,6 +160,7 @@ if ( ! class_exists( 'LP_Course_CURD' ) ) {
160
  $new_course_section_curd = new LP_Section_CURD( $new_course_id );
161
 
162
  // curriculum course
 
163
  $curriculum = $course->get_curriculum_raw();
164
 
165
  // quiz curd
160
  $new_course_section_curd = new LP_Section_CURD( $new_course_id );
161
 
162
  // curriculum course
163
+ // $course->load_curriculum();
164
  $curriculum = $course->get_curriculum_raw();
165
 
166
  // quiz curd
inc/curds/class-lp-section-curd.php CHANGED
@@ -202,8 +202,9 @@ class LP_Section_CURD extends LP_Object_Data_CURD implements LP_Interface_CURD {
202
  *
203
  * @return array
204
  * @since 3.0.0
 
205
  */
206
- public function read_sections_ids() {
207
 
208
  // Get course's sections id data from cache
209
  $ids = LP_Object_Cache::get( 'course-' . $this->course_id, 'learn-press/course-sections-ids' );
@@ -217,7 +218,7 @@ class LP_Section_CURD extends LP_Object_Data_CURD implements LP_Interface_CURD {
217
  }
218
 
219
  return $ids;
220
- }
221
 
222
  /**
223
  * Read all items from DB
@@ -398,7 +399,7 @@ class LP_Section_CURD extends LP_Object_Data_CURD implements LP_Interface_CURD {
398
  * @return array
399
  */
400
  public function add_items_section( $section_id, $items = array() ) {
401
- $order = 1;
402
  $current_items = $this->get_section_items( $section_id );
403
  // allow hook
404
  do_action( 'learn-press/before-add-items-section', $items, $section_id, $this->course_id );
@@ -407,7 +408,7 @@ class LP_Section_CURD extends LP_Object_Data_CURD implements LP_Interface_CURD {
407
 
408
  $all_items = array_merge( $current_items, $items );
409
  $result = array();
410
- foreach ( $all_items as $item ) {
411
 
412
  $item = (array) $item;
413
  $exist = $this->item_section_exist( $section_id, $item['id'] );
@@ -415,7 +416,7 @@ class LP_Section_CURD extends LP_Object_Data_CURD implements LP_Interface_CURD {
415
  if ( $exist ) {
416
  $a = $wpdb->update(
417
  $wpdb->learnpress_section_items,
418
- array( 'item_order' => $order ),
419
  array(
420
  'section_id' => $section_id,
421
  'item_id' => $item['id'],
@@ -427,7 +428,7 @@ class LP_Section_CURD extends LP_Object_Data_CURD implements LP_Interface_CURD {
427
  array(
428
  'section_id' => $section_id,
429
  'item_id' => $item['id'],
430
- 'item_order' => $order,
431
  'item_type' => $item['type'],
432
  )
433
  );
@@ -451,7 +452,7 @@ class LP_Section_CURD extends LP_Object_Data_CURD implements LP_Interface_CURD {
451
  }
452
 
453
  $result[] = $item;
454
- $order ++;
455
  }
456
 
457
  LP_Object_Cache::set( 'course-' . $this->course_id . '-' . $section_id, $all_items, 'learn-press/course-section-items' );
202
  *
203
  * @return array
204
  * @since 3.0.0
205
+ * @deprecated 4.1.6.3
206
  */
207
+ /*public function read_sections_ids() {
208
 
209
  // Get course's sections id data from cache
210
  $ids = LP_Object_Cache::get( 'course-' . $this->course_id, 'learn-press/course-sections-ids' );
218
  }
219
 
220
  return $ids;
221
+ }*/
222
 
223
  /**
224
  * Read all items from DB
399
  * @return array
400
  */
401
  public function add_items_section( $section_id, $items = array() ) {
402
+ // $order = 1;
403
  $current_items = $this->get_section_items( $section_id );
404
  // allow hook
405
  do_action( 'learn-press/before-add-items-section', $items, $section_id, $this->course_id );
408
 
409
  $all_items = array_merge( $current_items, $items );
410
  $result = array();
411
+ foreach ( $all_items as $key => $item ) {
412
 
413
  $item = (array) $item;
414
  $exist = $this->item_section_exist( $section_id, $item['id'] );
416
  if ( $exist ) {
417
  $a = $wpdb->update(
418
  $wpdb->learnpress_section_items,
419
+ array( 'item_order' => $key ),
420
  array(
421
  'section_id' => $section_id,
422
  'item_id' => $item['id'],
428
  array(
429
  'section_id' => $section_id,
430
  'item_id' => $item['id'],
431
+ 'item_order' => $key,
432
  'item_type' => $item['type'],
433
  )
434
  );
452
  }
453
 
454
  $result[] = $item;
455
+ // $order ++;
456
  }
457
 
458
  LP_Object_Cache::set( 'course-' . $this->course_id . '-' . $section_id, $all_items, 'learn-press/course-section-items' );
inc/custom-post-types/order.php CHANGED
@@ -514,14 +514,16 @@ if ( ! class_exists( 'LP_Order_Post_Type' ) ) {
514
  return $join;
515
  }
516
 
517
- $join .= " INNER JOIN {$wpdb->postmeta} pm1 ON {$wpdb->posts}.ID = pm1.post_id AND pm1.meta_key = '_user_id'";
518
- $join .= " INNER JOIN {$wpdb->postmeta} pm2 ON {$wpdb->posts}.ID = pm2.post_id AND pm2.meta_key = '_order_total'";
519
-
520
  $s = $wp_query->get( 's' );
521
  if ( $s ) {
522
  $join .= " INNER JOIN {$wpdb->learnpress_order_items} loi ON {$wpdb->posts}.ID = loi.order_id";
523
  }
524
- $join .= " LEFT JOIN {$wpdb->users} uu ON pm1.meta_value = uu.ID";
 
 
 
 
 
525
 
526
  return $join;
527
  }
514
  return $join;
515
  }
516
 
 
 
 
517
  $s = $wp_query->get( 's' );
518
  if ( $s ) {
519
  $join .= " INNER JOIN {$wpdb->learnpress_order_items} loi ON {$wpdb->posts}.ID = loi.order_id";
520
  }
521
+
522
+ if ( isset( $_REQUEST['author'] ) ) {
523
+ $join .= " INNER JOIN {$wpdb->postmeta} pm1 ON {$wpdb->posts}.ID = pm1.post_id AND pm1.meta_key = '_user_id'";
524
+ $join .= " INNER JOIN {$wpdb->postmeta} pm2 ON {$wpdb->posts}.ID = pm2.post_id AND pm2.meta_key = '_order_total'";
525
+ $join .= " LEFT JOIN {$wpdb->users} uu ON pm1.meta_value = uu.ID";
526
+ }
527
 
528
  return $join;
529
  }
inc/custom-post-types/quiz.php CHANGED
@@ -288,12 +288,34 @@ if ( ! class_exists( 'LP_Quiz_Post_Type' ) ) {
288
  );
289
  break;
290
  case 'duration':
291
- $duration = learn_press_human_time_to_seconds( get_post_meta( $post_id, '_lp_duration', true ) );
 
 
292
  if ( $duration > 0 ) {
293
- echo gmdate( 'H:i:s', $duration );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
294
  } else {
295
- echo '-';
296
  }
 
 
297
  break;
298
  case 'preview':
299
  printf(
288
  );
289
  break;
290
  case 'duration':
291
+ $duration_str = get_post_meta( $post_id, '_lp_duration', true );
292
+ $duration = (int) $duration_str;
293
+
294
  if ( $duration > 0 ) {
295
+ $duration_str .= 's';
296
+ $duration_str_arr = explode( ' ', $duration_str );
297
+ $type_time = '';
298
+ switch ( $duration_str_arr[1] ) {
299
+ case 'hours':
300
+ $type_time = __( 'hours', 'learnpress' );
301
+ break;
302
+ case 'minutes':
303
+ $type_time = __( 'minutes', 'learnpress' );
304
+ break;
305
+ case 'days':
306
+ $type_time = __( 'days', 'learnpress' );
307
+ break;
308
+ case 'weeks':
309
+ $type_time = __( 'weeks', 'learnpress' );
310
+ break;
311
+ }
312
+
313
+ $duration_str = sprintf( '%1$s %2$s', $duration_str_arr[0], $type_time );
314
  } else {
315
+ $duration_str = '--';
316
  }
317
+
318
+ echo $duration_str;
319
  break;
320
  case 'preview':
321
  printf(
inc/jwt/rest-api/version1/class-lp-rest-courses-v1-controller.php CHANGED
@@ -68,7 +68,7 @@ class LP_Jwt_Courses_V1_Controller extends LP_REST_Jwt_Posts_Controller {
68
  array(
69
  'methods' => WP_REST_Server::CREATABLE,
70
  'callback' => array( $this, 'enroll_course' ),
71
- 'permission_callback' => '__return_true',
72
  'args' => array(
73
  'context' => $this->get_context_param(
74
  array(
@@ -129,6 +129,27 @@ class LP_Jwt_Courses_V1_Controller extends LP_REST_Jwt_Posts_Controller {
129
  ),
130
  )
131
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
  }
133
 
134
  public function get_items_permissions_check( $request ) {
@@ -145,6 +166,18 @@ class LP_Jwt_Courses_V1_Controller extends LP_REST_Jwt_Posts_Controller {
145
  return true;
146
  }
147
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  /**
149
  * Checks if a course can be read.
150
  *
@@ -211,6 +244,133 @@ class LP_Jwt_Courses_V1_Controller extends LP_REST_Jwt_Posts_Controller {
211
  return learn_press_get_course( $id );
212
  }
213
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214
  public function enroll_course( $request ) {
215
  if ( ! class_exists( 'LP_REST_Courses_Controller' ) ) {
216
  include_once LP_PLUGIN_PATH . 'inc/rest-api/v1/frontend/class-lp-rest-courses-controller.php';
@@ -783,10 +943,10 @@ class LP_Jwt_Courses_V1_Controller extends LP_REST_Jwt_Posts_Controller {
783
  if ( is_bool( $request['on_sale'] ) ) {
784
  $on_sale_key = $request['on_sale'] ? 'post__in' : 'post__not_in';
785
 
786
- $filter = new LP_Course_Filter();
787
- $filter->only_fields = array( 'ID' );
788
 
789
- $filter = LP_Course_DB::getInstance()->get_courses_sort_by_sale( $filter );
790
  $on_sale_ids = LP_Course_DB::getInstance()->get_courses( $filter );
791
  $on_sale_ids = LP_course::get_course_ids( $on_sale_ids );
792
  $on_sale_ids = empty( $on_sale_ids ) ? array( 0 ) : $on_sale_ids;
@@ -795,12 +955,12 @@ class LP_Jwt_Courses_V1_Controller extends LP_REST_Jwt_Posts_Controller {
795
  } elseif ( is_bool( $request['popular'] ) ) {
796
  $on_popular_key = $request['popular'] ? 'post__in' : 'post__not_in';
797
 
798
- $filter = new LP_Course_Filter();
799
- $filter->only_fields = array( 'ID' );
800
- $filter->limit = $request['per_page'] ?? 10;
801
- $filter->page = $request['page'] ?? 1;
802
 
803
- $filter = LP_Course_DB::getInstance()->get_courses_order_by_popular( $filter );
804
  $on_popular_ids = LP_Course_DB::getInstance()->get_courses( $filter );
805
  $on_popular_ids = LP_course::get_course_ids( $on_popular_ids );
806
 
68
  array(
69
  'methods' => WP_REST_Server::CREATABLE,
70
  'callback' => array( $this, 'enroll_course' ),
71
+ 'permission_callback' => array( $this, 'get_course_need_login_check' ),
72
  'args' => array(
73
  'context' => $this->get_context_param(
74
  array(
129
  ),
130
  )
131
  );
132
+
133
+ register_rest_route(
134
+ $this->namespace,
135
+ '/' . $this->rest_base . '/verify-receipt',
136
+ array(
137
+ 'methods' => WP_REST_Server::CREATABLE,
138
+ 'callback' => array( $this, 'verify_receipt' ),
139
+ 'permission_callback' => '__return_true',
140
+ 'args' => array(
141
+ 'context' => $this->get_context_param(
142
+ array(
143
+ 'default' => 'edit',
144
+ )
145
+ ),
146
+ 'receipt-data' => array(
147
+ 'description' => esc_html__( 'Receipt data.', 'learnpress' ),
148
+ 'type' => 'string',
149
+ ),
150
+ ),
151
+ )
152
+ );
153
  }
154
 
155
  public function get_items_permissions_check( $request ) {
166
  return true;
167
  }
168
 
169
+ public function get_course_need_login_check( $request ) {
170
+ if ( ! is_user_logged_in() ) {
171
+ return new WP_Error(
172
+ 'rest_forbidden_context',
173
+ __( 'Please login to continue' ),
174
+ array( 'status' => 401 )
175
+ );
176
+ }
177
+
178
+ return true;
179
+ }
180
+
181
  /**
182
  * Checks if a course can be read.
183
  *
244
  return learn_press_get_course( $id );
245
  }
246
 
247
+ public function verify_receipt( $request ) {
248
+ $response = new LP_REST_Response();
249
+ $receipt = ! empty( $request['receipt-data'] ) ? $request['receipt-data'] : '';
250
+ $is_ios = ! empty( $request['is-ios'] ) ? true : false;
251
+ $password = LP()->settings()->get( 'in_app_purchase_apple_shared_secret', '' );
252
+
253
+ try {
254
+ if ( empty( $receipt ) ) {
255
+ throw new Exception( __( 'Receipt data is empty.', 'learnpress' ) );
256
+ }
257
+
258
+ if ( $is_ios ) {
259
+ $course_id = ! empty( $request['course-id'] ) ? absint( $request['course-id'] ) : 0;
260
+
261
+ if ( empty( $password ) ) {
262
+ throw new Exception( __( 'Secret key is empty.', 'learnpress' ) );
263
+ }
264
+
265
+ $url = LP()->settings()->get( 'in_app_purchase_apple_sandbox' ) === 'yes' ? 'https://sandbox.itunes.apple.com/verifyReceipt' : 'https://buy.itunes.apple.com/verifyReceipt';
266
+
267
+ $verify = wp_remote_post(
268
+ $url,
269
+ array(
270
+ 'method' => 'POST',
271
+ 'timeout' => 60,
272
+ 'body' => wp_json_encode(
273
+ array(
274
+ 'receipt-data' => $receipt,
275
+ 'password' => $password,
276
+ )
277
+ ),
278
+ )
279
+ );
280
+
281
+ if ( is_wp_error( $verify ) ) {
282
+ throw new Exception( $verify->get_error_message() );
283
+ }
284
+
285
+ $body = json_decode( wp_remote_retrieve_body( $verify ) );
286
+
287
+ if ( $body->status !== 0 ) {
288
+ throw new Exception( __( 'Cannot verify receipt', 'learnpress' ) );
289
+ }
290
+
291
+ $latest_receipt_info = ! empty( $body->latest_receipt_info ) ? $body->latest_receipt_info : array();
292
+
293
+ if ( empty( $latest_receipt_info ) ) {
294
+ throw new Exception( __( 'Course id is invalid.', 'learnpress' ) );
295
+ }
296
+
297
+ $course_ids = array_map(
298
+ function( $receipt_id ) {
299
+ return absint( $receipt_id->product_id );
300
+ },
301
+ $latest_receipt_info
302
+ );
303
+
304
+ if ( ! in_array( $course_id, $course_ids ) ) {
305
+ throw new Exception( __( 'Course id is invalid.', 'learnpress' ) );
306
+ }
307
+ } else {
308
+ $receipt = json_decode( $receipt, true );
309
+ $package_name = $receipt['packageName'] ?? '';
310
+ $course_id = ! empty( $receipt['productId'] ) ? absint( $receipt['productId'] ) : 0;
311
+ $purchase_token = $receipt['purchaseToken'] ?? '';
312
+
313
+ if ( ! function_exists( 'learnpress_in_app_purchase_get_access_token' ) ) {
314
+ throw new Exception( __( 'Cannot verify receipt', 'learnpress' ) );
315
+ }
316
+
317
+ $access_token = learnpress_in_app_purchase_get_access_token();
318
+
319
+ $verify = wp_remote_get( 'https://androidpublisher.googleapis.com/androidpublisher/v3/applications/' . $package_name . '/purchases/products/' . $course_id . '/tokens/' . $purchase_token . '?access_token=' . $access_token );
320
+
321
+ $body = json_decode( wp_remote_retrieve_body( $verify ) );
322
+
323
+ if ( isset( $body->error->message ) ) {
324
+ throw new Exception( $body->error->message );
325
+ }
326
+ }
327
+
328
+ $course = learn_press_get_course( $course_id );
329
+
330
+ if ( ! $course ) {
331
+ throw new Exception( __( 'Course is not exists.', 'learnpress' ) );
332
+ }
333
+ $user = learn_press_get_current_user();
334
+
335
+ $cart = LP()->cart;
336
+ $checkout = LP_Checkout::instance();
337
+
338
+ if ( ! learn_press_enable_cart() ) {
339
+ $order_awaiting_payment = LP()->session->order_awaiting_payment;
340
+ $cart->empty_cart();
341
+ LP()->session->order_awaiting_payment = $order_awaiting_payment;
342
+ }
343
+
344
+ $cart_id = $cart->add_to_cart( $course_id, 1, array() );
345
+
346
+ if ( ! $cart_id ) {
347
+ throw new Exception( esc_html__( 'Error: Can\'t add Course to cart.', 'learnpress' ) );
348
+ }
349
+
350
+ if ( is_user_logged_in() ) {
351
+ $order_id = $checkout->create_order();
352
+
353
+ if ( is_wp_error( $order_id ) ) {
354
+ throw new Exception( $order_id->get_error_message() );
355
+ }
356
+
357
+ $order = new LP_Order( $order_id );
358
+
359
+ $order->payment_complete();
360
+
361
+ $cart->empty_cart();
362
+ }
363
+
364
+ $response->status = 'success';
365
+ $response->message = esc_html__( 'Verify Receipt Data successfully.', 'learnpress' );
366
+ } catch ( \Throwable $th ) {
367
+ $response->status = 'error';
368
+ $response->message = $th->getMessage();
369
+ }
370
+
371
+ return rest_ensure_response( $response );
372
+ }
373
+
374
  public function enroll_course( $request ) {
375
  if ( ! class_exists( 'LP_REST_Courses_Controller' ) ) {
376
  include_once LP_PLUGIN_PATH . 'inc/rest-api/v1/frontend/class-lp-rest-courses-controller.php';
943
  if ( is_bool( $request['on_sale'] ) ) {
944
  $on_sale_key = $request['on_sale'] ? 'post__in' : 'post__not_in';
945
 
946
+ $filter = new LP_Course_Filter();
947
+ $filter->only_fields = array( 'ID' );
948
 
949
+ $filter = LP_Course_DB::getInstance()->get_courses_sort_by_sale( $filter );
950
  $on_sale_ids = LP_Course_DB::getInstance()->get_courses( $filter );
951
  $on_sale_ids = LP_course::get_course_ids( $on_sale_ids );
952
  $on_sale_ids = empty( $on_sale_ids ) ? array( 0 ) : $on_sale_ids;
955
  } elseif ( is_bool( $request['popular'] ) ) {
956
  $on_popular_key = $request['popular'] ? 'post__in' : 'post__not_in';
957
 
958
+ $filter = new LP_Course_Filter();
959
+ $filter->only_fields = array( 'ID' );
960
+ $filter->limit = $request['per_page'] ?? 10;
961
+ $filter->page = $request['page'] ?? 1;
962
 
963
+ $filter = LP_Course_DB::getInstance()->get_courses_order_by_popular( $filter );
964
  $on_popular_ids = LP_Course_DB::getInstance()->get_courses( $filter );
965
  $on_popular_ids = LP_course::get_course_ids( $on_popular_ids );
966
 
inc/rest-api/v1/frontend/class-lp-rest-lazy-load-controller.php CHANGED
@@ -218,8 +218,9 @@ class LP_REST_Lazy_Load_Controller extends LP_Abstract_REST_Controller {
218
 
219
  // For old value use on theme Eduma <= v4.6.0 - deprecated 4.1.6.1
220
  if ( defined( 'THIM_THEME_VERSION' ) && version_compare( THIM_THEME_VERSION, '4.6.3', '<=' ) ) {
221
- $response->pages = $sections['pages'];
222
- $response->data = $content;
 
223
  }
224
  } catch ( \Throwable $th ) {
225
  $response->message = $th->getMessage();
@@ -311,6 +312,7 @@ class LP_REST_Lazy_Load_Controller extends LP_Abstract_REST_Controller {
311
  // For old value use on theme Eduma <= v4.6.0 - deprecated 4.1.6.1
312
  if ( defined( 'THIM_THEME_VERSION' ) && version_compare( THIM_THEME_VERSION, '4.6.3', '<=' ) ) {
313
  $response->pages = $section_items['pages'];
 
314
  $response->data = $content;
315
  $response->item_ids = wp_list_pluck( $section_items['results'], 'ID' );
316
  }
218
 
219
  // For old value use on theme Eduma <= v4.6.0 - deprecated 4.1.6.1
220
  if ( defined( 'THIM_THEME_VERSION' ) && version_compare( THIM_THEME_VERSION, '4.6.3', '<=' ) ) {
221
+ $response->pages = $sections['pages'];
222
+ $response->data = $content;
223
+ $response->section_ids = wp_list_pluck( $sections['results'], 'section_id' );
224
  }
225
  } catch ( \Throwable $th ) {
226
  $response->message = $th->getMessage();
312
  // For old value use on theme Eduma <= v4.6.0 - deprecated 4.1.6.1
313
  if ( defined( 'THIM_THEME_VERSION' ) && version_compare( THIM_THEME_VERSION, '4.6.3', '<=' ) ) {
314
  $response->pages = $section_items['pages'];
315
+ $response->page = $filters->page;
316
  $response->data = $content;
317
  $response->item_ids = wp_list_pluck( $section_items['results'], 'ID' );
318
  }
learnpress.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin URI: http://thimpress.com/learnpress
5
  * Description: LearnPress is a WordPress complete solution for creating a Learning Management System (LMS). It can help you to create courses, lessons and quizzes.
6
  * Author: ThimPress
7
- * Version: 4.1.6.2
8
  * Author URI: http://thimpress.com
9
  * Requires at least: 5.6
10
  * Tested up to: 5.9
4
  * Plugin URI: http://thimpress.com/learnpress
5
  * Description: LearnPress is a WordPress complete solution for creating a Learning Management System (LMS). It can help you to create courses, lessons and quizzes.
6
  * Author: ThimPress
7
+ * Version: 4.1.6.3
8
  * Author URI: http://thimpress.com
9
  * Requires at least: 5.6
10
  * Tested up to: 5.9
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: elearning, education, course, lms, learning management system
5
  Requires at least: 5.6
6
  Tested up to: 5.9
7
  Requires PHP: 7.0
8
- Stable tag: 4.1.6.2
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -203,7 +203,16 @@ https://www.transifex.com/projects/p/learnpress/
203
 
204
  == Changelog ==
205
 
206
- = 4.1.6.2 (2022-04-05) =
 
 
 
 
 
 
 
 
 
207
  ~ Fixed: go to last item of section still show button "load more items".
208
  ~ Fixed: "Undefined" when click "load more sections" on theme Eduma.
209
 
5
  Requires at least: 5.6
6
  Tested up to: 5.9
7
  Requires PHP: 7.0
8
+ Stable tag: 4.1.6.3
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
203
 
204
  == Changelog ==
205
 
206
+ = 4.1.6.3 (2022-04-20) =
207
+ ~ Fixed: sort section of course.
208
+ ~ Fixed: sort item of course's section when edit course.
209
+ ~ Fixed: sometime call get_curriculum empty.
210
+ ~ Modified: fixed when set seconds big (about 100 hours), can't convert to format time right.
211
+ ~ Fixed: duplicate course not duplicate sections, items.
212
+ ~ Fixed: error wp.media on page Email setting.
213
+ ~ Fixed: count wrong order on the backend.
214
+
215
+ = 4.1.6.2 (2022-04-04) =
216
  ~ Fixed: go to last item of section still show button "load more items".
217
  ~ Fixed: "Undefined" when click "load more sections" on theme Eduma.
218