LearnPress – WordPress LMS Plugin - Version 2.1.4

Version Description

  • Added option for external link of "Buy this course"
  • Improved user roles while edit a course and it's items
  • Removed "Show/Hide" questions option of quiz in Global Settings
  • Removed option "Show/Hide" explanation for quiz
  • Removed "Preview" label of course items if course is no required enroll
  • Fixed guest user can not start quiz on wpengine site
  • Fixed "Start quiz" does not show for "No require enrollment" course
  • Fixed course id is missing after duplicating course
  • Fixed course results is incorrect with 'Evaluate lessons' option
  • Fixed wrong review course before publish
  • And more...
Download this release

Release Info

Developer leehld
Plugin Icon 128x128 LearnPress – WordPress LMS Plugin
Version 2.1.4
Comparing to
See all releases

Code changes from version 2.1.6.1 to 2.1.4

Files changed (180) hide show
  1. assets/css/admin/admin.css +20 -30
  2. assets/css/admin/admin.less +37 -44
  3. assets/css/admin/attributes.css +17 -17
  4. assets/css/admin/attributes.less +0 -18
  5. assets/css/admin/meta-box-course.css +141 -76
  6. assets/css/admin/meta-box-course.less +176 -108
  7. assets/css/admin/meta-box-order.css +44 -46
  8. assets/css/admin/meta-box-question.css +52 -0
  9. assets/css/learnpress.css +99 -355
  10. assets/css/learnpress.less +41 -335
  11. assets/js/admin/admin.js +1 -1
  12. assets/js/admin/attributes.js +0 -92
  13. assets/js/admin/course-editor.js +6 -6
  14. assets/js/admin/meta-box-course.js +15 -30
  15. assets/js/admin/meta-box-order.js +18 -37
  16. assets/js/admin/meta-box-quiz.js +1 -13
  17. assets/js/frontend/course-filters.js +0 -146
  18. assets/js/frontend/learnpress.js +2 -1
  19. assets/js/frontend/lesson.js +6 -3
  20. assets/js/frontend/profile.js +236 -0
  21. assets/js/frontend/single-course.js +16 -56
  22. assets/js/global.js +22 -25
  23. assets/js/global.min.js +2 -2
  24. inc/admin/class-lp-admin-ajax.php +144 -155
  25. inc/admin/class-lp-admin-menu.php +0 -24
  26. inc/admin/class-lp-profile.php +139 -0
  27. inc/admin/dashboard-statistics/class-lp-statistic-status.php +4 -4
  28. inc/admin/includes/class-markdown-parse.php +5 -7
  29. inc/admin/lp-admin-functions.php +184 -202
  30. inc/admin/meta-boxes/class-course-tabs-field.php +1 -1
  31. inc/admin/meta-boxes/class-curriculum-field.php +316 -0
  32. inc/admin/meta-boxes/class-meta-box-tabs.php +18 -0
  33. inc/admin/settings/class-lp-settings-emails.php +21 -44
  34. inc/admin/settings/class-lp-settings-general.php +1 -11
  35. inc/admin/views/meta-boxes/course/attributes.php +0 -45
  36. inc/admin/views/meta-boxes/course/curriculum.php +33 -33
  37. inc/admin/views/meta-boxes/course/html-course-attribute.php +0 -35
  38. inc/admin/views/meta-boxes/course/loop-item.php +36 -56
  39. inc/admin/views/meta-boxes/course/loop-section.php +55 -26
  40. inc/admin/views/meta-boxes/course/review-logs.php +2 -2
  41. inc/admin/views/meta-boxes/order/actions.php +10 -33
  42. inc/admin/views/meta-boxes/order/details.php +12 -25
  43. inc/admin/views/settings/emails/enrolled-course-admin.php +0 -76
  44. inc/admin/views/settings/emails/update-course.php +0 -50
  45. inc/admin/views/settings/emails/user-order-changed-status.php +0 -68
  46. inc/attributes/course.php +0 -399
  47. inc/attributes/lp-attributes-functions.php +0 -175
  48. inc/class-lp-assets.php +32 -38
  49. inc/class-lp-cache.php +62 -168
  50. inc/class-lp-emails.php +29 -35
  51. inc/class-lp-page-controller.php +15 -6
  52. inc/class-lp-query.php +124 -15
  53. inc/class-lp-request-handler.php +12 -39
  54. inc/class-lp-schedules.php +5 -48
  55. inc/class-lp-settings.php +1 -7
  56. inc/class-lp-shortcodes.php +62 -247
  57. inc/class-lp-widget.php +0 -395
  58. inc/course/abstract-lp-course.php +134 -204
  59. inc/course/lp-course-functions.php +130 -159
  60. inc/custom-post-types/course.php +146 -100
  61. inc/custom-post-types/order.php +15 -149
  62. inc/custom-post-types/quiz.php +41 -50
  63. inc/debug.php +0 -7
  64. inc/emails/class-lp-email-enrolled-course-admin.php +0 -172
  65. inc/emails/class-lp-email-update-course.php +0 -130
  66. inc/emails/class-lp-email-user-order-changed-status.php +0 -109
  67. inc/emails/class-lp-email-user-order-completed.php +52 -35
  68. inc/emails/class-lp-email.php +4 -16
  69. inc/lesson/lp-lesson-functions.php +8 -26
  70. inc/libraries/meta-box/inc/fields/checkbox-list.php +5 -10
  71. inc/libraries/meta-box/inc/fields/datetime.php +1 -1
  72. inc/{admin/meta-boxes → libraries/meta-box/inc/fields}/duration.php +2 -15
  73. inc/libraries/meta-box/inc/fields/time.php +2 -2
  74. inc/libraries/meta-box/inc/meta-box.php +1 -1
  75. inc/libraries/meta-box/meta-box.php +7 -17
  76. inc/lp-constants.php +2 -7
  77. inc/lp-core-functions.php +40 -115
  78. inc/lp-init.php +108 -197
  79. inc/lp-template-functions.php +65 -33
  80. inc/lp-template-hooks.php +0 -3
  81. inc/order/class-lp-order.php +19 -126
  82. inc/order/lp-order-functions.php +10 -66
  83. inc/question/class-lp-question-factory.php +2 -17
  84. inc/quiz/class-lp-quiz-factory.php +9 -19
  85. inc/shortcodes/archive-courses.php +45 -0
  86. inc/shortcodes/class-lp-abstract-archive-shortcode.php +354 -0
  87. inc/shortcodes/course-summary.php +11 -0
  88. inc/shortcodes/featured-courses/featured-course.php +136 -0
  89. inc/shortcodes/featured-courses/featured-courses.php +133 -0
  90. inc/{widgets/course-attributes/tmpl → shortcodes/featured-courses}/index.php +0 -0
  91. inc/shortcodes/featured-courses/templates/cards.php +127 -0
  92. inc/shortcodes/featured-courses/templates/grids.php +131 -0
  93. inc/{widgets/course-filters/tmpl → shortcodes/featured-courses/templates}/index.php +0 -0
  94. inc/shortcodes/featured-courses/templates/list.php +137 -0
  95. inc/shortcodes/index.php +1 -0
  96. inc/shortcodes/popular-courses/index.php +1 -0
  97. inc/shortcodes/popular-courses/popular-course.php +132 -0
  98. inc/shortcodes/popular-courses/popular-courses.php +129 -0
  99. inc/shortcodes/popular-courses/templates/cards.php +127 -0
  100. inc/shortcodes/popular-courses/templates/grids.php +131 -0
  101. inc/shortcodes/popular-courses/templates/index.php +1 -0
  102. inc/shortcodes/popular-courses/templates/list.php +137 -0
  103. inc/shortcodes/recent-courses/index.php +1 -0
  104. inc/shortcodes/recent-courses/recent-courses.php +121 -0
  105. inc/shortcodes/recent-courses/templates/cards.php +127 -0
  106. inc/shortcodes/recent-courses/templates/grids.php +131 -0
  107. inc/shortcodes/recent-courses/templates/index.php +1 -0
  108. inc/shortcodes/recent-courses/templates/list.php +136 -0
  109. inc/updates/09/script.js +2 -1
  110. inc/user/abstract-lp-user.php +29 -88
  111. inc/user/class-lp-profile.php +0 -114
  112. inc/user/class-lp-user-factory.php +5 -25
  113. inc/user/lp-user-functions.php +55 -88
  114. inc/widgets/course-attributes/course-attributes.php +0 -31
  115. inc/widgets/course-attributes/tmpl/default.php +0 -23
  116. inc/widgets/course-filters/course-filters.php +0 -178
  117. inc/widgets/course-filters/tmpl/default.php +0 -90
  118. inc/widgets/featured-courses/featured-course-widget.php +197 -0
  119. inc/widgets/featured-courses/featured-courses.php +0 -139
  120. inc/widgets/featured-courses/form.php +132 -0
  121. inc/widgets/featured-courses/index.php +1 -7
  122. inc/widgets/featured-courses/templates/default.php +78 -0
  123. inc/widgets/featured-courses/templates/index.php +1 -0
  124. inc/widgets/featured-courses/tmpl/default.php +0 -75
  125. inc/widgets/featured-courses/tmpl/index.php +0 -7
  126. inc/widgets/lp-widget-util.php +32 -0
  127. inc/widgets/popular-courses/form.php +132 -0
  128. inc/widgets/popular-courses/index.php +1 -7
  129. inc/widgets/popular-courses/popular-course-widget.php +206 -0
  130. inc/widgets/popular-courses/popular-courses.php +0 -149
  131. inc/widgets/popular-courses/templates/default.php +78 -0
  132. inc/widgets/popular-courses/templates/index.php +1 -0
  133. inc/widgets/popular-courses/tmpl/default.php +0 -0
  134. inc/widgets/popular-courses/tmpl/index.php +0 -7
  135. inc/widgets/recent-courses/form.php +132 -0
  136. inc/widgets/recent-courses/index.php +1 -7
  137. inc/widgets/recent-courses/recent-course-widget.php +194 -0
  138. inc/widgets/recent-courses/recent-courses.php +0 -142
  139. inc/widgets/recent-courses/{tmpl → templates}/default.php +17 -14
  140. inc/widgets/recent-courses/templates/index.php +1 -0
  141. inc/widgets/recent-courses/tmpl/index.php +0 -7
  142. learnpress.php +23 -10
  143. readme.txt +5 -42
  144. templates/content-archive-course.php +1 -1
  145. templates/content-question/multi-choice/answer-options.php +4 -9
  146. templates/content-question/single-choice/answer-options.php +2 -6
  147. templates/content-quiz/buttons.php +1 -6
  148. templates/content-single-course.php +0 -1
  149. templates/emails/enrolled-course-admin.php +0 -17
  150. templates/emails/plain/enrolled-course-admin.php +0 -13
  151. templates/emails/plain/update-course.php +0 -7
  152. templates/emails/plain/user-order-changed-status.php +0 -9
  153. templates/emails/update-course.php +0 -7
  154. templates/emails/user-order-changed-status.php +0 -9
  155. templates/global/become-teacher-form.php +2 -5
  156. templates/global/before-main-content.php +1 -1
  157. templates/order/order-details.php +1 -1
  158. templates/profile/tabs.php +7 -1
  159. templates/profile/tabs/courses/all.php +48 -0
  160. templates/profile/tabs/courses/finished.php +44 -0
  161. templates/profile/tabs/courses/learning.php +45 -0
  162. templates/profile/tabs/courses/loop.php +1 -1
  163. templates/profile/tabs/courses/own.php +55 -0
  164. templates/profile/tabs/courses/purchased.php +44 -0
  165. templates/profile/tabs/edit.php +3 -11
  166. templates/profile/tabs/orders.php +2 -2
  167. templates/single-course/buttons.php +113 -91
  168. templates/single-course/content-item-lp_lesson.php +1 -0
  169. templates/single-course/content-item-only.php +1 -0
  170. templates/single-course/content-item.php +4 -2
  171. templates/single-course/nav-items.php +0 -35
  172. templates/single-course/popup.php +1 -8
  173. templates/single-course/price.php +1 -1
  174. templates/single-course/progress.php +17 -12
  175. templates/single-course/section/item-meta.php +19 -61
  176. templates/single-course/section/item-quiz.php +9 -33
  177. templates/single-course/section/title.php +1 -1
  178. templates/widgets/featured-courses/default.php +0 -85
  179. templates/widgets/popular-courses/default.php +0 -85
  180. templates/widgets/recent-courses/default.php +0 -85
assets/css/admin/admin.css CHANGED
@@ -4,29 +4,17 @@
4
  * @author ThimPress
5
  * @version 1.0
6
  */
7
- input:focus::-webkit-input-placeholder {
8
- color: transparent !important;
9
- }
10
- input:focus::-moz-placeholder {
11
- color: transparent !important;
12
- }
13
- input:focus:-moz-placeholder {
14
- color: transparent !important;
15
- }
16
  .rwmb-field {
17
  margin: 20px 0 20px 0;
18
  }
19
  .rwmb-field .rwmb-input .rwmb-label {
20
  margin-top: 0;
21
  }
22
- .rwmb-field .rwmb-input .description {
23
- margin-top: 5px;
24
- }
25
- .rwmb-field .rwmb-input .description.option-desc {
26
  font-weight: normal;
27
- margin: 8px 0 10px 24px;
28
- font-size: smaller;
29
  font-style: italic;
 
30
  }
31
  .lp-nav-tab-wrapper {
32
  border-bottom: 1px solid #ccc;
@@ -42,6 +30,19 @@ input:focus:-moz-placeholder {
42
  .learn-press-quick-add-page-inline > * {
43
  vertical-align: top;
44
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  #learn-press-admin-settings {
46
  /*input[name="learn_press_single_course_image_size[width]"],
47
  input[name="learn_press_single_course_image_size[height]"],
@@ -272,6 +273,9 @@ input:focus:-moz-placeholder {
272
  .meta_box_course_lesson_quiz li select {
273
  min-width: 250px;
274
  }
 
 
 
275
  .dashed-placeholder {
276
  border: 2px dashed #999;
277
  padding: 10px;
@@ -1510,8 +1514,7 @@ body.post-type-lp_question #question_answer_ .inside {
1510
  }
1511
  .post-type-lp_order #submitpost .misc-pub-section label {
1512
  display: block;
1513
- font-weight: 600;
1514
- margin-bottom: 8px;
1515
  }
1516
  #learn-press-order {
1517
  margin: 15px;
@@ -1913,19 +1916,6 @@ input.regular-text[id^="learn-press-emails"] {
1913
  content: '';
1914
  display: block;
1915
  }
1916
- /* Metabox Widget */
1917
- #widgets-right .widgets-holder-wrap .rwmb-label {
1918
- margin-bottom: 5px;
1919
- }
1920
- #widgets-right .widgets-holder-wrap .rwmb-input input[type="text"] {
1921
- width: 100%;
1922
- }
1923
- #widgets-right .widgets-holder-wrap .description {
1924
- padding: 0;
1925
- margin-top: 5px;
1926
- font-size: small;
1927
- font-style: italic;
1928
- }
1929
  @keyframes learn-press-meta-box-tabs-initialize-animation {
1930
  0% {
1931
  opacity: 0;
4
  * @author ThimPress
5
  * @version 1.0
6
  */
 
 
 
 
 
 
 
 
 
7
  .rwmb-field {
8
  margin: 20px 0 20px 0;
9
  }
10
  .rwmb-field .rwmb-input .rwmb-label {
11
  margin-top: 0;
12
  }
13
+ .rwmb-field .rwmb-input .option-desc {
 
 
 
14
  font-weight: normal;
15
+ padding-left: 24px;
 
16
  font-style: italic;
17
+ margin-top: 3px;
18
  }
19
  .lp-nav-tab-wrapper {
20
  border-bottom: 1px solid #ccc;
30
  .learn-press-quick-add-page-inline > * {
31
  vertical-align: top;
32
  }
33
+ .post-type-lp_course .column-price,
34
+ .post-type-lp_course .column-students {
35
+ width: 10%;
36
+ }
37
+ .post-type-lp_course #course_curriculum .curriculum-section-items .lp-item-empty td.section-item-input {
38
+ padding-left: 40px;
39
+ }
40
+ .post-type-lp_course #course_curriculum .curriculum-section-items .lp-item-empty td.section-item-input.hover {
41
+ padding-left: 0;
42
+ }
43
+ .post-type-lp_course .type-lp_course.status-pending .row-actions .view {
44
+ display: none;
45
+ }
46
  #learn-press-admin-settings {
47
  /*input[name="learn_press_single_course_image_size[width]"],
48
  input[name="learn_press_single_course_image_size[height]"],
273
  .meta_box_course_lesson_quiz li select {
274
  min-width: 250px;
275
  }
276
+ .description {
277
+ margin-top: 5px;
278
+ }
279
  .dashed-placeholder {
280
  border: 2px dashed #999;
281
  padding: 10px;
1514
  }
1515
  .post-type-lp_order #submitpost .misc-pub-section label {
1516
  display: block;
1517
+ font-weight: bold;
 
1518
  }
1519
  #learn-press-order {
1520
  margin: 15px;
1916
  content: '';
1917
  display: block;
1918
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
1919
  @keyframes learn-press-meta-box-tabs-initialize-animation {
1920
  0% {
1921
  opacity: 0;
assets/css/admin/admin.less CHANGED
@@ -8,32 +8,17 @@
8
  @primary-icon-color: #666666;
9
  @primary-icon-hover-color: #00a0d2;
10
 
11
- input:focus::-webkit-input-placeholder {
12
- color: transparent !important;
13
- }
14
-
15
- input:focus::-moz-placeholder {
16
- color: transparent !important;
17
- }
18
-
19
- input:focus:-moz-placeholder {
20
- color: transparent !important;
21
- }
22
-
23
  .rwmb-field {
24
  margin: 20px 0 20px 0;
25
  .rwmb-input {
26
  .rwmb-label {
27
  margin-top: 0;
28
  }
29
- .description {
30
- margin-top: 5px;
31
- &.option-desc {
32
- font-weight: normal;
33
- margin: 8px 0 10px 24px;
34
- font-size: smaller;
35
- font-style: italic;
36
- }
37
  }
38
  }
39
  }
@@ -55,6 +40,29 @@ input:focus:-moz-placeholder {
55
  vertical-align: top;
56
  }
57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  #learn-press-admin-settings {
59
  #learn_press_email_formats {
60
  margin-bottom: 10px;
@@ -198,11 +206,11 @@ input:focus:-moz-placeholder {
198
  border-bottom: 1px solid #23282d;
199
  width: 20px;
200
  position: absolute;
201
- top: 50%;
202
  left: 8px;
203
  }
204
- &:hover {
205
- &:before {
206
  border-color: #FFF;
207
  }
208
  }
@@ -318,6 +326,10 @@ input:focus:-moz-placeholder {
318
  min-width: 250px;
319
  }
320
 
 
 
 
 
321
  .dashed-placeholder {
322
  border: 2px dashed #999;
323
  padding: 10px;
@@ -1810,8 +1822,7 @@ body.post-type-lp_question #question_answer_ .inside {
1810
 
1811
  .post-type-lp_order #submitpost .misc-pub-section label {
1812
  display: block;
1813
- font-weight: 600;
1814
- margin-bottom: 8px;
1815
  }
1816
 
1817
  #learn-press-order {
@@ -2271,24 +2282,6 @@ input.regular-text[id^="learn-press-emails"] {
2271
  }
2272
  }
2273
 
2274
- /* Metabox Widget */
2275
- #widgets-right .widgets-holder-wrap {
2276
- .rwmb-label {
2277
- margin-bottom: 5px;
2278
- }
2279
- .rwmb-input{
2280
- input[type="text"]{
2281
- width: 100%;
2282
- }
2283
- }
2284
- .description {
2285
- padding: 0;
2286
- margin-top: 5px;
2287
- font-size: small;
2288
- font-style: italic;
2289
- }
2290
- }
2291
-
2292
  @keyframes learn-press-meta-box-tabs-initialize-animation {
2293
  0% {
2294
  opacity: 0;
@@ -2347,4 +2340,4 @@ input.regular-text[id^="learn-press-emails"] {
2347
  100% {
2348
  opacity: 0;
2349
  }
2350
- }
8
  @primary-icon-color: #666666;
9
  @primary-icon-hover-color: #00a0d2;
10
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  .rwmb-field {
12
  margin: 20px 0 20px 0;
13
  .rwmb-input {
14
  .rwmb-label {
15
  margin-top: 0;
16
  }
17
+ .option-desc {
18
+ font-weight: normal;
19
+ padding-left: 24px;
20
+ font-style: italic;
21
+ margin-top: 3px;
 
 
 
22
  }
23
  }
24
  }
40
  vertical-align: top;
41
  }
42
 
43
+ .post-type-lp_course {
44
+ & .column-price, & .column-students {
45
+ width: 10%;
46
+ }
47
+
48
+ #course_curriculum .curriculum-section-items .lp-item-empty td.section-item-input {
49
+ padding-left: 40px;
50
+ &.hover {
51
+ padding-left: 0;
52
+ }
53
+ }
54
+
55
+ .type-lp_course {
56
+
57
+ &.status-pending {
58
+ .row-actions .view {
59
+ display: none;
60
+ }
61
+ }
62
+ }
63
+
64
+ }
65
+
66
  #learn-press-admin-settings {
67
  #learn_press_email_formats {
68
  margin-bottom: 10px;
206
  border-bottom: 1px solid #23282d;
207
  width: 20px;
208
  position: absolute;
209
+ top:50%;
210
  left: 8px;
211
  }
212
+ &:hover{
213
+ &:before{
214
  border-color: #FFF;
215
  }
216
  }
326
  min-width: 250px;
327
  }
328
 
329
+ .description {
330
+ margin-top: 5px;
331
+ }
332
+
333
  .dashed-placeholder {
334
  border: 2px dashed #999;
335
  padding: 10px;
1822
 
1823
  .post-type-lp_order #submitpost .misc-pub-section label {
1824
  display: block;
1825
+ font-weight: bold;
 
1826
  }
1827
 
1828
  #learn-press-order {
2282
  }
2283
  }
2284
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2285
  @keyframes learn-press-meta-box-tabs-initialize-animation {
2286
  0% {
2287
  opacity: 0;
2340
  100% {
2341
  opacity: 0;
2342
  }
2343
+ }
assets/css/admin/attributes.css CHANGED
@@ -1,17 +1,17 @@
1
- .course-attributes {
2
- margin: 20px 0;
3
- }
4
- .course-attributes .learn-press-attribute {
5
- border: 1px solid #DDD;
6
- margin-top: -1px;
7
- margin-bottom: 0;
8
- }
9
- .course-attributes .learn-press-attribute > h4 {
10
- padding: 10px 15px;
11
- margin: 0;
12
- background: #F5F5F5;
13
- }
14
- .course-attributes .learn-press-attribute .learn-press-attribute-data {
15
- padding: 15px;
16
- border-top: 1px solid #DDD;
17
- }
1
+ .course-attributes {
2
+ margin: 20px 0;
3
+ }
4
+ .course-attributes .learn-press-attribute {
5
+ border: 1px solid #DDD;
6
+ margin-top: -1px;
7
+ margin-bottom: 0;
8
+ }
9
+ .course-attributes .learn-press-attribute > h4 {
10
+ padding: 10px 15px;
11
+ margin: 0;
12
+ background: #F5F5F5;
13
+ }
14
+ .course-attributes .learn-press-attribute .learn-press-attribute-data {
15
+ padding: 15px;
16
+ border-top: 1px solid #DDD;
17
+ }
assets/css/admin/attributes.less DELETED
@@ -1,18 +0,0 @@
1
- .course-attributes {
2
- margin: 20px 0;
3
- .learn-press-attribute {
4
- border: 1px solid #DDD;
5
- margin-top: -1px;
6
- margin-bottom: 0;
7
- > h4 {
8
- padding: 10px 15px;
9
- margin: 0;
10
- background: #F5F5F5;
11
- }
12
- .learn-press-attribute-data {
13
- padding: 15px;
14
- border-top: 1px solid #DDD;
15
- }
16
- }
17
- }
18
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/css/admin/meta-box-course.css CHANGED
@@ -3,13 +3,6 @@
3
  .rwmb-duration-wrapper select {
4
  vertical-align: baseline;
5
  }
6
- #learn-press-toggle-course-results {
7
- display: block;
8
- margin-bottom: 10px;
9
- }
10
- #learn-press-toggle-course-results a {
11
- box-shadow: none;
12
- }
13
  .post-type-lp_course #postdivric,
14
  .post-type-lp_course #submitpost {
15
  visibility: hidden;
@@ -32,68 +25,65 @@
32
  font-size: 12px;
33
  font-style: italic;
34
  }
35
- #lp-course-curriculum {
 
 
 
36
  border: none;
37
  background-color: transparent;
38
- margin: 20px 0;
39
- }
40
- .post-type-lp_course .column-price,
41
- .post-type-lp_course .column-students {
42
- width: 10%;
43
- }
44
- .post-type-lp_course #lp-course-curriculum .curriculum-section-items .lp-item-empty td.section-item-input {
45
- padding-left: 40px;
46
  }
47
- .post-type-lp_course #lp-course-curriculum .curriculum-section-items .lp-item-empty td.section-item-input.hover {
48
- padding-left: 0;
49
- }
50
- .post-type-lp_course .type-lp_course.status-pending .row-actions .view {
51
  display: none;
52
  }
53
- #lp-course-curriculum .curriculum-heading {
 
 
 
 
54
  margin: 0 0 20px 0;
55
  padding: 10px 20px;
56
  background-color: #FFF;
57
  line-height: 1;
58
  border: 1px solid #DDD;
59
  }
60
- #lp-course-curriculum .curriculum-heading .description {
61
  font-weight: normal;
62
  color: #999;
63
  display: block;
64
  font-size: 90%;
65
  margin-top: 10px;
66
  }
67
- #lp-course-curriculum .curriculum-heading .items-toggle {
68
  float: right;
69
  margin: -33px 7px 0 0;
70
  line-height: 1;
71
  box-shadow: none;
72
  }
73
- #lp-course-curriculum .curriculum-heading .items-toggle a {
74
  -webkit-box-shadow: none;
75
  -moz-box-shadow: none;
76
  box-shadow: none;
77
  font-size: 32px;
78
  }
79
- #lp-course-curriculum .curriculum-sections {
80
  margin: 0;
81
  background-color: #FFF;
82
  border-bottom: 1px solid #DDD;
83
  }
84
- #lp-course-curriculum .curriculum-section {
85
  margin: -1px 0 0 0;
86
  background-color: #FFF;
87
  border-bottom: 1px solid #DDD;
88
  position: relative;
89
  }
90
- #lp-course-curriculum .curriculum-section.ui-sortable-placeholder {
91
  background-image: url("../../images/stripe.png");
92
  visibility: visible !important;
93
  border: 1px solid #DDD;
94
  border-bottom: none;
95
  }
96
- #lp-course-curriculum .curriculum-section-head {
97
  border: 1px solid #DDD;
98
  background-color: #F9F9F9;
99
  border-bottom: none;
@@ -101,37 +91,37 @@
101
  color: #777;
102
  padding: 3px 20px;
103
  }
104
- #lp-course-curriculum .curriculum-section-head input {
105
  background-color: #F9F9F9;
106
  }
107
- #lp-course-curriculum .curriculum-section-head .lp-section-actions {
108
  float: right;
109
  margin: 14px 0;
110
  visibility: hidden;
111
  position: relative;
112
  }
113
- #lp-course-curriculum .curriculum-section:not(.lp-empty-section) .curriculum-section-head:hover .lp-section-actions {
114
  visibility: visible;
115
  }
116
- #lp-course-curriculum .curriculum-section .lp-section-actions a {
117
  vertical-align: middle;
118
  color: #666666;
119
  width: 24px;
120
  height: 24px;
121
  box-shadow: none;
122
  }
123
- #lp-course-curriculum .curriculum-section .lp-section-actions a[data-action="expand"] {
124
  line-height: 28px;
125
  }
126
- #lp-course-curriculum .curriculum-section .lp-section-actions a:before {
127
  width: 24px;
128
  height: 24px;
129
  font-size: 24px;
130
  }
131
- #lp-course-curriculum .curriculum-section .lp-section-actions a:hover {
132
  color: #00a0d2;
133
  }
134
- #lp-course-curriculum .curriculum-section .curriculum-section-head .lp-section-actions .move {
135
  cursor: url("../../../assets/images/openhand.cur") 7 5, default;
136
  position: absolute;
137
  right: -15px;
@@ -140,17 +130,17 @@
140
  background: url("../../../assets/images/grippy_large.png") right no-repeat;
141
  width: 20px;
142
  }
143
- #lp-course-curriculum .curriculum-section-content {
144
  border: 1px solid #DDD;
145
  padding: 20px;
146
  border-bottom-width: 0;
147
  width: 100%;
148
  box-sizing: border-box;
149
  }
150
- #lp-course-curriculum .curriculum-section.ui-sortable-helper {
151
  border-bottom: 1px solid #DDD;
152
  }
153
- #lp-course-curriculum .curriculum-section-head .lp-section-name {
154
  border: none;
155
  outline: none;
156
  box-shadow: none;
@@ -161,65 +151,65 @@
161
  padding: 0;
162
  height: 50px;
163
  }
164
- #lp-course-curriculum .curriculum-section-head .lp-section-name:focus {
165
  color: #444;
166
  }
167
- #lp-course-curriculum .curriculum-section.lp-empty-section .curriculum-section-content {
168
  _display: none;
169
  }
170
- #lp-course-curriculum .curriculum-section-items {
171
  border-collapse: collapse;
172
  width: 100%;
173
  }
174
- #lp-course-curriculum .curriculum-section-items .lp-section-item {
175
  border: 1px dashed #DDD;
176
  margin: -1px 0 0 0;
177
  padding: 5px 0;
178
  background-color: #FFF;
179
  }
180
- #lp-course-curriculum .curriculum-section-items .lp-section-item:nth-child(2n+1),
181
- #lp-course-curriculum .curriculum-section-items .lp-section-item:nth-child(2n+1) .section-item-input input {
182
  background-color: #FCFCFC;
183
  }
184
- #lp-course-curriculum .curriculum-section-items .lp-section-item .lp-item-actions {
185
  margin: 0;
186
  float: right;
187
  position: relative;
188
  }
189
- #lp-course-curriculum .curriculum-section-items .lp-section-item .lp-item-actions a {
190
  vertical-align: middle;
191
  color: #666;
192
  margin-top: -2px;
193
  box-shadow: none;
194
  }
195
- #lp-course-curriculum .curriculum-section-items .lp-section-item .lp-item-actions a:hover {
196
  color: #00a0d2;
197
  }
198
- #lp-course-curriculum .curriculum-section-items .lp-section-item[data-item_id=""] .lp-edit {
199
  display: none;
200
  }
201
- #lp-course-curriculum .curriculum-section-items .lp-section-item.lp-item-empty .lp-item-actions {
202
  display: none;
203
  }
204
- #lp-course-curriculum .lp-section-item.ui-sortable-placeholder {
205
  visibility: visible !important;
206
  }
207
- #lp-course-curriculum .lp-section-item.ui-sortable-placeholder td {
208
  background-image: url("../../../assets/images/stripe.png");
209
  border-bottom: none;
210
  }
211
- #lp-course-curriculum .lp-item-actions > * {
212
  visibility: hidden;
213
  }
214
- #lp-course-curriculum .item-bulk-actions {
215
  text-align: right;
216
  margin-top: 0;
217
  margin-bottom: 15px;
218
  }
219
- #lp-course-curriculum .lp-section-item:not(.lp-item-empty):hover .lp-item-actions > * {
220
  visibility: visible;
221
  }
222
- #lp-course-curriculum .curriculum-section-items .lp-section-item:not(.lp-item-empty) .item-checkbox {
223
  display: inline-block;
224
  height: 34px;
225
  border: none;
@@ -229,26 +219,26 @@
229
  cursor: url("../../../assets/images/openhand.cur") 7 5, default;
230
  visibility: visible;
231
  }
232
- #lp-course-curriculum .curriculum-section-items .lp-section-item .item-checkbox input {
233
  opacity: 0.4;
234
  }
235
- #lp-course-curriculum .curriculum-section-items .lp-section-item:not(.lp-item-empty):hover .item-checkbox input {
236
  opacity: 1;
237
  }
238
- #lp-course-curriculum .lp-item-lp_lesson .handle.learn-press-icon:before {
239
  content: "\e900";
240
  }
241
- #lp-course-curriculum .lp-item-lp_quiz .handle.learn-press-icon:before {
242
  content: "\e901";
243
  }
244
- #lp-course-curriculum .lp-section-item.lp-item-new .handle {
245
  color: #999;
246
  }
247
- #lp-course-curriculum .curriculum-section-items .lp-section-item:hover,
248
- #lp-course-curriculum .curriculum-section-items .lp-section-item:hover input.lp-item-name {
249
  background-color: #F9F9F9;
250
  }
251
- #lp-course-curriculum .lp-section-item .handle {
252
  width: 32px;
253
  height: 32px;
254
  display: inline-block;
@@ -258,10 +248,10 @@
258
  line-height: 32px;
259
  color: #00A0D2;
260
  }
261
- #lp-course-curriculum .lp-section-item.remove input.lp-item-name {
262
  color: #FF0000;
263
  }
264
- #lp-course-curriculum .lp-section-item input.lp-item-name {
265
  color: #777;
266
  border: none;
267
  box-shadow: none;
@@ -273,7 +263,7 @@
273
  overflow: hidden;
274
  white-space: nowrap;
275
  }
276
- #lp-course-curriculum .lp-section-describe {
277
  border: none;
278
  box-shadow: none;
279
  color: #999;
@@ -282,11 +272,11 @@
282
  float: left;
283
  padding-left: 0;
284
  }
285
- #lp-course-curriculum .curriculum-section-items .lp-section-item input.lp-item-name:focus,
286
- #lp-course-curriculum input:focus {
287
  color: #444;
288
  }
289
- #lp-course-curriculum .lp-section-item .section-item-icon {
290
  width: 32px;
291
  white-space: nowrap;
292
  }
@@ -302,13 +292,13 @@
302
  cursor: pointer;
303
  border: 1px solid transparent;
304
  }
305
- #lp-course-curriculum .lp-section-item .learn-press-icon.item-lp_quiz:before {
306
  content: "\f469";
307
  }
308
- #lp-course-curriculum .lp-section-item .learn-press-icon.item-lp_lesson:before {
309
  content: "\f330";
310
  }
311
- #lp-course-curriculum .lp-section-item td {
312
  height: 30px;
313
  }
314
  #poststuff .postbox-container {
@@ -483,14 +473,89 @@ tr.focus .learn-press-dropdown-item-types > span.learn-press-icon {
483
  .learn-press-dropdown-item-types li span.learn-press-icon.item-selected {
484
  color: #0085ba;
485
  }
486
- .learn-press-course-attributes {
487
- margin: 20px 0;
488
- }
489
  .post-type-lp_course #switch-course-tabs,
490
  .post-type-lp_course #toggle-meta-boxes {
491
  float: right;
492
  margin-left: 10px;
493
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
494
  /*
495
  #lp-course-curriculum .lp-course-curriculum-toggle{
496
  padding: 0;
3
  .rwmb-duration-wrapper select {
4
  vertical-align: baseline;
5
  }
 
 
 
 
 
 
 
6
  .post-type-lp_course #postdivric,
7
  .post-type-lp_course #submitpost {
8
  visibility: hidden;
25
  font-size: 12px;
26
  font-style: italic;
27
  }
28
+ #learn-press-button-toggle-editor {
29
+ margin: 20px 0 0;
30
+ }
31
+ #course_curriculum {
32
  border: none;
33
  background-color: transparent;
 
 
 
 
 
 
 
 
34
  }
35
+ #course_curriculum .handlediv,
36
+ #course_curriculum .hndle {
 
 
37
  display: none;
38
  }
39
+ #course_curriculum .inside {
40
+ margin: 0;
41
+ padding: 0;
42
+ }
43
+ #course_curriculum .curriculum-heading {
44
  margin: 0 0 20px 0;
45
  padding: 10px 20px;
46
  background-color: #FFF;
47
  line-height: 1;
48
  border: 1px solid #DDD;
49
  }
50
+ #course_curriculum .curriculum-heading .description {
51
  font-weight: normal;
52
  color: #999;
53
  display: block;
54
  font-size: 90%;
55
  margin-top: 10px;
56
  }
57
+ #course_curriculum .curriculum-heading .items-toggle {
58
  float: right;
59
  margin: -33px 7px 0 0;
60
  line-height: 1;
61
  box-shadow: none;
62
  }
63
+ #course_curriculum .curriculum-heading .items-toggle a {
64
  -webkit-box-shadow: none;
65
  -moz-box-shadow: none;
66
  box-shadow: none;
67
  font-size: 32px;
68
  }
69
+ #course_curriculum .curriculum-sections {
70
  margin: 0;
71
  background-color: #FFF;
72
  border-bottom: 1px solid #DDD;
73
  }
74
+ #course_curriculum .curriculum-section {
75
  margin: -1px 0 0 0;
76
  background-color: #FFF;
77
  border-bottom: 1px solid #DDD;
78
  position: relative;
79
  }
80
+ #course_curriculum .curriculum-section.ui-sortable-placeholder {
81
  background-image: url("../../images/stripe.png");
82
  visibility: visible !important;
83
  border: 1px solid #DDD;
84
  border-bottom: none;
85
  }
86
+ #course_curriculum .curriculum-section-head {
87
  border: 1px solid #DDD;
88
  background-color: #F9F9F9;
89
  border-bottom: none;
91
  color: #777;
92
  padding: 3px 20px;
93
  }
94
+ #course_curriculum .curriculum-section-head input {
95
  background-color: #F9F9F9;
96
  }
97
+ #course_curriculum .curriculum-section-head .lp-section-actions {
98
  float: right;
99
  margin: 14px 0;
100
  visibility: hidden;
101
  position: relative;
102
  }
103
+ #course_curriculum .curriculum-section:not(.lp-empty-section) .curriculum-section-head:hover .lp-section-actions {
104
  visibility: visible;
105
  }
106
+ #course_curriculum .curriculum-section .lp-section-actions a {
107
  vertical-align: middle;
108
  color: #666666;
109
  width: 24px;
110
  height: 24px;
111
  box-shadow: none;
112
  }
113
+ #course_curriculum .curriculum-section .lp-section-actions a[data-action="expand"] {
114
  line-height: 28px;
115
  }
116
+ #course_curriculum .curriculum-section .lp-section-actions a:before {
117
  width: 24px;
118
  height: 24px;
119
  font-size: 24px;
120
  }
121
+ #course_curriculum .curriculum-section .lp-section-actions a:hover {
122
  color: #00a0d2;
123
  }
124
+ #course_curriculum .curriculum-section .curriculum-section-head .lp-section-actions .move {
125
  cursor: url("../../../assets/images/openhand.cur") 7 5, default;
126
  position: absolute;
127
  right: -15px;
130
  background: url("../../../assets/images/grippy_large.png") right no-repeat;
131
  width: 20px;
132
  }
133
+ #course_curriculum .curriculum-section-content {
134
  border: 1px solid #DDD;
135
  padding: 20px;
136
  border-bottom-width: 0;
137
  width: 100%;
138
  box-sizing: border-box;
139
  }
140
+ #course_curriculum .curriculum-section.ui-sortable-helper {
141
  border-bottom: 1px solid #DDD;
142
  }
143
+ #course_curriculum .curriculum-section-head .lp-section-name {
144
  border: none;
145
  outline: none;
146
  box-shadow: none;
151
  padding: 0;
152
  height: 50px;
153
  }
154
+ #course_curriculum .curriculum-section-head .lp-section-name:focus {
155
  color: #444;
156
  }
157
+ #course_curriculum .curriculum-section.lp-empty-section .curriculum-section-content {
158
  _display: none;
159
  }
160
+ #course_curriculum .curriculum-section-items {
161
  border-collapse: collapse;
162
  width: 100%;
163
  }
164
+ #course_curriculum .curriculum-section-items .lp-section-item {
165
  border: 1px dashed #DDD;
166
  margin: -1px 0 0 0;
167
  padding: 5px 0;
168
  background-color: #FFF;
169
  }
170
+ #course_curriculum .curriculum-section-items .lp-section-item:nth-child(2n+1),
171
+ #course_curriculum .curriculum-section-items .lp-section-item:nth-child(2n+1) .section-item-input input {
172
  background-color: #FCFCFC;
173
  }
174
+ #course_curriculum .curriculum-section-items .lp-section-item .lp-item-actions {
175
  margin: 0;
176
  float: right;
177
  position: relative;
178
  }
179
+ #course_curriculum .curriculum-section-items .lp-section-item .lp-item-actions a {
180
  vertical-align: middle;
181
  color: #666;
182
  margin-top: -2px;
183
  box-shadow: none;
184
  }
185
+ #course_curriculum .curriculum-section-items .lp-section-item .lp-item-actions a:hover {
186
  color: #00a0d2;
187
  }
188
+ #course_curriculum .curriculum-section-items .lp-section-item[data-item_id=""] .lp-edit {
189
  display: none;
190
  }
191
+ #course_curriculum .curriculum-section-items .lp-section-item.lp-item-empty .lp-item-actions {
192
  display: none;
193
  }
194
+ #course_curriculum .lp-section-item.ui-sortable-placeholder {
195
  visibility: visible !important;
196
  }
197
+ #course_curriculum .lp-section-item.ui-sortable-placeholder td {
198
  background-image: url("../../../assets/images/stripe.png");
199
  border-bottom: none;
200
  }
201
+ #course_curriculum .lp-item-actions > * {
202
  visibility: hidden;
203
  }
204
+ #course_curriculum .item-bulk-actions {
205
  text-align: right;
206
  margin-top: 0;
207
  margin-bottom: 15px;
208
  }
209
+ #course_curriculum .lp-section-item:not(.lp-item-empty):hover .lp-item-actions > * {
210
  visibility: visible;
211
  }
212
+ #course_curriculum .curriculum-section-items .lp-section-item:not(.lp-item-empty) .item-checkbox {
213
  display: inline-block;
214
  height: 34px;
215
  border: none;
219
  cursor: url("../../../assets/images/openhand.cur") 7 5, default;
220
  visibility: visible;
221
  }
222
+ #course_curriculum .curriculum-section-items .lp-section-item .item-checkbox input {
223
  opacity: 0.4;
224
  }
225
+ #course_curriculum .curriculum-section-items .lp-section-item:not(.lp-item-empty):hover .item-checkbox input {
226
  opacity: 1;
227
  }
228
+ #course_curriculum .lp-item-lp_lesson .handle.learn-press-icon:before {
229
  content: "\e900";
230
  }
231
+ #course_curriculum .lp-item-lp_quiz .handle.learn-press-icon:before {
232
  content: "\e901";
233
  }
234
+ #course_curriculum .lp-section-item.lp-item-new .handle {
235
  color: #999;
236
  }
237
+ #course_curriculum .curriculum-section-items .lp-section-item:hover,
238
+ #course_curriculum .curriculum-section-items .lp-section-item:hover input.lp-item-name {
239
  background-color: #F9F9F9;
240
  }
241
+ #course_curriculum .lp-section-item .handle {
242
  width: 32px;
243
  height: 32px;
244
  display: inline-block;
248
  line-height: 32px;
249
  color: #00A0D2;
250
  }
251
+ #course_curriculum .lp-section-item.remove input.lp-item-name {
252
  color: #FF0000;
253
  }
254
+ #course_curriculum .lp-section-item input.lp-item-name {
255
  color: #777;
256
  border: none;
257
  box-shadow: none;
263
  overflow: hidden;
264
  white-space: nowrap;
265
  }
266
+ #course_curriculum .lp-section-describe {
267
  border: none;
268
  box-shadow: none;
269
  color: #999;
272
  float: left;
273
  padding-left: 0;
274
  }
275
+ #course_curriculum .curriculum-section-items .lp-section-item input.lp-item-name:focus,
276
+ #course_curriculum input:focus {
277
  color: #444;
278
  }
279
+ #course_curriculum .lp-section-item .section-item-icon {
280
  width: 32px;
281
  white-space: nowrap;
282
  }
292
  cursor: pointer;
293
  border: 1px solid transparent;
294
  }
295
+ #course_curriculum .lp-section-item .learn-press-icon.item-lp_quiz:before {
296
  content: "\f469";
297
  }
298
+ #course_curriculum .lp-section-item .learn-press-icon.item-lp_lesson:before {
299
  content: "\f330";
300
  }
301
+ #course_curriculum .lp-section-item td {
302
  height: 30px;
303
  }
304
  #poststuff .postbox-container {
473
  .learn-press-dropdown-item-types li span.learn-press-icon.item-selected {
474
  color: #0085ba;
475
  }
 
 
 
476
  .post-type-lp_course #switch-course-tabs,
477
  .post-type-lp_course #toggle-meta-boxes {
478
  float: right;
479
  margin-left: 10px;
480
  }
481
+ .post-type-lp_course.enable-course-tabs #post-body-content {
482
+ margin-bottom: 0;
483
+ }
484
+ .post-type-lp_course.enable-course-tabs #normal-sortables .postbox {
485
+ _visibility: hidden;
486
+ float: left;
487
+ margin-right: -100%;
488
+ width: 100%;
489
+ box-sizing: border-box;
490
+ height: 0;
491
+ overflow: hidden;
492
+ border-width: 0;
493
+ }
494
+ .post-type-lp_course.enable-course-tabs #normal-sortables .postbox.active {
495
+ height: auto;
496
+ border-width: 1px;
497
+ }
498
+ .post-type-lp_course.enable-course-tabs #normal-sortables .postbox .handlediv,
499
+ .post-type-lp_course.enable-course-tabs #normal-sortables .postbox .hndle {
500
+ display: none;
501
+ }
502
+ .post-type-lp_course.enable-course-tabs #course-tabs {
503
+ background: #FFF;
504
+ padding: 10px;
505
+ margin-bottom: 0;
506
+ border: 1px solid #DDD;
507
+ border-bottom: none;
508
+ }
509
+ .post-type-lp_course.enable-course-tabs #course-tabs:after {
510
+ display: block;
511
+ clear: both;
512
+ content: '';
513
+ }
514
+ .post-type-lp_course.enable-course-tabs #course-tabs.ui-sortable:not(.ui-sortable-disabled) li.ui-sortable-handle {
515
+ position: relative;
516
+ }
517
+ .post-type-lp_course.enable-course-tabs #course-tabs.ui-sortable:not(.ui-sortable-disabled) li.ui-sortable-handle a {
518
+ border: 1px solid #ddd;
519
+ padding: 0px 5px;
520
+ margin: 0 5px;
521
+ color: #DDD;
522
+ background: #FFF;
523
+ }
524
+ .post-type-lp_course.enable-course-tabs #course-tabs.ui-sortable:not(.ui-sortable-disabled) li.ui-sortable-handle:after {
525
+ content: '';
526
+ position: absolute;
527
+ top: 0;
528
+ left: 0;
529
+ width: 100%;
530
+ height: 100%;
531
+ cursor: move;
532
+ }
533
+ .post-type-lp_course.enable-course-tabs #course-tabs li {
534
+ float: left;
535
+ margin-bottom: 0;
536
+ }
537
+ .post-type-lp_course.enable-course-tabs #course-tabs li a {
538
+ display: block;
539
+ padding: 0 15px 0 0;
540
+ text-decoration: none;
541
+ outline: none;
542
+ box-shadow: none;
543
+ }
544
+ .post-type-lp_course.enable-course-tabs #course-tabs li.active a {
545
+ font-weight: bold;
546
+ }
547
+ .post-type-lp_course.enable-course-tabs #course-tabs li#switch-course-metaboxes {
548
+ float: right;
549
+ }
550
+ .post-type-lp_course.enable-course-tabs #course-tabs li#switch-course-metaboxes #complete-reorder-course-tabs {
551
+ display: none;
552
+ }
553
+ .post-type-lp_course.enable-course-tabs #course-tabs li#switch-course-metaboxes a {
554
+ padding-right: 0;
555
+ color: #FF0000;
556
+ display: inline-block;
557
+ margin-left: 15px;
558
+ }
559
  /*
560
  #lp-course-curriculum .lp-course-curriculum-toggle{
561
  padding: 0;
assets/css/admin/meta-box-course.less CHANGED
@@ -3,10 +3,7 @@
3
  .rwmb-duration-wrapper select {
4
  vertical-align: baseline;
5
  }
6
- #learn-press-toggle-course-results{
7
- display: block;margin-bottom:10px;
8
- a{box-shadow: none;}
9
- }
10
  .post-type-lp_course {
11
  #postdivric,
12
  #submitpost {
@@ -33,36 +30,26 @@
33
  }
34
  }
35
 
36
- #lp-course-curriculum {
 
 
 
 
37
  border: none;
38
  background-color: transparent;
39
- margin: 20px 0;
40
  }
41
 
42
- .post-type-lp_course {
43
- & .column-price, & .column-students {
44
- width: 10%;
45
- }
46
-
47
- #lp-course-curriculum .curriculum-section-items .lp-item-empty td.section-item-input {
48
- padding-left: 40px;
49
- &.hover {
50
- padding-left: 0;
51
- }
52
- }
53
-
54
- .type-lp_course {
55
-
56
- &.status-pending {
57
- .row-actions .view {
58
- display: none;
59
- }
60
- }
61
- }
62
 
 
 
 
63
  }
64
 
65
- #lp-course-curriculum .curriculum-heading {
66
  margin: 0 0 20px 0;
67
  padding: 10px 20px;
68
  background-color: #FFF;
@@ -70,7 +57,7 @@
70
  border: 1px solid #DDD;
71
  }
72
 
73
- #lp-course-curriculum .curriculum-heading .description {
74
  font-weight: normal;
75
  color: #999;
76
  display: block;
@@ -78,14 +65,14 @@
78
  margin-top: 10px;;
79
  }
80
 
81
- #lp-course-curriculum .curriculum-heading .items-toggle {
82
  float: right;
83
  margin: -33px 7px 0 0;
84
  line-height: 1;
85
  box-shadow: none;
86
  }
87
 
88
- #lp-course-curriculum .curriculum-heading .items-toggle a {
89
  -webkit-box-shadow: none;
90
  -moz-box-shadow: none;
91
  box-shadow: none;
@@ -93,27 +80,27 @@
93
 
94
  }
95
 
96
- #lp-course-curriculum .curriculum-sections {
97
  margin: 0;
98
  background-color: #FFF;
99
  border-bottom: 1px solid #DDD;
100
  }
101
 
102
- #lp-course-curriculum .curriculum-section {
103
  margin: -1px 0 0 0;
104
  background-color: #FFF;
105
  border-bottom: 1px solid #DDD;
106
  position: relative;
107
  }
108
 
109
- #lp-course-curriculum .curriculum-section.ui-sortable-placeholder {
110
  background-image: url("../../images/stripe.png");
111
  visibility: visible !important;
112
  border: 1px solid #DDD;
113
  border-bottom: none;
114
  }
115
 
116
- #lp-course-curriculum .curriculum-section-head {
117
  border: 1px solid #DDD;
118
  background-color: #F9F9F9;
119
  border-bottom: none;
@@ -122,22 +109,22 @@
122
  padding: 3px 20px;
123
  }
124
 
125
- #lp-course-curriculum .curriculum-section-head input {
126
  background-color: #F9F9F9;
127
  }
128
 
129
- #lp-course-curriculum .curriculum-section-head .lp-section-actions {
130
  float: right;
131
  margin: 14px 0;
132
  visibility: hidden;
133
  position: relative;
134
  }
135
 
136
- #lp-course-curriculum .curriculum-section:not(.lp-empty-section) .curriculum-section-head:hover .lp-section-actions {
137
  visibility: visible;
138
  }
139
 
140
- #lp-course-curriculum .curriculum-section .lp-section-actions a {
141
  vertical-align: middle;
142
  color: #666666;
143
  width: 24px;
@@ -145,21 +132,21 @@
145
  box-shadow: none;
146
  }
147
 
148
- #lp-course-curriculum .curriculum-section .lp-section-actions a[data-action="expand"] {
149
  line-height: 28px;
150
  }
151
 
152
- #lp-course-curriculum .curriculum-section .lp-section-actions a:before {
153
  width: 24px;
154
  height: 24px;
155
  font-size: 24px;
156
  }
157
 
158
- #lp-course-curriculum .curriculum-section .lp-section-actions a:hover {
159
  color: #00a0d2;
160
  }
161
 
162
- #lp-course-curriculum .curriculum-section .curriculum-section-head .lp-section-actions .move {
163
  cursor: url("../../../assets/images/openhand.cur") 7 5, default;
164
  position: absolute;
165
  right: -15px;
@@ -169,7 +156,7 @@
169
  width: 20px;
170
  }
171
 
172
- #lp-course-curriculum .curriculum-section-content {
173
  border: 1px solid #DDD;
174
  padding: 20px;
175
  border-bottom-width: 0;
@@ -177,11 +164,11 @@
177
  box-sizing: border-box;
178
  }
179
 
180
- #lp-course-curriculum .curriculum-section.ui-sortable-helper {
181
  border-bottom: 1px solid #DDD;
182
  }
183
 
184
- #lp-course-curriculum .curriculum-section-head .lp-section-name {
185
  border: none;
186
  outline: none;
187
  box-shadow: none;
@@ -193,87 +180,87 @@
193
  height: 50px;
194
  }
195
 
196
- #lp-course-curriculum .curriculum-section-head .lp-section-name:focus {
197
  color: #444;
198
  }
199
 
200
- #lp-course-curriculum .curriculum-section.lp-empty-section .curriculum-section-content {
201
  _display: none;
202
  }
203
 
204
- #lp-course-curriculum .curriculum-section-items {
205
  border-collapse: collapse;
206
  width: 100%;
207
  }
208
 
209
- #lp-course-curriculum .curriculum-section-items .lp-section-item {
210
  border: 1px dashed #DDD;
211
  margin: -1px 0 0 0;
212
  padding: 5px 0;
213
  background-color: #FFF;
214
  }
215
 
216
- #lp-course-curriculum .curriculum-section-items .lp-section-item:nth-child(2n+1),
217
- #lp-course-curriculum .curriculum-section-items .lp-section-item:nth-child(2n+1) .section-item-input input {
218
  background-color: #FCFCFC;
219
  }
220
 
221
- #lp-course-curriculum .curriculum-section-items .lp-section-item .lp-item-actions {
222
  margin: 0;
223
  float: right;
224
  position: relative;
225
  }
226
 
227
- #lp-course-curriculum .curriculum-section-items .lp-section-item .lp-item-actions a {
228
  vertical-align: middle;
229
  color: #666;
230
  margin-top: -2px;
231
  box-shadow: none;
232
  }
233
 
234
- #lp-course-curriculum .curriculum-section-items .lp-section-item .lp-item-actions a:hover {
235
  color: #00a0d2;
236
  }
237
 
238
- #lp-course-curriculum .curriculum-section-items .lp-section-item[data-item_id=""] .lp-edit {
239
  display: none;
240
  }
241
 
242
- #lp-course-curriculum .curriculum-section-items .lp-section-item.lp-item-empty .lp-item-actions {
243
  display: none;
244
  }
245
 
246
- #lp-course-curriculum .lp-section-item.ui-sortable-helper td {
247
 
248
  }
249
 
250
- #lp-course-curriculum .lp-section-item.ui-sortable-placeholder {
251
  visibility: visible !important;
252
  }
253
 
254
- #lp-course-curriculum .lp-section-item.ui-sortable-placeholder td {
255
  background-image: url("../../../assets/images/stripe.png");
256
  border-bottom: none;
257
  }
258
 
259
- #lp-course-curriculum .lp-item-actions > * {
260
  visibility: hidden;
261
  }
262
 
263
- #lp-course-curriculum .lp-item-actions > a {
264
  }
265
 
266
- #lp-course-curriculum .item-bulk-actions {
267
  text-align: right;
268
  margin-top: 0;
269
  margin-bottom: 15px;
270
  }
271
 
272
- #lp-course-curriculum .lp-section-item:not(.lp-item-empty):hover .lp-item-actions > * {
273
  visibility: visible;
274
  }
275
 
276
- #lp-course-curriculum .curriculum-section-items .lp-section-item:not(.lp-item-empty) .item-checkbox {
277
  display: inline-block;
278
  height: 34px;
279
  border: none;
@@ -284,32 +271,32 @@
284
  visibility: visible;
285
  }
286
 
287
- #lp-course-curriculum .curriculum-section-items .lp-section-item .item-checkbox input {
288
  opacity: 0.4;
289
  }
290
 
291
- #lp-course-curriculum .curriculum-section-items .lp-section-item:not(.lp-item-empty):hover .item-checkbox input {
292
  opacity: 1;
293
  }
294
 
295
- #lp-course-curriculum .lp-item-lp_lesson .handle.learn-press-icon:before {
296
  content: "\e900";
297
  }
298
 
299
- #lp-course-curriculum .lp-item-lp_quiz .handle.learn-press-icon:before {
300
  content: "\e901";
301
  }
302
 
303
- #lp-course-curriculum .lp-section-item.lp-item-new .handle {
304
  color: #999;
305
  }
306
 
307
- #lp-course-curriculum .curriculum-section-items .lp-section-item:hover,
308
- #lp-course-curriculum .curriculum-section-items .lp-section-item:hover input.lp-item-name {
309
  background-color: #F9F9F9;
310
  }
311
 
312
- #lp-course-curriculum .lp-section-item .handle {
313
  width: 32px;
314
  height: 32px;
315
  display: inline-block;
@@ -320,15 +307,15 @@
320
  color: #00A0D2;
321
  }
322
 
323
- #lp-course-curriculum .lp-section-item.remove input.lp-item-name {
324
  color: #FF0000;
325
  }
326
 
327
- #lp-course-curriculum .lp-section-item.ui-sortable-helper {
328
 
329
  }
330
 
331
- #lp-course-curriculum .lp-section-item input.lp-item-name {
332
  color: #777;
333
  border: none;
334
  box-shadow: none;
@@ -341,7 +328,7 @@
341
  white-space: nowrap;
342
  }
343
 
344
- #lp-course-curriculum .lp-section-describe {
345
  border: none;
346
  box-shadow: none;
347
  color: #999;
@@ -351,12 +338,12 @@
351
  padding-left: 0;
352
  }
353
 
354
- #lp-course-curriculum .curriculum-section-items .lp-section-item input.lp-item-name:focus,
355
- #lp-course-curriculum input:focus {
356
  color: #444;
357
  }
358
 
359
- #lp-course-curriculum .lp-section-item .section-item-icon {
360
  width: 32px;
361
  white-space: nowrap;
362
  }
@@ -374,19 +361,19 @@
374
  border: 1px solid transparent;
375
  }
376
 
377
- #lp-course-curriculum .lp-section-item .learn-press-icon.item-lp_quiz:before {
378
  content: "\f469";
379
  }
380
 
381
- #lp-course-curriculum .lp-section-item .learn-press-icon.item-lp_lesson:before {
382
  content: "\f330";
383
  }
384
 
385
- #lp-course-curriculum .lp-section-item .learn-press-icon.item-selected,
386
- #lp-course-curriculum .lp-section-item[data-item_id=""] .learn-press-icon:hover {
387
  }
388
 
389
- #lp-course-curriculum .lp-section-item td {
390
  height: 30px;
391
  }
392
 
@@ -543,23 +530,26 @@
543
 
544
  .learn-press-dropdown-item-types {
545
  position: relative;
546
- > ul {
547
- display: none;
548
- position: absolute;
549
- top: 0px;
550
- z-index: 10;
551
- background: #FFF;
552
- border: 1px solid #DDD;
553
- left: 100%;
554
- margin-left: -1px;
555
- > li {
556
- margin: 0;
557
- display: table-cell;
558
- span {
559
- border-width: 0 !important;
560
- }
561
- }
562
- }
 
 
 
563
  }
564
 
565
  tr[data-item_id=""] .learn-press-dropdown-item-types:hover > ul,
@@ -593,14 +583,7 @@ tr.focus .learn-press-dropdown-item-types > span.learn-press-icon {
593
  color: #0085ba;
594
  }
595
 
596
- .learn-press-course-attributes {
597
- margin: 20px 0;
598
- .course-attribute-taxonomy {
599
- li {
600
 
601
- }
602
- }
603
- }
604
 
605
  .post-type-lp_course {
606
  #switch-course-tabs,
@@ -608,6 +591,91 @@ tr.focus .learn-press-dropdown-item-types > span.learn-press-icon {
608
  float: right;
609
  margin-left: 10px;
610
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
611
  }
612
 
613
  /*
3
  .rwmb-duration-wrapper select {
4
  vertical-align: baseline;
5
  }
6
+
 
 
 
7
  .post-type-lp_course {
8
  #postdivric,
9
  #submitpost {
30
  }
31
  }
32
 
33
+ #learn-press-button-toggle-editor {
34
+ margin: 20px 0 0;
35
+ }
36
+
37
+ #course_curriculum {
38
  border: none;
39
  background-color: transparent;
 
40
  }
41
 
42
+ #course_curriculum .handlediv,
43
+ #course_curriculum .hndle {
44
+ display: none;
45
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
 
47
+ #course_curriculum .inside {
48
+ margin: 0;
49
+ padding: 0;
50
  }
51
 
52
+ #course_curriculum .curriculum-heading {
53
  margin: 0 0 20px 0;
54
  padding: 10px 20px;
55
  background-color: #FFF;
57
  border: 1px solid #DDD;
58
  }
59
 
60
+ #course_curriculum .curriculum-heading .description {
61
  font-weight: normal;
62
  color: #999;
63
  display: block;
65
  margin-top: 10px;;
66
  }
67
 
68
+ #course_curriculum .curriculum-heading .items-toggle {
69
  float: right;
70
  margin: -33px 7px 0 0;
71
  line-height: 1;
72
  box-shadow: none;
73
  }
74
 
75
+ #course_curriculum .curriculum-heading .items-toggle a {
76
  -webkit-box-shadow: none;
77
  -moz-box-shadow: none;
78
  box-shadow: none;
80
 
81
  }
82
 
83
+ #course_curriculum .curriculum-sections {
84
  margin: 0;
85
  background-color: #FFF;
86
  border-bottom: 1px solid #DDD;
87
  }
88
 
89
+ #course_curriculum .curriculum-section {
90
  margin: -1px 0 0 0;
91
  background-color: #FFF;
92
  border-bottom: 1px solid #DDD;
93
  position: relative;
94
  }
95
 
96
+ #course_curriculum .curriculum-section.ui-sortable-placeholder {
97
  background-image: url("../../images/stripe.png");
98
  visibility: visible !important;
99
  border: 1px solid #DDD;
100
  border-bottom: none;
101
  }
102
 
103
+ #course_curriculum .curriculum-section-head {
104
  border: 1px solid #DDD;
105
  background-color: #F9F9F9;
106
  border-bottom: none;
109
  padding: 3px 20px;
110
  }
111
 
112
+ #course_curriculum .curriculum-section-head input {
113
  background-color: #F9F9F9;
114
  }
115
 
116
+ #course_curriculum .curriculum-section-head .lp-section-actions {
117
  float: right;
118
  margin: 14px 0;
119
  visibility: hidden;
120
  position: relative;
121
  }
122
 
123
+ #course_curriculum .curriculum-section:not(.lp-empty-section) .curriculum-section-head:hover .lp-section-actions {
124
  visibility: visible;
125
  }
126
 
127
+ #course_curriculum .curriculum-section .lp-section-actions a {
128
  vertical-align: middle;
129
  color: #666666;
130
  width: 24px;
132
  box-shadow: none;
133
  }
134
 
135
+ #course_curriculum .curriculum-section .lp-section-actions a[data-action="expand"] {
136
  line-height: 28px;
137
  }
138
 
139
+ #course_curriculum .curriculum-section .lp-section-actions a:before {
140
  width: 24px;
141
  height: 24px;
142
  font-size: 24px;
143
  }
144
 
145
+ #course_curriculum .curriculum-section .lp-section-actions a:hover {
146
  color: #00a0d2;
147
  }
148
 
149
+ #course_curriculum .curriculum-section .curriculum-section-head .lp-section-actions .move {
150
  cursor: url("../../../assets/images/openhand.cur") 7 5, default;
151
  position: absolute;
152
  right: -15px;
156
  width: 20px;
157
  }
158
 
159
+ #course_curriculum .curriculum-section-content {
160
  border: 1px solid #DDD;
161
  padding: 20px;
162
  border-bottom-width: 0;
164
  box-sizing: border-box;
165
  }
166
 
167
+ #course_curriculum .curriculum-section.ui-sortable-helper {
168
  border-bottom: 1px solid #DDD;
169
  }
170
 
171
+ #course_curriculum .curriculum-section-head .lp-section-name {
172
  border: none;
173
  outline: none;
174
  box-shadow: none;
180
  height: 50px;
181
  }
182
 
183
+ #course_curriculum .curriculum-section-head .lp-section-name:focus {
184
  color: #444;
185
  }
186
 
187
+ #course_curriculum .curriculum-section.lp-empty-section .curriculum-section-content {
188
  _display: none;
189
  }
190
 
191
+ #course_curriculum .curriculum-section-items {
192
  border-collapse: collapse;
193
  width: 100%;
194
  }
195
 
196
+ #course_curriculum .curriculum-section-items .lp-section-item {
197
  border: 1px dashed #DDD;
198
  margin: -1px 0 0 0;
199
  padding: 5px 0;
200
  background-color: #FFF;
201
  }
202
 
203
+ #course_curriculum .curriculum-section-items .lp-section-item:nth-child(2n+1),
204
+ #course_curriculum .curriculum-section-items .lp-section-item:nth-child(2n+1) .section-item-input input {
205
  background-color: #FCFCFC;
206
  }
207
 
208
+ #course_curriculum .curriculum-section-items .lp-section-item .lp-item-actions {
209
  margin: 0;
210
  float: right;
211
  position: relative;
212
  }
213
 
214
+ #course_curriculum .curriculum-section-items .lp-section-item .lp-item-actions a {
215
  vertical-align: middle;
216
  color: #666;
217
  margin-top: -2px;
218
  box-shadow: none;
219
  }
220
 
221
+ #course_curriculum .curriculum-section-items .lp-section-item .lp-item-actions a:hover {
222
  color: #00a0d2;
223
  }
224
 
225
+ #course_curriculum .curriculum-section-items .lp-section-item[data-item_id=""] .lp-edit {
226
  display: none;
227
  }
228
 
229
+ #course_curriculum .curriculum-section-items .lp-section-item.lp-item-empty .lp-item-actions {
230
  display: none;
231
  }
232
 
233
+ #course_curriculum .lp-section-item.ui-sortable-helper td {
234
 
235
  }
236
 
237
+ #course_curriculum .lp-section-item.ui-sortable-placeholder {
238
  visibility: visible !important;
239
  }
240
 
241
+ #course_curriculum .lp-section-item.ui-sortable-placeholder td {
242
  background-image: url("../../../assets/images/stripe.png");
243
  border-bottom: none;
244
  }
245
 
246
+ #course_curriculum .lp-item-actions > * {
247
  visibility: hidden;
248
  }
249
 
250
+ #course_curriculum .lp-item-actions > a {
251
  }
252
 
253
+ #course_curriculum .item-bulk-actions {
254
  text-align: right;
255
  margin-top: 0;
256
  margin-bottom: 15px;
257
  }
258
 
259
+ #course_curriculum .lp-section-item:not(.lp-item-empty):hover .lp-item-actions > * {
260
  visibility: visible;
261
  }
262
 
263
+ #course_curriculum .curriculum-section-items .lp-section-item:not(.lp-item-empty) .item-checkbox {
264
  display: inline-block;
265
  height: 34px;
266
  border: none;
271
  visibility: visible;
272
  }
273
 
274
+ #course_curriculum .curriculum-section-items .lp-section-item .item-checkbox input {
275
  opacity: 0.4;
276
  }
277
 
278
+ #course_curriculum .curriculum-section-items .lp-section-item:not(.lp-item-empty):hover .item-checkbox input {
279
  opacity: 1;
280
  }
281
 
282
+ #course_curriculum .lp-item-lp_lesson .handle.learn-press-icon:before {
283
  content: "\e900";
284
  }
285
 
286
+ #course_curriculum .lp-item-lp_quiz .handle.learn-press-icon:before {
287
  content: "\e901";
288
  }
289
 
290
+ #course_curriculum .lp-section-item.lp-item-new .handle {
291
  color: #999;
292
  }
293
 
294
+ #course_curriculum .curriculum-section-items .lp-section-item:hover,
295
+ #course_curriculum .curriculum-section-items .lp-section-item:hover input.lp-item-name {
296
  background-color: #F9F9F9;
297
  }
298
 
299
+ #course_curriculum .lp-section-item .handle {
300
  width: 32px;
301
  height: 32px;
302
  display: inline-block;
307
  color: #00A0D2;
308
  }
309
 
310
+ #course_curriculum .lp-section-item.remove input.lp-item-name {
311
  color: #FF0000;
312
  }
313
 
314
+ #course_curriculum .lp-section-item.ui-sortable-helper {
315
 
316
  }
317
 
318
+ #course_curriculum .lp-section-item input.lp-item-name {
319
  color: #777;
320
  border: none;
321
  box-shadow: none;
328
  white-space: nowrap;
329
  }
330
 
331
+ #course_curriculum .lp-section-describe {
332
  border: none;
333
  box-shadow: none;
334
  color: #999;
338
  padding-left: 0;
339
  }
340
 
341
+ #course_curriculum .curriculum-section-items .lp-section-item input.lp-item-name:focus,
342
+ #course_curriculum input:focus {
343
  color: #444;
344
  }
345
 
346
+ #course_curriculum .lp-section-item .section-item-icon {
347
  width: 32px;
348
  white-space: nowrap;
349
  }
361
  border: 1px solid transparent;
362
  }
363
 
364
+ #course_curriculum .lp-section-item .learn-press-icon.item-lp_quiz:before {
365
  content: "\f469";
366
  }
367
 
368
+ #course_curriculum .lp-section-item .learn-press-icon.item-lp_lesson:before {
369
  content: "\f330";
370
  }
371
 
372
+ #course_curriculum .lp-section-item .learn-press-icon.item-selected,
373
+ #course_curriculum .lp-section-item[data-item_id=""] .learn-press-icon:hover {
374
  }
375
 
376
+ #course_curriculum .lp-section-item td {
377
  height: 30px;
378
  }
379
 
530
 
531
  .learn-press-dropdown-item-types {
532
  position: relative;
533
+ }
534
+
535
+ .learn-press-dropdown-item-types > ul {
536
+ display: none;
537
+ position: absolute;
538
+ top: 0px;
539
+ z-index: 10;
540
+ background: #FFF;
541
+ border: 1px solid #DDD;
542
+ left: 100%;
543
+ margin-left: -1px;
544
+ }
545
+
546
+ .learn-press-dropdown-item-types > ul > li {
547
+ margin: 0;
548
+ display: table-cell;
549
+ }
550
+
551
+ .learn-press-dropdown-item-types > ul > li span {
552
+ border-width: 0 !important;
553
  }
554
 
555
  tr[data-item_id=""] .learn-press-dropdown-item-types:hover > ul,
583
  color: #0085ba;
584
  }
585
 
 
 
 
 
586
 
 
 
 
587
 
588
  .post-type-lp_course {
589
  #switch-course-tabs,
591
  float: right;
592
  margin-left: 10px;
593
  }
594
+ &.enable-course-tabs {
595
+ #post-body-content {
596
+ margin-bottom: 0;
597
+ }
598
+ #normal-sortables {
599
+ .postbox {
600
+ _visibility: hidden;
601
+ float: left;
602
+ margin-right: -100%;
603
+ width: 100%;
604
+ box-sizing: border-box;
605
+ height: 0;
606
+ overflow: hidden;
607
+ border-width: 0;
608
+ &.active {
609
+ height: auto;
610
+ border-width: 1px;
611
+ }
612
+ .handlediv, .hndle {
613
+ display: none;
614
+ }
615
+ }
616
+ }
617
+ #course-tabs {
618
+ background: #FFF;
619
+ padding: 10px;
620
+ margin-bottom: 0;
621
+ border: 1px solid #DDD;
622
+ border-bottom: none;
623
+ &:after {
624
+ display: block;
625
+ clear: both;
626
+ content: '';
627
+ }
628
+ &.ui-sortable:not(.ui-sortable-disabled) {
629
+ li.ui-sortable-handle {
630
+ position: relative;
631
+ a {
632
+ border: 1px solid #ddd;
633
+ padding: 0px 5px;
634
+ margin: 0 5px;
635
+ color: #DDD;
636
+ background: #FFF;
637
+ }
638
+ &:after {
639
+ content: '';
640
+ position: absolute;
641
+ top: 0;
642
+ left: 0;
643
+ width: 100%;
644
+ height: 100%;
645
+ cursor: move;
646
+ }
647
+ }
648
+ }
649
+ li {
650
+ float: left;
651
+ margin-bottom: 0;
652
+ a {
653
+ display: block;
654
+ padding: 0 15px 0 0;
655
+ text-decoration: none;
656
+ outline: none;
657
+ box-shadow: none;
658
+ }
659
+ &.active {
660
+ a {
661
+ font-weight: bold;
662
+ }
663
+ }
664
+ }
665
+ li#switch-course-metaboxes {
666
+ float: right;
667
+ #complete-reorder-course-tabs {
668
+ display: none;
669
+ }
670
+ a {
671
+ padding-right: 0;
672
+ color: #FF0000;
673
+ display: inline-block;
674
+ margin-left: 15px;
675
+ }
676
+ }
677
+ }
678
+ }
679
  }
680
 
681
  /*
assets/css/admin/meta-box-order.css CHANGED
@@ -1,136 +1,133 @@
 
1
  /* admin order details */
2
  .column-order_date,
3
  .column-order_total,
4
  .column-order_status,
5
- .post-type-lp_order .column-title {
6
  width: 10%;
7
  }
8
- .post-type-lp_order .column-order_student {
9
  width: 12%;
10
  }
 
 
11
  #order_details .ui-sortable-handle,
12
  #order_details .handlediv {
13
  display: none !important;
14
  }
 
15
  #order_details .inside {
16
  padding: 20px;
17
  margin: 0;
18
  }
 
19
  #order_details .order-user-avatar {
20
  float: left;
21
  margin-right: 20px;
22
  }
 
23
  #order_details .order-user-meta {
24
  float: left;
25
  }
 
26
  #order_details .order-items table {
27
  width: 100%;
28
  border-collapse: collapse;
29
  margin-top: 20px;
30
  }
 
31
  #order_details .order-items table tr {
32
  border-bottom: 1px solid #EEE;
33
  }
 
34
  #order_details .order-items table thead th {
35
  height: 30px;
36
  text-align: left;
37
  font-size: 16px;
38
  padding: 15px 10px;
39
  }
 
40
  #order_details .order-items table td {
41
  padding: 15px 10px;
42
  font-size: 16px;
43
  }
 
44
  #order_details .order-items table .align-right {
45
  text-align: right;
46
  }
 
47
  #order_details .order-data {
48
  float: right;
49
  }
 
50
  #order_details .order-data {
51
  text-align: right;
52
  }
 
53
  #order_details .order-data .order-data-number {
54
  font-size: 24px;
55
  font-weight: bold;
56
  margin-bottom: 10px;
57
  }
 
58
  #order_details .order-data .order-data-date {
59
  font-size: 14px;
60
  font-style: italic;
61
  margin-bottom: 5px;
62
  }
 
63
  #order_details .order-data .order-data-payment-method {
64
  font-size: 16px;
65
  font-weight: bold;
66
  margin: 5px 0;
67
  }
 
68
  #order_details .order-data .order-data-status {
69
  border-radius: 3px;
70
  padding: 2px 5px;
71
  display: inline-block;
72
  color: #FFF;
73
  font-size: 12px;
 
74
  }
 
75
  #order_details .order-data .order-data-status.completed {
76
  background-color: #006400;
77
  }
 
78
  #order_details .order-data .order-data-status.pending {
79
  background-color: #CCCCCC;
80
  }
 
81
  #order_details .total {
82
  font-weight: bold;
83
  font-size: 16px;
84
  }
85
- #order_details .avatar-multiple-users{
 
86
  width: 120px;
87
- height: 120px;
88
- background: #F5F5F5;
89
- position: relative;
90
  }
91
- #order_details .avatar-multiple-users:before,
92
- #order_details .avatar-multiple-users:after{
93
- content: "\f110";
94
- width: 120px;
95
- height:120px;
96
- position: absolute;
97
- top:0;
98
- left: 0;
99
- font-family: dashicons;
100
- font-size: 58px;
101
- color: #a1adbb;
102
- text-align: center;
103
- line-height: 120px;
104
- }
105
- #order_details .avatar-multiple-users:before{
106
- font-size: 48px;
107
- left: -27px;
108
- color: #DEDEDE;
109
- }
110
- #order_details .avatar-multiple-users span:after{
111
- font-family: dashicons;
112
- content: "\f132";
113
- font-size: 32px;
114
- top: 0;
115
- position: absolute;
116
- width: 120px;
117
- height: 120px;
118
- text-align: center;
119
- line-height: 120px;
120
- left: 31px;
121
- color: #a1adbb;
122
- }
123
- #order_details .order-users > strong{
124
- font-weight: bold;
125
  }
126
- #order_details .order-users p{
127
- font-style: italic;
128
- margin: 5px 0 15px 0;
129
  }
130
- #order_details .payment-method-title{
131
- font-weight: bold;
 
 
132
  }
133
 
 
 
 
 
 
 
 
134
 
135
  .order-status-description {
136
  font-size: smaller;
@@ -142,10 +139,11 @@
142
  margin-top: 10px;
143
  border-radius: 3px;
144
  }
 
145
  .order-status-description:before {
146
  content: '';
147
  border: 5px solid transparent;
148
  border-bottom-color: #CEE8FF;
149
  position: absolute;
150
  top: -10px;
151
- }
1
+
2
  /* admin order details */
3
  .column-order_date,
4
  .column-order_total,
5
  .column-order_status,
6
+ .post-type-lp_order .column-title{
7
  width: 10%;
8
  }
9
+ .post-type-lp_order .column-order_student{
10
  width: 12%;
11
  }
12
+ .post-type-lpr_order #post-body-content,
13
+ .post-type-lpr_order #postbox-container-1,
14
  #order_details .ui-sortable-handle,
15
  #order_details .handlediv {
16
  display: none !important;
17
  }
18
+
19
  #order_details .inside {
20
  padding: 20px;
21
  margin: 0;
22
  }
23
+
24
  #order_details .order-user-avatar {
25
  float: left;
26
  margin-right: 20px;
27
  }
28
+
29
  #order_details .order-user-meta {
30
  float: left;
31
  }
32
+
33
  #order_details .order-items table {
34
  width: 100%;
35
  border-collapse: collapse;
36
  margin-top: 20px;
37
  }
38
+
39
  #order_details .order-items table tr {
40
  border-bottom: 1px solid #EEE;
41
  }
42
+
43
  #order_details .order-items table thead th {
44
  height: 30px;
45
  text-align: left;
46
  font-size: 16px;
47
  padding: 15px 10px;
48
  }
49
+
50
  #order_details .order-items table td {
51
  padding: 15px 10px;
52
  font-size: 16px;
53
  }
54
+
55
  #order_details .order-items table .align-right {
56
  text-align: right;
57
  }
58
+
59
  #order_details .order-data {
60
  float: right;
61
  }
62
+
63
  #order_details .order-data {
64
  text-align: right;
65
  }
66
+
67
  #order_details .order-data .order-data-number {
68
  font-size: 24px;
69
  font-weight: bold;
70
  margin-bottom: 10px;
71
  }
72
+
73
  #order_details .order-data .order-data-date {
74
  font-size: 14px;
75
  font-style: italic;
76
  margin-bottom: 5px;
77
  }
78
+
79
  #order_details .order-data .order-data-payment-method {
80
  font-size: 16px;
81
  font-weight: bold;
82
  margin: 5px 0;
83
  }
84
+
85
  #order_details .order-data .order-data-status {
86
  border-radius: 3px;
87
  padding: 2px 5px;
88
  display: inline-block;
89
  color: #FFF;
90
  font-size: 12px;
91
+
92
  }
93
+
94
  #order_details .order-data .order-data-status.completed {
95
  background-color: #006400;
96
  }
97
+
98
  #order_details .order-data .order-data-status.pending {
99
  background-color: #CCCCCC;
100
  }
101
+
102
  #order_details .total {
103
  font-weight: bold;
104
  font-size: 16px;
105
  }
106
+ /*************************************************************/
107
+ .post-type-lpr_order .column-title {
108
  width: 120px;
 
 
 
109
  }
110
+
111
+ .post-type-lpr_order .column-order_student {
112
+ width: 100px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  }
114
+
115
+ .post-type-lpr_order .column-order_date {
116
+ width: 150px;
117
  }
118
+
119
+ .post-type-lpr_order .column-order_total {
120
+ width: 100px;
121
+ text-align: right;
122
  }
123
 
124
+ .post-type-lpr_order .column-order_status {
125
+ width: 100px;
126
+ }
127
+ .post-type-lp_order #minor-publishing-actions,
128
+ .post-type-lp_order #submitdiv .handlediv{
129
+ display: none;
130
+ }
131
 
132
  .order-status-description {
133
  font-size: smaller;
139
  margin-top: 10px;
140
  border-radius: 3px;
141
  }
142
+
143
  .order-status-description:before {
144
  content: '';
145
  border: 5px solid transparent;
146
  border-bottom-color: #CEE8FF;
147
  position: absolute;
148
  top: -10px;
149
+ }
assets/css/admin/meta-box-question.css ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #question_settings select.lpr-question-types{
2
+ margin-left: 20px;
3
+ font-weight: normal;
4
+ display: none;
5
+ font-size: 12px;
6
+ padding: 0;
7
+ height: auto;
8
+ }
9
+ .lpr-question-option{
10
+ border: 1px solid #DDD;
11
+ border-collapse: collapse;
12
+ width: 100%;
13
+ border-bottom: none ;
14
+ position: relative;
15
+ }
16
+ .lpr-question-option{}
17
+ .lpr-question-option th,
18
+ .lpr-question-option td{
19
+ padding: 5px;
20
+ border: 1px solid #DDD;
21
+ }
22
+ .lpr-question-option thead{
23
+ background-color: #F5F5F5;
24
+ }
25
+ .lpr-question-option thead th{
26
+ text-align: left;
27
+ padding: 8px 5px;
28
+ border: 1px solid #DDD;
29
+ }
30
+ .lpr-question-option tbody{
31
+ position: relative;
32
+ }
33
+ .lpr-question-option tbody tr{
34
+ width: 100%;
35
+ background-color: #FFF;
36
+ }
37
+ .lpr-question-option tbody th{
38
+ text-align: left;
39
+ padding: 5px;
40
+ border: 1px solid #DDD;
41
+ width: 25%;
42
+ }
43
+ .lpr-question-option tbody tr.placeholder td{
44
+ border: 1px solid #DDD;
45
+ background-color: #DDD;
46
+ }
47
+ .lpr-question-option tbody tr.ui-sortable-helper{
48
+ left: 0;
49
+ }
50
+ .lpr-question-option input[type="text"] {
51
+ width: 100%;
52
+ }
assets/css/learnpress.css CHANGED
@@ -277,55 +277,6 @@
277
  #learn-press-course-curriculum .course-item .lp-icon {
278
  display: none;
279
  }
280
- #learn-press-course-curriculum .course-item .item-status {
281
- display: none;
282
- font-family: dashicons;
283
- -webkit-border-radius: 4px;
284
- -khtml-border-radius: 4px;
285
- -moz-border-radius: 4px;
286
- -ms-border-radius: 4px;
287
- -o-border-radius: 4px;
288
- border-radius: 4px;
289
- background: #DDD;
290
- color: #22b4ff;
291
- font-size: 18px;
292
- }
293
- #learn-press-course-curriculum .course-item .item-status:before {
294
- content: "\f177";
295
- }
296
- #learn-press-course-curriculum .course-item .item-status.item-status-started:before {
297
- content: "\f469";
298
- }
299
- #learn-press-course-curriculum .course-item .item-status.item-status-completed {
300
- background: #22b4ff;
301
- color: #FFF;
302
- }
303
- #learn-press-course-curriculum .course-item .item-status.item-status-completed:before {
304
- content: "\f147";
305
- }
306
- #learn-press-course-curriculum .course-item .item-status.item-status-passed {
307
- background: #22b4ff;
308
- color: #FFF;
309
- }
310
- #learn-press-course-curriculum .course-item .item-status.item-status-passed:before {
311
- content: "\f147";
312
- }
313
- #learn-press-course-curriculum .course-item .item-status.item-status-failed {
314
- background: #cc540d;
315
- color: #FFF;
316
- }
317
- #learn-press-course-curriculum .course-item .item-status.item-status-failed:before {
318
- content: "\f335";
319
- }
320
- #learn-press-course-curriculum .course-item .item-result {
321
- display: none;
322
- }
323
- #learn-press-course-curriculum .course-item.item-has-status .item-status {
324
- display: inline-block;
325
- }
326
- #learn-press-course-curriculum .course-item.item-has-result .item-result {
327
- display: inline-block;
328
- }
329
  #learn-press-course-curriculum .course-item.viewable {
330
  cursor: pointer;
331
  }
@@ -357,6 +308,18 @@
357
  height: 100%;
358
  content: '';
359
  }
 
 
 
 
 
 
 
 
 
 
 
 
360
  #learn-press-course-curriculum .course-item.focus {
361
  background: #ffb710;
362
  }
@@ -376,25 +339,12 @@
376
  #learn-press-course-curriculum .course-item-meta {
377
  display: block;
378
  line-height: 1;
 
379
  top: 15px;
380
  right: 15px;
381
  float: right;
382
  margin-top: 5px;
383
  }
384
- #learn-press-course-curriculum .course-item-meta .item-loop-meta-text {
385
- font-size: small;
386
- }
387
- #learn-press-course-curriculum .course-item-meta .item-loop-meta-text.item-final {
388
- color: #ffffff;
389
- background: #cc540d;
390
- padding: 3px 8px;
391
- -webkit-border-radius: 3px;
392
- -khtml-border-radius: 3px;
393
- -moz-border-radius: 3px;
394
- -ms-border-radius: 3px;
395
- -o-border-radius: 3px;
396
- border-radius: 3px;
397
- }
398
  .lp-icon {
399
  display: inline-block;
400
  font-family: 'lp-icons';
@@ -516,26 +466,6 @@
516
  .single-lp_course .learn-press-course-results-progress .percentage-sign {
517
  margin-left: 5px;
518
  }
519
- .single-lp_course .learn-press-course-results-progress .grade {
520
- font-size: 12px;
521
- font-weight: bold;
522
- background: #F5F5F5;
523
- padding: 2px 7px;
524
- -webkit-border-radius: 3px;
525
- -khtml-border-radius: 3px;
526
- -moz-border-radius: 3px;
527
- -ms-border-radius: 3px;
528
- -o-border-radius: 3px;
529
- border-radius: 3px;
530
- }
531
- .single-lp_course .learn-press-course-results-progress .grade.passed {
532
- color: #ffffff;
533
- background: #95e6f9;
534
- }
535
- .single-lp_course .learn-press-course-results-progress .grade.failed {
536
- color: #ffffff;
537
- background: #ff5425;
538
- }
539
  .single-lp_course .learn-press-course-results-progress:after {
540
  display: block;
541
  content: '';
@@ -901,7 +831,7 @@ body.course-has-popup {
901
  height: 43px;
902
  line-height: 43px;
903
  background: #F5F5F5;
904
- margin-left: 10px;
905
  border: 1px solid #DDD;
906
  outline: none;
907
  }
@@ -1024,9 +954,6 @@ body.block-content #learn-press-block-content {
1024
  padding: 0;
1025
  margin-left: 0;
1026
  }
1027
- .quiz-intro li label {
1028
- display: inline-block;
1029
- }
1030
  .quiz-questions-list {
1031
  margin: 0 0 20px 0;
1032
  padding: 0;
@@ -1037,95 +964,10 @@ body.block-content #learn-press-block-content {
1037
  }
1038
  .quiz-questions-list .question-title {
1039
  margin: 0 0 5px 0;
1040
- display: inline-block;
1041
- font-size: 14px;
1042
  }
1043
  .quiz-questions-list .current .question-title {
1044
  font-weight: bold;
1045
  }
1046
- .quiz-questions-list input[type="checkbox"],
1047
- .quiz-questions-list input[type="radio"] {
1048
- border: 1px solid #DDD;
1049
- display: inline-block;
1050
- -webkit-appearance: none;
1051
- width: 18px;
1052
- height: 18px;
1053
- position: relative;
1054
- }
1055
- .quiz-questions-list input[type="checkbox"]:checked:after,
1056
- .quiz-questions-list input[type="radio"]:checked:after {
1057
- content: '';
1058
- display: inline-block;
1059
- position: absolute;
1060
- }
1061
- .quiz-questions-list input[type="checkbox"]:checked:after {
1062
- border-bottom: 3px solid #00b9eb;
1063
- border-right: 1px solid #00b9eb;
1064
- -webkit-transform: rotate(14deg);
1065
- -moz-transform: rotate(14deg);
1066
- -ms-transform: rotate(14deg);
1067
- -o-transform: rotate(14deg);
1068
- transform: rotate(33deg);
1069
- width: 8px;
1070
- height: 16px;
1071
- top: -5px;
1072
- left: 5px;
1073
- }
1074
- .quiz-questions-list input[type="checkbox"]:disabled:after {
1075
- border-color: #DDD;
1076
- }
1077
- .quiz-questions-list input[type="radio"] {
1078
- -webkit-border-radius: 50%;
1079
- -moz-border-radius: 50%;
1080
- border-radius: 50%;
1081
- }
1082
- .quiz-questions-list input[type="radio"]:checked:after {
1083
- background: #00b9eb;
1084
- width: 8px;
1085
- height: 8px;
1086
- border-radius: 50%;
1087
- top: 50%;
1088
- left: 50%;
1089
- margin-left: -4px;
1090
- margin-top: -4px;
1091
- }
1092
- .quiz-questions-list input[type="radio"]:disabled:after {
1093
- background: #DDD;
1094
- }
1095
- .question-results .question-title:after {
1096
- font-family: dashicons;
1097
- font-size: 24px;
1098
- vertical-align: middle;
1099
- display: inline-block;
1100
- text-align: center;
1101
- margin-left: 5px;
1102
- }
1103
- .question-results.correct .question-title:after {
1104
- content: '\f147';
1105
- color: #00adff;
1106
- }
1107
- .question-results.skipped .question-title:after {
1108
- content: '\f534';
1109
- color: #c6c6c6;
1110
- }
1111
- .question-results.incorrect .question-title:after {
1112
- content: '\f335';
1113
- color: #ff5425;
1114
- }
1115
- .question-results.incorrect .user-answer-false .option-title {
1116
- text-decoration: line-through;
1117
- }
1118
- .question-results .answer-true {
1119
- color: #007acc;
1120
- }
1121
- .question-results .answer-true .option-title {
1122
- background: #fff9d8;
1123
- padding: 0 5px;
1124
- margin-left: -5px;
1125
- }
1126
- .question-results input {
1127
- vertical-align: middle;
1128
- }
1129
  .quiz-description .learn-press-question-title,
1130
  .question-content .learn-press-question-title {
1131
  margin-bottom: 20px;
@@ -2517,37 +2359,48 @@ body.content-item-only #learn-press-content-item.expand {
2517
  content: '-';
2518
  }
2519
  /*
2520
- .payment-method-form {
2521
- &.payment_method_authorizenet {
2522
- background: #f7f7f7;
2523
- border-radius: 5px;
2524
- -webkit-border-radius: 5px;
2525
- -moz-border-radius: 5px;
2526
- padding-top: 25px;
2527
- .row-fluid {
2528
- clear: both;
2529
- padding-bottom: 25px;
2530
- .span6 {
2531
- &:first-child {
2532
- width: 50%;
2533
- float: left;
2534
- label {
2535
- margin-left: 17px;
2536
- }
2537
- select, input {
2538
- margin-left: 10px;
2539
- }
2540
- }
2541
- select, input {
2542
- padding: 8px 0;
2543
- }
2544
- select.required {
2545
- color: #000;
2546
- }
2547
- }
2548
- }
2549
- }
2550
  }*/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2551
  .place-order-action {
2552
  margin-top: 20px;
2553
  }
@@ -2571,128 +2424,31 @@ body.content-item-only #learn-press-content-item.expand {
2571
  z-index: 10;
2572
  position: relative;
2573
  }
2574
- .table-orders .order-status.order-status-removed {
2575
- color: #FF0000;
2576
- }
2577
  /* Shortcode/Widgets */
2578
- .widget_lp-widget-popular-courses .course-meta-data > div,
2579
- .widget_lp-widget-recent-courses .course-meta-data > div,
2580
- .widget_lp-widget-featured-courses .course-meta-data > div {
2581
  display: inline-block;
2582
  }
2583
- .widget_lp-widget-popular-courses .course-meta-data > div:after,
2584
- .widget_lp-widget-recent-courses .course-meta-data > div:after,
2585
- .widget_lp-widget-featured-courses .course-meta-data > div:after {
2586
  content: '/';
2587
  }
2588
- .widget_lp-widget-popular-courses .course-meta-data > div:last-child:after,
2589
- .widget_lp-widget-recent-courses .course-meta-data > div:last-child:after,
2590
- .widget_lp-widget-featured-courses .course-meta-data > div:last-child:after {
2591
  content: '';
2592
  }
2593
- .widget_lp-widget-popular-courses .course-title,
2594
- .widget_lp-widget-recent-courses .course-title,
2595
- .widget_lp-widget-featured-courses .course-title {
2596
  margin: 5px 0;
2597
  }
2598
- .widget_lp-widget-popular-courses .course-entry,
2599
- .widget_lp-widget-recent-courses .course-entry,
2600
- .widget_lp-widget-featured-courses .course-entry {
2601
  margin-bottom: 20px;
2602
- border-bottom: 1px dashed #DDD;
2603
- padding-bottom: 20px;
2604
- }
2605
- .edit-course-item-link a {
2606
- font-size: 14px;
2607
- position: relative;
2608
- padding-left: 25px;
2609
- }
2610
- .edit-course-item-link a:after {
2611
- content: "\f464";
2612
- font-family: Dashicons;
2613
- font-size: 26px;
2614
- position: absolute;
2615
- bottom: 0;
2616
- line-height: 1;
2617
- left: 0;
2618
- }
2619
- .course-item-navigation {
2620
- border-top: 4px solid #333;
2621
- padding-top: 10px;
2622
- margin-top: 20px;
2623
- }
2624
- .course-item-navigation .nav-links .nav-link {
2625
- opacity: 1;
2626
- }
2627
- .course-item-navigation .nav-links .nav-link a {
2628
- opacity: 1;
2629
- }
2630
- .course-item-navigation .nav-links .nav-link a .meta-nav {
2631
- display: block;
2632
- text-transform: uppercase;
2633
- font-size: small;
2634
- color: #b9b9b9;
2635
- }
2636
- .course-item-navigation .nav-links .nav-link a .post-title {
2637
- opacity: 1;
2638
- }
2639
- .course-item-navigation .nav-links .nav-link.nav-previous {
2640
- float: left;
2641
- }
2642
- .course-item-navigation .nav-links .nav-link.nav-next {
2643
- float: right;
2644
- text-align: right;
2645
- }
2646
- .course-item-navigation .nav-links:after {
2647
- clear: both;
2648
- display: block;
2649
- content: '';
2650
- }
2651
- /* widget attributes */
2652
- .lp-course-attributes {
2653
- list-style: none;
2654
- margin-left: 0;
2655
- }
2656
- .lp-course-attributes li {
2657
- list-style: none;
2658
- margin-bottom: 10px;
2659
- }
2660
- .lp-course-attributes .lp-course-attribute-values {
2661
- list-style: none;
2662
- margin-left: 0;
2663
- }
2664
- .lp-course-attributes.course-attributes .lp-course-attribute-values li {
2665
- display: inline-block;
2666
- padding: 3px 8px;
2667
- background: #F0F0F0;
2668
- border-radius: 4px;
2669
- margin: 0 5px 5px 0;
2670
- }
2671
- .lp-course-attributes.course-filters .lp-course-attribute-values li a:before {
2672
- font-family: dashicons;
2673
- border-radius: 50%;
2674
- background: #DDD;
2675
- display: inline-block;
2676
- width: 16px;
2677
- height: 16px;
2678
- text-align: center;
2679
- line-height: 16px;
2680
- color: #FFF;
2681
- font-size: 16px;
2682
- vertical-align: middle;
2683
- margin-right: 5px;
2684
- content: '';
2685
- }
2686
- .lp-course-attributes.course-filters .lp-course-attribute-values li:hover a:before {
2687
- background: #4acfff;
2688
- }
2689
- .lp-course-attributes.course-filters .lp-course-attribute-values li.active a:before {
2690
- content: "\f147";
2691
- background: #4acfff;
2692
- }
2693
- .lp-course-attributes.course-filters .lp-course-attribute-values li.active:hover a:before {
2694
- content: "\f335";
2695
- background: #a20000;
2696
  }
2697
  @-moz-keyframes spin-12 {
2698
  0% {
@@ -2814,17 +2570,11 @@ body.content-item-only #learn-press-content-item.expand {
2814
  margin-left: 0;
2815
  }
2816
  }
2817
- /*
2818
  @media (max-width: 480px) {
2819
- .woocommerce {
2820
- .checkout_coupon {
2821
- .form-row {
2822
- width: 100%;
2823
- }
2824
- }
2825
- }
2826
- }
2827
- */
2828
  @media (max-width: 400px) {
2829
  .learn-press-courses li.course {
2830
  width: 100%;
@@ -2846,35 +2596,29 @@ body.content-item-only #learn-press-content-item.expand {
2846
  display: none;
2847
  }
2848
  }
2849
- /*
2850
  @media screen and (max-width: 615px) {
2851
- .payment-method-form {
2852
- &.payment_method_authorizenet {
2853
- .row-fluid {
2854
- padding-bottom: 15px;
2855
- .span6 {
2856
- &:first-child {
2857
- width: 100%;
2858
- margin-bottom: 15px;
2859
- }
2860
- label {
2861
- margin-left: 17px;
2862
- }
2863
- select, input {
2864
- margin-left: 10px;
2865
- }
2866
- select, input {
2867
- padding: 8px 0;
2868
- }
2869
- select.required {
2870
- color: #000;
2871
- }
2872
- #learn-press-authorizenet-payment-expmonth {
2873
- margin-bottom: 10px;
2874
- }
2875
- }
2876
- }
2877
- }
2878
- }
2879
- }
2880
- */
277
  #learn-press-course-curriculum .course-item .lp-icon {
278
  display: none;
279
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
280
  #learn-press-course-curriculum .course-item.viewable {
281
  cursor: pointer;
282
  }
308
  height: 100%;
309
  content: '';
310
  }
311
+ #learn-press-course-curriculum .course-item.item-has-status .item-status {
312
+ display: inline-block;
313
+ background: #d6d6d6;
314
+ margin-left: 5px;
315
+ }
316
+ #learn-press-course-curriculum .course-item.item-has-status .item-status:before {
317
+ content: '\ea10';
318
+ color: #FFF;
319
+ }
320
+ #learn-press-course-curriculum .course-item.item-has-status.item-completed .item-status {
321
+ background: #95e6f9;
322
+ }
323
  #learn-press-course-curriculum .course-item.focus {
324
  background: #ffb710;
325
  }
339
  #learn-press-course-curriculum .course-item-meta {
340
  display: block;
341
  line-height: 1;
342
+ __position: absolute;
343
  top: 15px;
344
  right: 15px;
345
  float: right;
346
  margin-top: 5px;
347
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
348
  .lp-icon {
349
  display: inline-block;
350
  font-family: 'lp-icons';
466
  .single-lp_course .learn-press-course-results-progress .percentage-sign {
467
  margin-left: 5px;
468
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
469
  .single-lp_course .learn-press-course-results-progress:after {
470
  display: block;
471
  content: '';
831
  height: 43px;
832
  line-height: 43px;
833
  background: #F5F5F5;
834
+ margin: 0 10px;
835
  border: 1px solid #DDD;
836
  outline: none;
837
  }
954
  padding: 0;
955
  margin-left: 0;
956
  }
 
 
 
957
  .quiz-questions-list {
958
  margin: 0 0 20px 0;
959
  padding: 0;
964
  }
965
  .quiz-questions-list .question-title {
966
  margin: 0 0 5px 0;
 
 
967
  }
968
  .quiz-questions-list .current .question-title {
969
  font-weight: bold;
970
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
971
  .quiz-description .learn-press-question-title,
972
  .question-content .learn-press-question-title {
973
  margin-bottom: 20px;
2359
  content: '-';
2360
  }
2361
  /*
2362
+ .sidebar-hide-btn, .sidebar-show-btn {
2363
+ cursor: pointer;
2364
+ width: 60px;
2365
+ height: 60px;
2366
+ display: inline-block;
2367
+ font-size: 34px;
2368
+ line-height: 60px;
2369
+ text-align: center;
2370
+ color: #FFF;
2371
+ position: absolute;
2372
+
2373
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2374
  }*/
2375
+ .payment-method-form.payment_method_authorizenet {
2376
+ background: #f7f7f7;
2377
+ border-radius: 5px;
2378
+ -webkit-border-radius: 5px;
2379
+ -moz-border-radius: 5px;
2380
+ padding-top: 25px;
2381
+ }
2382
+ .payment-method-form.payment_method_authorizenet .row-fluid {
2383
+ clear: both;
2384
+ padding-bottom: 25px;
2385
+ }
2386
+ .payment-method-form.payment_method_authorizenet .row-fluid .span6:first-child {
2387
+ width: 50%;
2388
+ float: left;
2389
+ }
2390
+ .payment-method-form.payment_method_authorizenet .row-fluid .span6:first-child label {
2391
+ margin-left: 17px;
2392
+ }
2393
+ .payment-method-form.payment_method_authorizenet .row-fluid .span6:first-child select,
2394
+ .payment-method-form.payment_method_authorizenet .row-fluid .span6:first-child input {
2395
+ margin-left: 10px;
2396
+ }
2397
+ .payment-method-form.payment_method_authorizenet .row-fluid .span6 select,
2398
+ .payment-method-form.payment_method_authorizenet .row-fluid .span6 input {
2399
+ padding: 8px 0;
2400
+ }
2401
+ .payment-method-form.payment_method_authorizenet .row-fluid .span6 select.required {
2402
+ color: #000;
2403
+ }
2404
  .place-order-action {
2405
  margin-top: 20px;
2406
  }
2424
  z-index: 10;
2425
  position: relative;
2426
  }
 
 
 
2427
  /* Shortcode/Widgets */
2428
+ .recent-courses-widget .course-meta-data > div,
2429
+ .popular-courses-widget .course-meta-data > div,
2430
+ .featured-courses-widget .course-meta-data > div {
2431
  display: inline-block;
2432
  }
2433
+ .recent-courses-widget .course-meta-data > div:after,
2434
+ .popular-courses-widget .course-meta-data > div:after,
2435
+ .featured-courses-widget .course-meta-data > div:after {
2436
  content: '/';
2437
  }
2438
+ .recent-courses-widget .course-meta-data > div:last-child:after,
2439
+ .popular-courses-widget .course-meta-data > div:last-child:after,
2440
+ .featured-courses-widget .course-meta-data > div:last-child:after {
2441
  content: '';
2442
  }
2443
+ .recent-courses-widget .course-title,
2444
+ .popular-courses-widget .course-title,
2445
+ .featured-courses-widget .course-title {
2446
  margin: 5px 0;
2447
  }
2448
+ .recent-courses-widget .course-entry,
2449
+ .popular-courses-widget .course-entry,
2450
+ .featured-courses-widget .course-entry {
2451
  margin-bottom: 20px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2452
  }
2453
  @-moz-keyframes spin-12 {
2454
  0% {
2570
  margin-left: 0;
2571
  }
2572
  }
 
2573
  @media (max-width: 480px) {
2574
+ .woocommerce .checkout_coupon .form-row {
2575
+ width: 100%;
2576
+ }
2577
+ }
 
 
 
 
 
2578
  @media (max-width: 400px) {
2579
  .learn-press-courses li.course {
2580
  width: 100%;
2596
  display: none;
2597
  }
2598
  }
 
2599
  @media screen and (max-width: 615px) {
2600
+ .payment-method-form.payment_method_authorizenet .row-fluid {
2601
+ padding-bottom: 15px;
2602
+ }
2603
+ .payment-method-form.payment_method_authorizenet .row-fluid .span6:first-child {
2604
+ width: 100%;
2605
+ margin-bottom: 15px;
2606
+ }
2607
+ .payment-method-form.payment_method_authorizenet .row-fluid .span6 label {
2608
+ margin-left: 17px;
2609
+ }
2610
+ .payment-method-form.payment_method_authorizenet .row-fluid .span6 select,
2611
+ .payment-method-form.payment_method_authorizenet .row-fluid .span6 input {
2612
+ margin-left: 10px;
2613
+ }
2614
+ .payment-method-form.payment_method_authorizenet .row-fluid .span6 select,
2615
+ .payment-method-form.payment_method_authorizenet .row-fluid .span6 input {
2616
+ padding: 8px 0;
2617
+ }
2618
+ .payment-method-form.payment_method_authorizenet .row-fluid .span6 select.required {
2619
+ color: #000;
2620
+ }
2621
+ .payment-method-form.payment_method_authorizenet .row-fluid .span6 #learn-press-authorizenet-payment-expmonth {
2622
+ margin-bottom: 10px;
2623
+ }
2624
+ }
 
 
 
 
 
assets/css/learnpress.less CHANGED
@@ -319,16 +319,13 @@
319
  }
320
  }
321
  }
322
-
323
  .course-origin-price {
324
  text-decoration: line-through;
325
  padding-right: 5px;
326
  }
327
-
328
  .course-price {
329
  color: rgb(84, 181, 81);
330
  }
331
-
332
  .learn-press-notice .button {
333
  float: right;
334
  }
@@ -430,59 +427,6 @@
430
  .lp-icon {
431
  display: none;
432
  }
433
- .item-status {
434
- display: none;
435
- font-family: dashicons;
436
- .border-radius(4px);
437
- background: #DDD;
438
- color: #22b4ff;
439
- font-size: 18px;
440
- &:before {
441
- content: "\f177";
442
- }
443
- &.item-status-viewed {
444
-
445
- }
446
- &.item-status-started {
447
- &:before {
448
- content: "\f469";
449
- }
450
- }
451
- &.item-status-completed {
452
- background: #22b4ff;
453
- color: #FFF;
454
- &:before {
455
- content: "\f147";
456
- }
457
- }
458
- &.item-status-passed {
459
- background: #22b4ff;
460
- color: #FFF;
461
- &:before {
462
- content: "\f147";
463
- }
464
- }
465
- &.item-status-failed {
466
- background: #cc540d;
467
- color: #FFF;
468
- &:before {
469
- content: "\f335";
470
- }
471
- }
472
- }
473
- .item-result {
474
- display: none;
475
- }
476
- &.item-has-status {
477
- .item-status {
478
- display: inline-block;
479
- }
480
- }
481
- &.item-has-result {
482
- .item-result {
483
- display: inline-block;
484
- }
485
- }
486
  &.viewable {
487
  cursor: pointer;
488
  &:hover {
@@ -517,7 +461,20 @@
517
  content: '';
518
  }
519
  }
520
-
 
 
 
 
 
 
 
 
 
 
 
 
 
521
  &.focus {
522
  background: #ffb710;
523
  &.off {
@@ -534,19 +491,11 @@
534
  .course-item-meta {
535
  display: block;
536
  line-height: 1;
 
537
  top: 15px;
538
  right: 15px;
539
  float: right;
540
  margin-top: 5px;
541
- .item-loop-meta-text {
542
- font-size: small;
543
- &.item-final {
544
- color: #ffffff;
545
- background: #cc540d;
546
- padding: 3px 8px;
547
- .border-radius(3px);
548
- }
549
- }
550
  }
551
  }
552
 
@@ -644,24 +593,6 @@
644
  .percentage-sign {
645
  margin-left: 5px;
646
  }
647
- .grade {
648
- font-size: 12px;
649
- font-weight: bold;
650
- background: #F5F5F5;
651
- padding: 2px 7px;
652
- .border-radius(3px);
653
- &.in-progress {
654
-
655
- }
656
- &.passed {
657
- color: #ffffff;
658
- background: #95e6f9;
659
- }
660
- &.failed {
661
- color: #ffffff;
662
- background: #ff5425;
663
- }
664
- }
665
  &:after {
666
  display: block;
667
  content: '';
@@ -1059,7 +990,7 @@ body.course-has-popup {
1059
  height: 43px;
1060
  line-height: 43px;
1061
  background: #F5F5F5;
1062
- margin-left: 10px;
1063
  border: 1px solid #DDD;
1064
  outline: none;
1065
  }
@@ -1154,9 +1085,6 @@ body.block-content {
1154
  list-style: none;
1155
  padding: 0;
1156
  margin-left: 0;
1157
- li label {
1158
- display: inline-block;
1159
- }
1160
  }
1161
 
1162
  .quiz-questions-list {
@@ -1168,127 +1096,12 @@ body.block-content {
1168
  }
1169
  .question-title {
1170
  margin: 0 0 5px 0;
1171
- display: inline-block;
1172
- font-size: 14px;
1173
  }
1174
  .current {
1175
  .question-title {
1176
  font-weight: bold;
1177
  }
1178
  }
1179
- input[type="checkbox"], input[type="radio"] {
1180
- border: 1px solid #DDD;
1181
- display: inline-block;
1182
- -webkit-appearance: none;
1183
- width: 18px;
1184
- height: 18px;
1185
- position: relative;
1186
- &:checked {
1187
- &:after {
1188
- content: '';
1189
- display: inline-block;
1190
- position: absolute;
1191
- }
1192
- }
1193
- }
1194
- input[type="checkbox"]:checked {
1195
- &:after {
1196
- border-bottom: 3px solid #00b9eb;
1197
- border-right: 1px solid #00b9eb;
1198
- -webkit-transform: rotate(14deg);
1199
- -moz-transform: rotate(14deg);
1200
- -ms-transform: rotate(14deg);
1201
- -o-transform: rotate(14deg);
1202
- transform: rotate(33deg);
1203
- width: 8px;
1204
- height: 16px;
1205
-
1206
- top: -5px;
1207
- left: 5px;
1208
- }
1209
- }
1210
- input[type="checkbox"] {
1211
- &:disabled {
1212
- &:after {
1213
- border-color: #DDD;
1214
- }
1215
- }
1216
- }
1217
- input[type="radio"] {
1218
- -webkit-border-radius: 50%;
1219
- -moz-border-radius: 50%;
1220
- border-radius: 50%;
1221
- &:checked {
1222
- &:after {
1223
- background: #00b9eb;
1224
- width: 8px;
1225
- height: 8px;
1226
- border-radius: 50%;
1227
- top: 50%;
1228
- left: 50%;
1229
- margin-left: -4px;
1230
- margin-top: -4px;
1231
- }
1232
- }
1233
- &:disabled {
1234
- &:after {
1235
- background: #DDD;
1236
- }
1237
- }
1238
- }
1239
- }
1240
-
1241
- .question-results {
1242
- .question-title {
1243
- &:after {
1244
- font-family: dashicons;
1245
- font-size: 24px;
1246
- vertical-align: middle;
1247
- display: inline-block;
1248
- text-align: center;
1249
- margin-left: 5px;
1250
- }
1251
- }
1252
- &.correct {
1253
- .question-title {
1254
- &:after {
1255
- content: '\f147';
1256
- color: #00adff;
1257
- }
1258
- }
1259
- }
1260
- &.skipped {
1261
- .question-title {
1262
- &:after {
1263
- content: '\f534';
1264
- color: #c6c6c6;
1265
- }
1266
- }
1267
- }
1268
- &.incorrect {
1269
- .question-title {
1270
- &:after {
1271
- content: '\f335';
1272
- color: #ff5425;
1273
- }
1274
- }
1275
- .user-answer-false {
1276
- .option-title {
1277
- text-decoration: line-through;
1278
- }
1279
- }
1280
- }
1281
- .answer-true {
1282
- color: #007acc;
1283
- .option-title {
1284
- background: #fff9d8;
1285
- padding: 0 5px;
1286
- margin-left: -5px;
1287
- }
1288
- }
1289
- input {
1290
- vertical-align: middle;
1291
- }
1292
  }
1293
 
1294
  .quiz-description,
@@ -1309,6 +1122,7 @@ body.block-content {
1309
  }
1310
 
1311
  #quiz-countdown {
 
1312
  .progress-circle {
1313
  overflow: hidden;
1314
  box-shadow: 0 0 3px #bdbdbd inset;
@@ -1756,8 +1570,9 @@ body.block-content {
1756
  }
1757
  }
1758
 
 
1759
  }
1760
- .update-profile {
1761
  border-top: 2px solid #DDD;
1762
  padding-top: 20px;
1763
  }
@@ -1768,10 +1583,10 @@ body.block-content {
1768
  .moxie-shim {
1769
  display: none;
1770
  }
1771
- .lp-form-field-avatar {
1772
  float: left;
1773
  }
1774
- #lp-avatar-actions {
1775
  margin: 20px 0;
1776
  }
1777
  }
@@ -1854,6 +1669,7 @@ body.block-content {
1854
  display: block;
1855
  }
1856
  }
 
1857
  &.croping {
1858
  .lp-avatar-preview-actions {
1859
  display: none;
@@ -1989,7 +1805,6 @@ body {
1989
  text-align: center;
1990
  }
1991
  }
1992
-
1993
  .learn-press-auto-redirect-next-item {
1994
  display: none;
1995
 
@@ -1997,7 +1812,6 @@ body {
1997
  display: block;
1998
  }
1999
  }
2000
-
2001
  .single-lp_course {
2002
  .course-summary {
2003
  .lp_course {
@@ -2042,6 +1856,8 @@ body {
2042
 
2043
  }
2044
 
 
 
2045
  }
2046
 
2047
  /* tooltip */
@@ -2114,6 +1930,20 @@ body.content-item-only {
2114
  }
2115
 
2116
  /*
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2117
  .payment-method-form {
2118
  &.payment_method_authorizenet {
2119
  background: #f7f7f7;
@@ -2144,7 +1974,7 @@ body.content-item-only {
2144
  }
2145
  }
2146
  }
2147
- }*/
2148
 
2149
  .place-order-action {
2150
  margin-top: 20px;
@@ -2180,16 +2010,8 @@ body.content-item-only {
2180
  }
2181
  }
2182
 
2183
- .table-orders {
2184
- .order-status {
2185
- &.order-status-removed {
2186
- color: #FF0000;
2187
- }
2188
- }
2189
- }
2190
-
2191
  /* Shortcode/Widgets */
2192
- .widget_lp-widget-popular-courses, .widget_lp-widget-recent-courses, .widget_lp-widget-featured-courses {
2193
  .course-meta-data {
2194
  > div {
2195
  display: inline-block;
@@ -2207,119 +2029,6 @@ body.content-item-only {
2207
  }
2208
  .course-entry {
2209
  margin-bottom: 20px;
2210
- border-bottom: 1px dashed #DDD;
2211
- padding-bottom: 20px;
2212
- }
2213
- }
2214
-
2215
- .edit-course-item-link {
2216
- a {
2217
- font-size: 14px;
2218
- position: relative;
2219
- padding-left: 25px;
2220
- &:after {
2221
- content: "\f464";
2222
- font-family: Dashicons;
2223
- font-size: 26px;
2224
- position: absolute;
2225
- bottom: 0;
2226
- line-height: 1;
2227
- left: 0;
2228
- }
2229
- }
2230
- }
2231
-
2232
- .course-item-navigation {
2233
- border-top: 4px solid #333;
2234
- padding-top: 10px;
2235
- margin-top: 20px;
2236
- .nav-links {
2237
- .nav-link {
2238
- opacity: 1;
2239
- a {
2240
- opacity: 1;
2241
- .meta-nav {
2242
- display: block;
2243
- text-transform: uppercase;
2244
- font-size: small;
2245
- color: #b9b9b9;
2246
- }
2247
- .post-title {
2248
- opacity: 1;
2249
- }
2250
- }
2251
- &.nav-previous {
2252
- float: left;
2253
- }
2254
- &.nav-next {
2255
- float: right;
2256
- text-align: right;
2257
- }
2258
- }
2259
- &:after {
2260
- clear: both;
2261
- display: block;
2262
- content: '';
2263
- }
2264
- }
2265
- }
2266
-
2267
- /* widget attributes */
2268
- .lp-course-attributes {
2269
- list-style: none;
2270
- margin-left: 0;
2271
- li {
2272
- list-style: none;
2273
- margin-bottom: 10px;
2274
- }
2275
- .lp-course-attribute-values {
2276
- list-style: none;
2277
- margin-left: 0;
2278
- }
2279
- &.course-attributes {
2280
- .lp-course-attribute-values {
2281
- li {
2282
- display: inline-block;
2283
- padding: 3px 8px;
2284
- background: #F0F0F0;
2285
- border-radius: 4px;
2286
- margin: 0 5px 5px 0;
2287
- }
2288
- }
2289
- }
2290
- &.course-filters {
2291
- .lp-course-attribute-values {
2292
- li {
2293
- a:before {
2294
- font-family: dashicons;
2295
- border-radius: 50%;
2296
- background: #DDD;
2297
- display: inline-block;
2298
- width: 16px;
2299
- height: 16px;
2300
- text-align: center;
2301
- line-height: 16px;
2302
- color: #FFF;
2303
- font-size: 16px;
2304
- vertical-align: middle;
2305
- margin-right: 5px;
2306
- content: '';
2307
- }
2308
- &:hover a:before {
2309
- background: #4acfff;
2310
- }
2311
- }
2312
- li.active {
2313
- a:before {
2314
- content: "\f147";
2315
- background: #4acfff;
2316
- }
2317
- &:hover a:before {
2318
- content: "\f335";
2319
- background: #a20000;
2320
- }
2321
- }
2322
- }
2323
  }
2324
  }
2325
 
@@ -2455,7 +2164,6 @@ body.content-item-only {
2455
 
2456
  }
2457
 
2458
- /*
2459
  @media (max-width: 480px) {
2460
  .woocommerce {
2461
  .checkout_coupon {
@@ -2465,7 +2173,7 @@ body.content-item-only {
2465
  }
2466
  }
2467
  }
2468
- */
2469
  @media (max-width: 400px) {
2470
 
2471
  .learn-press-courses {
@@ -2498,7 +2206,6 @@ body.content-item-only {
2498
  }
2499
  }
2500
 
2501
- /*
2502
  @media screen and (max-width: 615px) {
2503
  .payment-method-form {
2504
  &.payment_method_authorizenet {
@@ -2529,4 +2236,3 @@ body.content-item-only {
2529
  }
2530
  }
2531
  }
2532
- */
319
  }
320
  }
321
  }
 
322
  .course-origin-price {
323
  text-decoration: line-through;
324
  padding-right: 5px;
325
  }
 
326
  .course-price {
327
  color: rgb(84, 181, 81);
328
  }
 
329
  .learn-press-notice .button {
330
  float: right;
331
  }
427
  .lp-icon {
428
  display: none;
429
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
430
  &.viewable {
431
  cursor: pointer;
432
  &:hover {
461
  content: '';
462
  }
463
  }
464
+ &.item-has-status .item-status {
465
+ display: inline-block;
466
+ background: #d6d6d6;
467
+ margin-left: 5px;
468
+ &:before {
469
+ content: '\ea10';
470
+ color: #FFF;
471
+ }
472
+ }
473
+ &.item-has-status.item-completed {
474
+ .item-status {
475
+ background: #95e6f9;
476
+ }
477
+ }
478
  &.focus {
479
  background: #ffb710;
480
  &.off {
491
  .course-item-meta {
492
  display: block;
493
  line-height: 1;
494
+ __position: absolute;
495
  top: 15px;
496
  right: 15px;
497
  float: right;
498
  margin-top: 5px;
 
 
 
 
 
 
 
 
 
499
  }
500
  }
501
 
593
  .percentage-sign {
594
  margin-left: 5px;
595
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
596
  &:after {
597
  display: block;
598
  content: '';
990
  height: 43px;
991
  line-height: 43px;
992
  background: #F5F5F5;
993
+ margin: 0 10px;
994
  border: 1px solid #DDD;
995
  outline: none;
996
  }
1085
  list-style: none;
1086
  padding: 0;
1087
  margin-left: 0;
 
 
 
1088
  }
1089
 
1090
  .quiz-questions-list {
1096
  }
1097
  .question-title {
1098
  margin: 0 0 5px 0;
 
 
1099
  }
1100
  .current {
1101
  .question-title {
1102
  font-weight: bold;
1103
  }
1104
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1105
  }
1106
 
1107
  .quiz-description,
1122
  }
1123
 
1124
  #quiz-countdown {
1125
+ //.progress-circle(@initialize: 100%, @size: 260px, @inside-size: 200px);
1126
  .progress-circle {
1127
  overflow: hidden;
1128
  box-shadow: 0 0 3px #bdbdbd inset;
1570
  }
1571
  }
1572
 
1573
+
1574
  }
1575
+ .update-profile{
1576
  border-top: 2px solid #DDD;
1577
  padding-top: 20px;
1578
  }
1583
  .moxie-shim {
1584
  display: none;
1585
  }
1586
+ .lp-form-field-avatar{
1587
  float: left;
1588
  }
1589
+ #lp-avatar-actions{
1590
  margin: 20px 0;
1591
  }
1592
  }
1669
  display: block;
1670
  }
1671
  }
1672
+
1673
  &.croping {
1674
  .lp-avatar-preview-actions {
1675
  display: none;
1805
  text-align: center;
1806
  }
1807
  }
 
1808
  .learn-press-auto-redirect-next-item {
1809
  display: none;
1810
 
1812
  display: block;
1813
  }
1814
  }
 
1815
  .single-lp_course {
1816
  .course-summary {
1817
  .lp_course {
1856
 
1857
  }
1858
 
1859
+
1860
+
1861
  }
1862
 
1863
  /* tooltip */
1930
  }
1931
 
1932
  /*
1933
+ .sidebar-hide-btn, .sidebar-show-btn {
1934
+ cursor: pointer;
1935
+ width: 60px;
1936
+ height: 60px;
1937
+ display: inline-block;
1938
+ font-size: 34px;
1939
+ line-height: 60px;
1940
+ text-align: center;
1941
+ color: #FFF;
1942
+ position: absolute;
1943
+
1944
+
1945
+ }*/
1946
+
1947
  .payment-method-form {
1948
  &.payment_method_authorizenet {
1949
  background: #f7f7f7;
1974
  }
1975
  }
1976
  }
1977
+ }
1978
 
1979
  .place-order-action {
1980
  margin-top: 20px;
2010
  }
2011
  }
2012
 
 
 
 
 
 
 
 
 
2013
  /* Shortcode/Widgets */
2014
+ .recent-courses-widget, .popular-courses-widget, .featured-courses-widget {
2015
  .course-meta-data {
2016
  > div {
2017
  display: inline-block;
2029
  }
2030
  .course-entry {
2031
  margin-bottom: 20px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2032
  }
2033
  }
2034
 
2164
 
2165
  }
2166
 
 
2167
  @media (max-width: 480px) {
2168
  .woocommerce {
2169
  .checkout_coupon {
2173
  }
2174
  }
2175
  }
2176
+
2177
  @media (max-width: 400px) {
2178
 
2179
  .learn-press-courses {
2206
  }
2207
  }
2208
 
 
2209
  @media screen and (max-width: 615px) {
2210
  .payment-method-form {
2211
  &.payment_method_authorizenet {
2236
  }
2237
  }
2238
  }
 
assets/js/admin/admin.js CHANGED
@@ -655,7 +655,7 @@ lprHook.addAction('lpr_admin_quiz_question_html', _lprAdminQuestionHTML);
655
  parse_json : function (response) {
656
  if (typeof reposnse == 'object') return response;
657
  try {
658
- var m = response.match(/<-- LP_AJAX_START -->(.*)<-- LP_AJAX_END -->/)
659
 
660
  if (m && m[1]) {
661
  response = JSON.parse(m[1])
655
  parse_json : function (response) {
656
  if (typeof reposnse == 'object') return response;
657
  try {
658
+ var m = response.match(/<!-- LP_AJAX_START -->(.*)<!-- LP_AJAX_END -->/)
659
 
660
  if (m && m[1]) {
661
  response = JSON.parse(m[1])
assets/js/admin/attributes.js DELETED
@@ -1,92 +0,0 @@
1
- ;(function ($) {
2
- var select2Options = {
3
- formatNoMatches: function () {
4
- $(document).off('keyup.addNewAttributeValueEvent');
5
- $(document).on('keyup.addNewAttributeValueEvent', '.select2-input', addNewAttributeValueEvent);
6
- return 'No match found, <code>Ctrl + Enter</code> to add new attribute';
7
- },
8
- formatMatches : function () {
9
- $(document).off('keyup.addNewAttributeValueEvent');
10
- }
11
- }, postId = 0;
12
-
13
- function getPostId() {
14
- if (!postId) {
15
- postId = $('input[name="post_ID"]').val();
16
- }
17
- return postId;
18
- }
19
-
20
- function addAttributeToCourse(button) {
21
- $(button).addClass('disabled');
22
- $.post({
23
- url : window.location.href.addQueryVar('add-attribute-to-course', getPostId()),
24
- data : $().extend({}, $(button).data()),
25
- success: function (response) {
26
- var $html = $('.course-attributes');
27
- $(response).appendTo($html);
28
- $html.find('.course-attribute-values').select2(select2Options)
29
- }
30
- })
31
- }
32
-
33
- function addNewAttributeValue(name, taxonomy, el) {
34
- var $li = $(el).closest('.learn-press-attribute');
35
- $.post({
36
- url : window.location.href.addQueryVar('add-attribute-value', getPostId()),
37
- data : {
38
- name : name,
39
- taxonomy: taxonomy
40
- },
41
- dataType: 'text',
42
- success : function (response) {
43
- response = LP.parseJSON(response);
44
- if (response.result == 'success') {
45
- $li.find('select.course-attribute-values').append('<option value="' + response.slug + '" selected="selected">' + response.name + '</option>').change();
46
- } else {
47
- if (response.message) {
48
- alert(response.message);
49
- }
50
- }
51
- }
52
- })
53
- }
54
-
55
- function addNewAttributeValueEvent(e) {
56
- if (e.ctrlKey && e.keyCode == 13) {
57
- var $sel = $('.select2-focused');
58
- if ($sel.length == 0) {
59
- return;
60
- }
61
- addNewAttributeValue($sel.val(), $sel.closest('.learn-press-attribute').data('taxonomy'), this)
62
- }
63
- }
64
-
65
- function saveAttributesEvent(e) {
66
- $.post({
67
- url : window.location.href.addQueryVar('save-attributes', getPostId()),
68
- data : {
69
- data: $('.course-attributes').find('input, select, textarea').serialize(),
70
- },
71
- success: function () {
72
-
73
- }
74
- });
75
- }
76
-
77
- $(document).ready(function () {
78
- $(document)
79
- .on('click', '.add-attribute:not(.disabled)', function () {
80
- addAttributeToCourse(this);
81
- })
82
- .on('click', '#save-attributes', saveAttributesEvent)
83
- .on('keyup.addNewAttributeValueEvent', '.select2-input', addNewAttributeValueEvent);
84
-
85
- var $courseAttributes = $('.course-attribute-values') ;
86
-
87
- if ($courseAttributes.length) {
88
- $courseAttributes.select2(select2Options);
89
- }
90
-
91
- });
92
- })(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/js/admin/course-editor.js CHANGED
@@ -34,7 +34,7 @@
34
  },
35
  render : function () {
36
  this.$editor = this.template('course-editor');
37
- var $curriculum = this.$editor.find('#lp-course-curriculum');
38
  this.model.sections.forEach(function (section) {
39
  var $section = this._createSection(section);
40
  $curriculum.append($section);
@@ -69,8 +69,8 @@
69
  axis : 'y',
70
  handle : '.section-item-move',
71
  connectWith: '.section-items',
72
- stop : function (e, ui) {
73
- if (!ui.item.hasClass('ui-draggable')) {
74
  return;
75
  }
76
  var temp_id = parseInt($(this).closest('.course-section').data('temp_id')),
@@ -88,7 +88,7 @@
88
  $section.find('.section-content-types li').draggable({
89
  revert : 'invalid',
90
  connectToSortable: '.section-items',
91
- helper : function () {
92
 
93
  var $helper = $(this).clone();
94
  $helper.get(0).className = 'ui-draggable ui-draggable-handle course-section-item';
@@ -99,7 +99,7 @@
99
  accept: '.dashicons',
100
  drop : function (e, ui) {
101
 
102
- if (!xxx.check(10)) {
103
  //return;
104
  }
105
 
@@ -149,7 +149,7 @@
149
  this.model.sections.add(section);
150
 
151
  var $section = this._createSection(section);
152
- this.$editor.find('#lp-course-curriculum').append($section);
153
  $section.find('.section-name').focus();
154
  },
155
  _showContentTypes: function (e) {
34
  },
35
  render : function () {
36
  this.$editor = this.template('course-editor');
37
+ var $curriculum = this.$editor.find('#course-curriculum');
38
  this.model.sections.forEach(function (section) {
39
  var $section = this._createSection(section);
40
  $curriculum.append($section);
69
  axis : 'y',
70
  handle : '.section-item-move',
71
  connectWith: '.section-items',
72
+ stop: function(e, ui){
73
+ if(!ui.item.hasClass('ui-draggable')){
74
  return;
75
  }
76
  var temp_id = parseInt($(this).closest('.course-section').data('temp_id')),
88
  $section.find('.section-content-types li').draggable({
89
  revert : 'invalid',
90
  connectToSortable: '.section-items',
91
+ helper : function(){
92
 
93
  var $helper = $(this).clone();
94
  $helper.get(0).className = 'ui-draggable ui-draggable-handle course-section-item';
99
  accept: '.dashicons',
100
  drop : function (e, ui) {
101
 
102
+ if(!xxx.check(10)){
103
  //return;
104
  }
105
 
149
  this.model.sections.add(section);
150
 
151
  var $section = this._createSection(section);
152
+ this.$editor.find('#course-curriculum').append($section);
153
  $section.find('.section-name').focus();
154
  },
155
  _showContentTypes: function (e) {
assets/js/admin/meta-box-course.js CHANGED
@@ -30,7 +30,7 @@
30
  'keyup' : 'processKeyEvents',
31
  'click .lp-section-item .lp-remove' : '_removeItem',
32
  'click .lp-toggle' : 'toggleSection',
33
- 'click .curriculum-heading .items-toggle a' : 'toggleSections',
34
  'keyup input.no-submit' : 'onEnterInput',
35
  'update input.no-submit' : 'onEnterInput',
36
  'keydown' : 'preventSubmit',
@@ -45,8 +45,7 @@
45
  'click .learn-press-dropdown-item-types > li a' : '_changeItemType',
46
  'change .lp-item-name ' : '_updateItem',
47
  'focus .lp-item-name' : '_focusItem',
48
- 'blur .lp-item-name' : '_blurItem',
49
- 'click #learn-press-toggle-course-results' : '_toggleCourseResults'
50
  },
51
  removeSectionIds : [],
52
  removeItemIds : [],
@@ -67,13 +66,6 @@
67
  $('#course_curriculum.postbox').removeClass('closed');
68
 
69
  },
70
- _toggleCourseResults : function (e) {
71
- e.preventDefault();
72
- var $a = $(e.target),
73
- click = $a.data('click');
74
- $a.html($a.data(click));
75
- $a.attr('data-click', click == 'advanced' ? 'basic' : 'advanced');
76
- },
77
  _focusItem : function (e) {
78
  $(e.target).closest('tr').removeClass('focus');
79
  },
@@ -259,7 +251,17 @@
259
  .on('change', 'input[name="learn-press-submit-for-review"]', this.toggleMessage);
260
 
261
  $('input[name="learn_press_submit_course_notice_reviewer"]').trigger('change');
262
-
 
 
 
 
 
 
 
 
 
 
263
  },
264
  toggleMessage : function (e) {
265
  if (e.target.checked) {
@@ -572,11 +574,10 @@
572
  e.preventDefault();
573
  var $target = $(e.target);
574
  if ($target.attr('data-action') == 'expand') {
575
- this.$('.curriculum-section:not(.lp-empty-section) .curriculum-section-content').slideDown();
576
  } else {
577
- this.$('.curriculum-section:not(.lp-empty-section) .curriculum-section-content').slideUp();
578
  }
579
- $target.addClass('hide-if-js').siblings('a').removeClass('hide-if-js');
580
  },
581
  getSelectedItems : function () {
582
  return this.$('.lp-section-item[data-item_id]').map(function () {
@@ -1442,22 +1443,6 @@
1442
  });
1443
  });
1444
 
1445
- function _toggleCourseResults(click) {
1446
-
1447
- }
1448
-
1449
- $(document).on('click.learn-press-toggle-course-results', '#learn-press-toggle-course-results a', function (e) {
1450
- e.preventDefault();
1451
- var $a = $(this),
1452
- click = $a.data('click');
1453
- $a.html($a.data(click));
1454
- $a.data('click', click == 'advanced' ? 'basic' : 'advanced');
1455
- $a.closest('.rwmb-input').children('label:gt(1)').toggle(click != 'advanced');
1456
- $a.parent().remove();
1457
- });
1458
- if ($.inArray($('input[name="_lp_course_result"]:checked').val(), ['', 'evaluate_lesson', 'evaluate_final_quiz']) != -1) {
1459
- $('#learn-press-toggle-course-results').closest('.rwmb-input').children('label:gt(1)').hide();
1460
- }
1461
 
1462
  function canSubmit() {
1463
  if ((opts.current_user_type == 'admin') || !opts.required_review || (opts.course_status == 'publish' && opts.enable_edit_published)) {
30
  'keyup' : 'processKeyEvents',
31
  'click .lp-section-item .lp-remove' : '_removeItem',
32
  'click .lp-toggle' : 'toggleSection',
33
+ 'click .lp-course-curriculum-toggle a' : 'toggleSections',
34
  'keyup input.no-submit' : 'onEnterInput',
35
  'update input.no-submit' : 'onEnterInput',
36
  'keydown' : 'preventSubmit',
45
  'click .learn-press-dropdown-item-types > li a' : '_changeItemType',
46
  'change .lp-item-name ' : '_updateItem',
47
  'focus .lp-item-name' : '_focusItem',
48
+ 'blur .lp-item-name' : '_blurItem'
 
49
  },
50
  removeSectionIds : [],
51
  removeItemIds : [],
66
  $('#course_curriculum.postbox').removeClass('closed');
67
 
68
  },
 
 
 
 
 
 
 
69
  _focusItem : function (e) {
70
  $(e.target).closest('tr').removeClass('focus');
71
  },
251
  .on('change', 'input[name="learn-press-submit-for-review"]', this.toggleMessage);
252
 
253
  $('input[name="learn_press_submit_course_notice_reviewer"]').trigger('change');
254
+ $(window).scroll(function () {
255
+ return;
256
+ var $holder = $('#course_tabs_placeholder'),
257
+ $tabs = $('#course_tabs'),
258
+ top = $holder.offset().top;
259
+ if ($(window).scrollTop() > top) {
260
+ $tabs.css('width', $tabs.width()).addClass('fixed');
261
+ } else {
262
+ $tabs.css('width', '').removeClass('fixed');
263
+ }
264
+ });
265
  },
266
  toggleMessage : function (e) {
267
  if (e.target.checked) {
574
  e.preventDefault();
575
  var $target = $(e.target);
576
  if ($target.attr('data-action') == 'expand') {
577
+ this.$('.curriculum-section:not(.lp-empty-section) .lp-curriculum-section-content').slideDown();
578
  } else {
579
+ this.$('.curriculum-section:not(.lp-empty-section) .lp-curriculum-section-content').slideUp();
580
  }
 
581
  },
582
  getSelectedItems : function () {
583
  return this.$('.lp-section-item[data-item_id]').map(function () {
1443
  });
1444
  });
1445
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1446
 
1447
  function canSubmit() {
1448
  if ((opts.current_user_type == 'admin') || !opts.required_review || (opts.course_status == 'publish' && opts.enable_edit_published)) {
assets/js/admin/meta-box-order.js CHANGED
@@ -14,38 +14,19 @@
14
  _.bindAll(this, 'resetModal', 'updateModal', '_updateDescription');
15
  LP.Hook.addAction('learn_press_message_box_before_resize', this.resetModal);
16
  LP.Hook.addAction('learn_press_message_box_resize', this.updateModal);
17
-
18
- var $selectUsers = this.$('#order-customer');
19
- if ($selectUsers.attr('multiple') == 'multiple') {
20
- $selectUsers.select2({
21
- width: $('#minor-publishing .misc-pub-section').innerWidth() - 20
22
- });
23
- }
24
- var $add_new_h2 = $('body.post-type-lp_order').find('.page-title-action, .add-new-h2'),
25
- $add_h2 = $('<a href="post-new.php?post_type=lp_order&multi-users=yes" class="page-title-action add-new-h2">Add order multiple users</a>');
26
- $add_h2
27
- .insertAfter($add_new_h2);
28
-
29
- $('select[name="order-status"]').on('init change', function () {
30
- var $sel = $(this),
31
- $sec = $('.order-action-section'),
32
- status = $sel.data('status');
33
- console.log(status, $sel.val())
34
- $sec.toggleClass('hide-if-js', status != $sel.val());
35
- }).trigger('init');
36
-
37
-
38
  $(document).on('learn_press_modal_search_items_response', this.addItem2);
39
  this.userSuggest();
40
  },
41
  _updateDescription: function (e) {
42
  var $sel = $(e.target),
43
  $option = $sel.find('option:selected');
44
- $sel.siblings('.description').hide().html($option.attr('data-desc'))
45
- .removeClass(function (c, d) {
46
- var m = d.match(/(lp-.*)\s?/);
47
- return m ? m[0] : '';
48
- }).addClass($option.val()).show();
 
 
49
  },
50
  userSuggest : function () {
51
  var id = ( typeof current_site_id !== 'undefined' ) ? '&site_id=' + current_site_id : '';
@@ -82,7 +63,7 @@
82
  updateModal : function ($app) {
83
  this.$('#learn-press-courses-result').css('height', '').css('overflow', '');
84
  },
85
- showFormItems : function (type) {
86
  var $form = LP.ModalSearchItems({
87
  template : 'tmpl-learn-press-search-items',
88
  type : 'lp_course',
@@ -97,22 +78,22 @@
97
 
98
  },
99
  _addItem : function (e) {
100
- this.showFormItems('lp_course', 'add-lp_course')
101
  // var $form = $('#learn-press-modal-add-order-courses');
102
  // if ($form.length == 0) {
103
  // $form = $(wp.template('learn-press-modal-add-order-courses')());
104
  // }
105
  // LP.MessageBox.show($form);
106
  },
107
- addItem2 : function (e, $view, $items) {
108
- var that = this;
109
- var selected = $items; //$form.find('li:visible input:checked'),
110
  if (e.ctrlKey) {
111
  //return true;
112
  }
113
  var ids = [];
114
  selected.each(function () {
115
- ids.push($(this).data('id'));
116
  });
117
 
118
  $.ajax({
@@ -135,17 +116,17 @@
135
  $order_table.find('.order-subtotal').html(response.order_data.subtotal_html);
136
  $order_table.find('.order-total').html(response.order_data.total_html);
137
 
138
- selected.each(function () {
139
- console.log($(this));
140
- $(this).remove();
141
- });
142
  $no_item.addClass('hide-if-js');
143
  }
144
  }
145
  });
146
 
147
  return false;
148
- // restart sortable
149
  // _makeListSortable();
150
  },
151
  addItem : function (e, ids) {
14
  _.bindAll(this, 'resetModal', 'updateModal', '_updateDescription');
15
  LP.Hook.addAction('learn_press_message_box_before_resize', this.resetModal);
16
  LP.Hook.addAction('learn_press_message_box_resize', this.updateModal);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  $(document).on('learn_press_modal_search_items_response', this.addItem2);
18
  this.userSuggest();
19
  },
20
  _updateDescription: function (e) {
21
  var $sel = $(e.target),
22
  $option = $sel.find('option:selected');
23
+ $sel.siblings('.description').fadeOut('fast', function () {
24
+ $(this).html($option.attr('data-desc'))
25
+ .removeClass(function (c, d) {
26
+ var m = d.match(/(lp-.*)\s?/);
27
+ return m ? m[0] : '';
28
+ }).addClass($option.val()).fadeIn('fast');
29
+ });
30
  },
31
  userSuggest : function () {
32
  var id = ( typeof current_site_id !== 'undefined' ) ? '&site_id=' + current_site_id : '';
63
  updateModal : function ($app) {
64
  this.$('#learn-press-courses-result').css('height', '').css('overflow', '');
65
  },
66
+ showFormItems : function ( type ) {
67
  var $form = LP.ModalSearchItems({
68
  template : 'tmpl-learn-press-search-items',
69
  type : 'lp_course',
78
 
79
  },
80
  _addItem : function (e) {
81
+ this.showFormItems('lp_course','add-lp_course')
82
  // var $form = $('#learn-press-modal-add-order-courses');
83
  // if ($form.length == 0) {
84
  // $form = $(wp.template('learn-press-modal-add-order-courses')());
85
  // }
86
  // LP.MessageBox.show($form);
87
  },
88
+ addItem2 : function (e, $view, $items) {
89
+ var that = this;
90
+ var selected = $items; //$form.find('li:visible input:checked'),
91
  if (e.ctrlKey) {
92
  //return true;
93
  }
94
  var ids = [];
95
  selected.each(function () {
96
+ ids.push( $(this).data('id') );
97
  });
98
 
99
  $.ajax({
116
  $order_table.find('.order-subtotal').html(response.order_data.subtotal_html);
117
  $order_table.find('.order-total').html(response.order_data.total_html);
118
 
119
+ selected.each(function () {
120
+ console.log($(this));
121
+ $(this).remove();
122
+ });
123
  $no_item.addClass('hide-if-js');
124
  }
125
  }
126
  });
127
 
128
  return false;
129
+ // restart sortable
130
  // _makeListSortable();
131
  },
132
  addItem : function (e, ids) {
assets/js/admin/meta-box-quiz.js CHANGED
@@ -283,18 +283,6 @@
283
  }
284
  $el.find('span').html(t);
285
  }).filter(':checked').trigger('change');
286
-
287
- $('input[name="_lp_show_hide_question"]').change(function () {
288
- var t = $('input[name="_lp_show_hide_question"]:checked').val(),
289
- $el = $('label[for="_lp_show_result"]'),
290
- passing_grade = $('input[name="_lp_show_result"]');
291
- if( t === 'show' ){
292
- $el.closest('.rwmb-field').show();
293
- } else {
294
- $el.closest('.rwmb-field').hide();
295
- }
296
- $el.find('span').html(t);
297
- }).filter(':checked').trigger('change');
298
  });
299
 
300
  return;
@@ -327,4 +315,4 @@
327
 
328
  $doc.ready(_ready);
329
 
330
- })(jQuery)
283
  }
284
  $el.find('span').html(t);
285
  }).filter(':checked').trigger('change');
 
 
 
 
 
 
 
 
 
 
 
 
286
  });
287
 
288
  return;
315
 
316
  $doc.ready(_ready);
317
 
318
+ })(jQuery)
assets/js/frontend/course-filters.js DELETED
@@ -1,146 +0,0 @@
1
- ;(function ($) {
2
- "use strict";
3
- $.fn.courseFilters = function (options) {
4
- return $.each(this, function () {
5
- var defaults = {
6
- attribute_operator: 'and',
7
- value_operator : 'and',
8
- ajax_filter : 1,
9
- button_filter : 1
10
- },
11
- $widget = $(this),
12
- widgetID = $widget.attr('id'),
13
- filterUrl = window.location.href.addQueryVar('course-filter', 'yes'),
14
- oldFilterUrl = filterUrl,
15
- $buttonFilter = $widget.find('.lp-button-filter'),
16
- $buttonReset = $widget.find('.lp-button-reset-filter');
17
- options = $.extend({}, defaults, options || {});
18
-
19
- filterUrl = filterUrl
20
- .addQueryVar('attribute_operator', options.attribute_operator)
21
- .addQueryVar('value_operator', options.value_operator);
22
- function addAttribute(attribute, value) {
23
- var attributes = filterUrl.getQueryVar(attribute);
24
- if (!attributes) {
25
- attributes = value;
26
- } else {
27
- if (attributes.indexOf(value) == -1) {
28
- attributes += ',' + value;
29
- }
30
- }
31
- filterUrl = filterUrl.addQueryVar(attribute, attributes);
32
- return filterUrl;
33
- }
34
-
35
- function removeAttribute(attribute, value) {
36
- var attributes = filterUrl.getQueryVar(attribute);
37
- if (attributes) {
38
- attributes = attributes.replace(value, '').split(',').filter(function (a, b) {
39
- return a + '' !== '';
40
- }).join(',');
41
- if (attributes) {
42
- filterUrl = filterUrl.addQueryVar(attribute, attributes);
43
- } else {
44
- filterUrl = filterUrl.removeQueryVar(attribute);
45
- }
46
- }
47
- return filterUrl;
48
- }
49
-
50
- function hasFiltered() {
51
- return $('#' + widgetID + ' .lp-course-attribute-values li.active').length;
52
- }
53
-
54
- function validateUrl(url) {
55
- // remove paged in query
56
- url = url.replace(/\/page\/[0-9]+/, '').removeQueryVar('paged');
57
- return url;
58
- }
59
-
60
- function doFilter() {
61
- filterUrl = validateUrl(filterUrl);
62
- if (oldFilterUrl == filterUrl) {
63
- return;
64
- }
65
- var useAjax = $widget.find('.lp-course-attributes.course-filters').data('ajax') == 'yes';
66
- if (useAjax) {
67
- LP.setUrl(filterUrl);
68
- LP.blockContent();
69
- $.ajax({
70
- url : filterUrl,
71
- success: function (res) {
72
- var $html = $(res).contents(),
73
- $newContent = $html.find('.entry-content'),
74
- $newWidget = $html.find('#' + widgetID);
75
- $('.entry-content').replaceWith($newContent);
76
- $('#' + widgetID).replaceWith($newWidget);
77
- LP.unblockContent();
78
- }
79
- });
80
- } else {
81
- LP.reload(filterUrl);
82
- }
83
- oldFilterUrl = filterUrl;
84
- $buttonFilter.prop('disabled', true);
85
- }
86
-
87
- function toggleControls() {
88
- filterUrl = validateUrl(filterUrl);
89
- var url = filterUrl;
90
- if (!hasFiltered()) {
91
- url = url
92
- .removeQueryVar('attribute_operator')
93
- .removeQueryVar('value_operator')
94
- .removeQueryVar('course-filter');
95
- }
96
- if ($buttonFilter.length == 0) {
97
- doFilter();
98
- } else {
99
- if (filterUrl == oldFilterUrl) {
100
- $buttonFilter.prop('disabled', true);
101
- } else {
102
- $buttonFilter.prop('disabled', false);
103
- }
104
- $buttonReset.prop('disabled', !hasFiltered());
105
- }
106
- LP.setUrl(url);
107
- }
108
-
109
- if ($buttonFilter.length) {
110
- $buttonFilter.off('click').on('click', function () {
111
- doFilter()
112
- })
113
- }
114
- $buttonReset.off('click').on('click', function () {
115
- $('#' + widgetID + ' .lp-course-attribute-values li.active a').each(function () {
116
- var $this = $(this),
117
- $li = $this.parent(),
118
- $attribute = $li.closest('.lp-course-attribute-values').parent(),
119
- attribute = $attribute.data('attribute'),
120
- value = $li.data('value');
121
- $li.removeClass('active');
122
- filterUrl = filterUrl.removeQueryVar(attribute);
123
- });
124
- $(this).prop('disabled', true);
125
- toggleControls();
126
- })
127
- $(document)
128
- .off('click', '#' + widgetID + ' .lp-course-attribute-values a')
129
- .on('click', '#' + widgetID + ' .lp-course-attribute-values a', function (e) {
130
- e.preventDefault();
131
- var $this = $(this),
132
- $li = $this.parent(),
133
- $attribute = $li.closest('.lp-course-attribute-values').parent(),
134
- attribute = $attribute.data('attribute'),
135
- value = $li.data('value');
136
- $li.toggleClass('active');
137
- if ($li.hasClass('active')) {
138
- filterUrl = addAttribute(attribute, value);
139
- } else {
140
- filterUrl = removeAttribute(attribute, value);
141
- }
142
- toggleControls();
143
- });
144
- });
145
- }
146
- })(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/js/frontend/learnpress.js CHANGED
@@ -22,7 +22,7 @@
22
  window.location.href = url;
23
  },
24
  parseJSON : function (data) {
25
- var m = data.match(/<-- LP_AJAX_START -->(.*)<-- LP_AJAX_END -->/);
26
  try {
27
  if (m) {
28
  data = $.parseJSON(m[1]);
@@ -30,6 +30,7 @@
30
  data = $.parseJSON(data);
31
  }
32
  } catch (e) {
 
33
  data = {};
34
  }
35
  return data;
22
  window.location.href = url;
23
  },
24
  parseJSON : function (data) {
25
+ var m = data.match(/<!-- LP_AJAX_START -->(.*)<!-- LP_AJAX_END -->/);
26
  try {
27
  if (m) {
28
  data = $.parseJSON(m[1]);
30
  data = $.parseJSON(data);
31
  }
32
  } catch (e) {
33
+ LP.log(e);
34
  data = {};
35
  }
36
  return data;
assets/js/frontend/lesson.js CHANGED
@@ -42,7 +42,7 @@
42
  security = $button.data('security'),
43
  $item = $button.closest('.course-item');
44
  windowTarget.LP.blockContent();
45
- /*return;
46
  this.complete({
47
  security : security,
48
  course_id : this.model.get('courseId'),
@@ -55,7 +55,10 @@
55
  item.$el.removeClass('focus off');
56
  }, 3000, item);
57
 
58
-
 
 
 
59
  windowTarget.LP.setUrl(that.model.get('permalink'));
60
  var data = response.course_result;
61
  data.messageType = 'update-course';
@@ -63,7 +66,7 @@
63
  }
64
  windowTarget.LP.unblockContent();
65
  }
66
- });*/
67
  },
68
  complete : function (args) {
69
  var that = this;
42
  security = $button.data('security'),
43
  $item = $button.closest('.course-item');
44
  windowTarget.LP.blockContent();
45
+ return;
46
  this.complete({
47
  security : security,
48
  course_id : this.model.get('courseId'),
55
  item.$el.removeClass('focus off');
56
  }, 3000, item);
57
 
58
+ /*that.$('.learn-press-course-results-progress').replaceWith($(response.html.progress));
59
+ $section.find('.section-header').replaceWith($(response.html.section_header));
60
+ that.$('.learn-press-course-buttons').replaceWith($(response.html.buttons));
61
+ that.currentItem.set('content', $(response.html.content))*/
62
  windowTarget.LP.setUrl(that.model.get('permalink'));
63
  var data = response.course_result;
64
  data.messageType = 'update-course';
66
  }
67
  windowTarget.LP.unblockContent();
68
  }
69
+ });
70
  },
71
  complete : function (args) {
72
  var that = this;
assets/js/frontend/profile.js CHANGED
@@ -313,4 +313,240 @@
313
  });
314
  });
315
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
316
  })(jQuery);
313
  });
314
  });
315
 
316
+ return;
317
+ $(document).on('click', '#lp-remove-upload-photo', function () {
318
+
319
+
320
+ $('#learn-press-toggle-password').click(function (e) {
321
+ e.preventDefault();
322
+ var $el = $('#user_profile_password_form');
323
+ if ($el.hasClass('hide-if-js')) {
324
+ $el.removeClass('hide-if-js').hide();
325
+ }
326
+ $el.slideToggle(function () {
327
+ $el.find('input').attr('disabled', !$el.is(':visible'));
328
+ });
329
+ });
330
+
331
+ $('#learn-press-form-login input[type="text"]').focus();
332
+ /**
333
+ * Show hide dropdown menu
334
+ */
335
+ $('.user-profile-edit-form').on('change', 'select[name="profile_picture_type"]', function () {
336
+ var avata_type = $(this).val();
337
+ $('.profile-avatar-hidden, .profile-avatar-current').each(function () {
338
+ $(this).toggleClass('hide-if-js', $(this).hasClass('avatar-' + avata_type));
339
+ });
340
+ $('.menu-item-use-gravatar, .menu-item-use-picture').each(function () {
341
+ $(this).toggleClass('lp-menu-item-selected', $(this).hasClass('menu-item-use-' + avata_type));
342
+ });
343
+ });
344
+
345
+ $('#lp-menu-change-picture .menu-item-use-gravatar').click(function (event) {
346
+ $('#lp-profile_picture_type').val('gravatar').trigger('change');
347
+ $('#lpbox-upload-crop-profile-picture').slideUp();
348
+ });
349
+
350
+ $('#lp-menu-change-picture .menu-item-use-picture').click(function (event) {
351
+ var current_picture = $('#lp-user-profile-picture-data').attr('data-current');
352
+ if (!current_picture) {
353
+ // $('#lp-button-choose-file').trigger('click');
354
+ $('#lpbox-upload-crop-profile-picture').slideDown();
355
+ } else {
356
+ $('#lp-profile_picture_type').val('picture').trigger('change');
357
+ $('#lpbox-upload-crop-profile-picture').slideUp();
358
+ }
359
+ });
360
+
361
+ $('#lp-menu-change-picture .menu-item-upload-picture').click(function (event) {
362
+ // $('#lp-button-choose-file').trigger('click');
363
+ $('#lpbox-upload-crop-profile-picture').slideDown();
364
+ });
365
+
366
+ $('#lp-ocupload-picture').upload(
367
+ {
368
+ 'name' : 'image',
369
+ params : {from: 'profile', 'action': 'update', 'sub_action': 'upload_avatar'},
370
+ 'onSubmit' : function () {
371
+ LP.blockContent();
372
+ },
373
+ 'onComplete': function (response) {
374
+ response = LP.parseJSON(response);
375
+ console.log(response);
376
+ if (response.return && response.avatar_tmp) {
377
+ /* Load Image in to crop */
378
+ $('.image-editor').cropit('imageSrc', response.avatar_tmp);
379
+ $('.image-editor').attr('avatar-filename', response.avatar_tmp_filename);
380
+ $('#lpbox-upload-crop-profile-picture').slideDown();
381
+ LP.unblockContent();
382
+ $('body, html').css('overflow', 'visible');
383
+ $('.user-profile-picture.info-field .learn-press-message').remove();
384
+ var message = '<div class="learn-press-message success"><p>' + response.message + '</p></div>';
385
+ $('.user-profile-picture.info-field').prepend(message);
386
+ } else if (!response.return) {
387
+ $('.image-editor').cropit('imageSrc', '');
388
+ $('.image-editor').attr('avatar-filename', '');
389
+ LP.unblockContent();
390
+ $('body, html').css('overflow', 'visible');
391
+ $('.user-profile-picture.info-field .learn-press-message').remove();
392
+ var message = '<div class="learn-press-message error"><p>' + response.message + '</p></div>';
393
+ $('.user-profile-picture.info-field').prepend(message);
394
+
395
+ }
396
+ }
397
+ }
398
+ );
399
+
400
+ $('#lp-button-choose-file').click(function (event) {
401
+ event.preventDefault();
402
+ $('#lp-ocupload-picture').parent().find('form input[name="image"]').trigger('click');
403
+ });
404
+
405
+ $('#lpbox-upload-crop-profile-picture .image-editor').cropit();
406
+
407
+
408
+ $('#lp-button-apply-changes').click(function (event) {
409
+ event.preventDefault();
410
+ var zoom = $('.image-editor').cropit('zoom');
411
+ var offset = $('.image-editor').cropit('offset');
412
+ var avatar_filename = $('.image-editor').attr('avatar-filename');
413
+ var datas = {
414
+ from : 'profile',
415
+ 'action' : 'update',
416
+ 'sub_action' : 'crop_avatar',
417
+ 'avatar_filename': avatar_filename,
418
+ 'zoom' : zoom,
419
+ 'offset' : offset
420
+ };
421
+ /** Create avatar, thumbnail and update picture option **/
422
+ $.ajax({
423
+ url : LP.getUrl(),
424
+ dataType : 'html',
425
+ data : datas,
426
+ type : 'post',
427
+ beforeSend: function () {
428
+ LP.blockContent();
429
+ },
430
+ success : function (response) {
431
+ response = LP.parseJSON(response);
432
+ var avatar_url = response.avatar_url;
433
+ $('.profile-picture.avatar-gravatar img').attr('src', avatar_url);
434
+ $('#lp-profile_picture_type').val('picture').trigger('change');
435
+ $('#lpbox-upload-crop-profile-picture').slideUp();
436
+ LP.unblockContent();
437
+ $('body, html').css('overflow', 'visible');
438
+ $('.user-profile-picture.info-field .learn-press-message').remove();
439
+ $('.user-profile-picture.info-field').prepend(response.message);
440
+ }
441
+ });
442
+ return;
443
+ });
444
+
445
+ $('#lp-button-cancel-changes').click(function (event) {
446
+ event.preventDefault();
447
+ $('#lpbox-upload-crop-profile-picture').slideUp();
448
+ });
449
+
450
+ $('#learn-press-user-profile-edit-form form#your-profile input[name="submit"]').on('click', function (event) {
451
+ event.preventDefault();
452
+ var check_form = true;
453
+ var check_focus = false;
454
+ /**
455
+ * VALIDATE FORM
456
+ */
457
+ // console.log( '' === $('#your-profile #nickname' ).val());
458
+ if ('' === $('#your-profile #nickname').val()) {
459
+ if (0 === $('#your-profile #nickname').next('span.error').length) {
460
+ $('<span class="error">' + lp_profile_translation.msg_field_is_required + '</span>').insertAfter($('#your-profile #nickname'));
461
+ }
462
+ check_form = false;
463
+ //document.getElementById('nickname').focus();
464
+ $('#your-profile #nickname').focus();
465
+ check_focus = true;
466
+ } else {
467
+ $('#your-profile #nickname').next('span.error').remove();
468
+ }
469
+
470
+ if ('' !== $('#your-profile #pass0').val()) {
471
+ if ('' === $('#your-profile #pass1').val()) {
472
+ if (0 === $('#your-profile #pass1').next('span.error').length) {
473
+ $('<span class="error">' + lp_profile_translation.msg_field_is_required + '</span>').insertAfter($('#your-profile #pass1'));
474
+ }
475
+ check_form = false;
476
+ if (!check_focus) {
477
+ $('#your-profile #pass1').focus();
478
+ check_focus = true;
479
+ }
480
+ } else {
481
+ $('#your-profile #pass1').next('span.error').remove();
482
+ }
483
+
484
+ if ('' === $('#your-profile #pass2').val()) {
485
+ if (0 === $('#your-profile #pass2').next('span.error').length) {
486
+ $('<span class="error">' + lp_profile_translation.msg_field_is_required + '</span>').insertAfter($('#your-profile #pass2'));
487
+ }
488
+ check_form = false;
489
+ if (!check_focus) {
490
+ $('#your-profile #pass2').focus();
491
+ check_focus = true;
492
+ }
493
+ } else {
494
+ $(this.pass2).next('span.error').remove();
495
+ }
496
+ }
497
+ if (check_form) {
498
+ // $('#learn-press-user-profile-edit-form form#your-profile').submit();
499
+ var datas = $('#learn-press-user-profile-edit-form form#your-profile').serializeArray();
500
+ $.ajax({
501
+ url : LP.getUrl(),
502
+ dataType : 'html',
503
+ data : datas,
504
+ type : 'post',
505
+ beforeSend: function () {
506
+ LP.blockContent();
507
+ },
508
+ success : function (response) {
509
+ response = LP.parseJSON(response);
510
+ $('#your-profile #pass0, #your-profile #pass1, #your-profile #pass2').val('');
511
+ $('#user_profile_password_form').slideUp();
512
+ LP.unblockContent();
513
+ $('body, html').css('overflow', 'visible');
514
+ $('.user-profile-picture.info-field .learn-press-message').remove();
515
+ $('.user-profile-picture.info-field').prepend(response.message);
516
+ $('html, body').animate({
517
+ scrollTop: $('.user-profile-picture.info-field .learn-press-message').offset().top - 100
518
+ }, 500);
519
+ }
520
+ });
521
+ }
522
+ });
523
+
524
+ $('#learn-press-user-profile-edit-form #your-profile input#nickname').on('change', function () {
525
+ if ('' === $(this).val()) {
526
+ if (0 === $(this).next('span.error').length) {
527
+ ;
528
+ $('<span class="error">' + lp_profile_translation.msg_field_is_required + '</span>').insertAfter($(this));
529
+ }
530
+ } else {
531
+ $(this).next('span.error').remove();
532
+ }
533
+ });
534
+
535
+ $('#learn-press-user-profile-edit-form #your-profile input#pass1').on('change', function () {
536
+
537
+ });
538
+
539
+ $('#learn-press-user-profile-edit-form #your-profile input#pass2').on('keyup', function () {
540
+ var pass1 = $('#your-profile input#pass1').val();
541
+ if (pass1 !== $(this).val()) {
542
+ if (0 === $(this).next('span.error').length) {
543
+ ;
544
+ $('<span class="error">' + lp_profile_translation.confim_pass_not_match + '</span>').insertAfter($(this));
545
+ }
546
+ } else {
547
+ $(this).next('span.error').remove();
548
+ }
549
+ });
550
+
551
+ });
552
  })(jQuery);
assets/js/frontend/single-course.js CHANGED
@@ -44,13 +44,6 @@ if (typeof LearnPress === 'undefined') {
44
  },
45
  _changeCurrent : function (m) {
46
 
47
- },
48
- get : function () {
49
- var val = Course_Item.__super__.get.apply(this, arguments);
50
- if (arguments[0] == 'url') {
51
- val = LP_Course_Params.root_url + val;
52
- }
53
- return val;
54
  },
55
  request : function (args) {
56
  var that = this;
@@ -301,43 +294,24 @@ if (typeof LearnPress === 'undefined') {
301
  sections = {},
302
  $progress = this.$('.course-progress').find('.number, .percentage-sign'),
303
  $itemProgress = this.$('.items-progress').find('.number, .percentage-sign');
304
-
305
- if ($progress.length == 0) {
306
- return;
307
- }
308
-
309
- $progress[0].childNodes[0].nodeValue = parseInt(data.results);
310
-
311
- this.$('.course-progress .lp-progress-value').width(parseInt(data.results) + '%');
312
  data.items && data.items.forEach(function (item) {
313
- var $item = this.$('.course-item.course-item-' + item.id),
314
- $status = $item.find('.item-status'),
315
- statusClass = ($status[0].className + '').replace(/(item-status-[^\s]*)/g, '').trim();
316
  if (!sections[item.section_id]) {
317
  sections[item.section_id] = [0, 0];
318
  }
319
- if (item.status) {
320
- statusClass += ' item-status-' + item.status;
321
- }
322
  if (item.status === 'completed') {
 
323
  $item.addClass('item-has-status item-completed');
 
324
  } else if (item.status) {
325
  $item.addClass('item-has-status').removeClass('item-completed');
326
  } else {
327
  $item.removeClass('item-has-status').removeClass('item-completed');
328
  }
329
-
330
  if (item.type === 'lp_quiz') {
331
- $item.find('.item-result').html(LP.Hook.applyFilters('item_result_text', item.results));
332
- }
333
- $status[0].className = statusClass;
334
- if ($.inArray(item.status, ['completed', 'failed', 'passed']) != -1) {
335
- sections[item.section_id][1]++;
336
- }
337
- if (item.status && item.status != 'viewed') {
338
- $item.addClass('item-has-result');
339
- } else {
340
- $item.removeClass('item-has-result');
341
  }
342
  sections[item.section_id][0]++;
343
  }, this);
@@ -348,18 +322,11 @@ if (typeof LearnPress === 'undefined') {
348
  if (!data) {
349
  return;
350
  }
351
- itemsCompleted += data[1];
352
  $section.find('.section-header span.step').html(LP.Hook.applyFilters('section_header_span_text', data[1] + '/' + data[0]));
353
  });
354
  $itemProgress.eq(0).html(data.completed_items_text.replace('%d', itemsCompleted).replace('%d', itemsCount));
355
  var passingCondition = parseInt(this.$('.course-progress .lp-course-progress').data('passing-condition'));
356
- if (data.grade) {
357
- var $grade = this.$('.grade').html(data.grade_html),
358
- gradeClass = $grade[0].className.replace(/passed|failed|in-progress/, '') + ' ' + data.grade;
359
- $grade[0].className = gradeClass;
360
- }
361
  this.$('.button-finish-course').toggleClass('hide-if-js', !(data.results >= passingCondition));
362
-
363
  if (data.setUrl) {
364
  LP.setUrl(data.setUrl);
365
  }
@@ -409,18 +376,11 @@ if (typeof LearnPress === 'undefined') {
409
  that.$('.course-item.item-current .button-load-item').trigger('click', {force: true});
410
  }, 500);
411
  },
412
- _getItemId : function (el) {
413
- var id = el.hasClass('button-load-item') ? el.data('id') : el.find('.button-load-item').data('id');
414
- if (!id) {
415
- id = el.hasClass('lp-label-preview') ? el.closest('.course-item').find('.button-load-item').data('id') : 0;
416
- }
417
- return id;
418
- },
419
  _loadItem : function (e, f) {
420
  e.preventDefault();
421
  var that = this,
422
  $target = $(e.target),
423
- id = this._getItemId($target);
424
  f = f || {force: false};
425
  if (!id || this.itemLoading) {
426
  return;
@@ -726,13 +686,13 @@ if (typeof LearnPress === 'undefined') {
726
  this.remove();
727
 
728
  /*var $root = $(this).removeClass('block-content'),
729
- overflow = $root.attr('overflow');
730
- $root.css('overflow', overflow).removeAttr('overflow');*/
731
  LP.unblockContent();
732
  $('html, body').css('overflow', '');
733
  $(document).off('focusin').trigger('learn_press_popup_course_remove').unbind('learn_press_unblock_content', this.hideScrollBar);
734
  },
735
- hideScrollBar : function () {
736
  $('html, body').each(function () {
737
  var $root = $(this).css('overflow', 'hidden');
738
  })
@@ -752,12 +712,12 @@ if (typeof LearnPress === 'undefined') {
752
  _loadItem : function (e) {
753
  var $iframe = $('<iframe webkitallowfullscreen mozallowfullscreen allowfullscreen />').src($(e.target).attr('href') + '?content-item-only=yes');
754
  this.$('#popup-content-inner').html($iframe);
755
- /*return '';
756
- e.preventDefault();
757
- $.ajax({
758
- url : $(e.target).attr('href'),
759
- success: this._ajaxLoadItemSuccess
760
- });*/
761
  },
762
  _ajaxLoadItemSuccess: function (response) {
763
  this.$('#popup-content-inner').html($(response).contents().find('.lp_course'));
44
  },
45
  _changeCurrent : function (m) {
46
 
 
 
 
 
 
 
 
47
  },
48
  request : function (args) {
49
  var that = this;
294
  sections = {},
295
  $progress = this.$('.course-progress').find('.number, .percentage-sign'),
296
  $itemProgress = this.$('.items-progress').find('.number, .percentage-sign');
297
+ $progress.eq(0).html(parseInt(data.results));
298
+ this.$('.lp-progress-value').width(parseInt(data.results) + '%');
 
 
 
 
 
 
299
  data.items && data.items.forEach(function (item) {
300
+ var $item = this.$('.course-item.course-item-' + item.id);
 
 
301
  if (!sections[item.section_id]) {
302
  sections[item.section_id] = [0, 0];
303
  }
 
 
 
304
  if (item.status === 'completed') {
305
+ itemsCompleted++;
306
  $item.addClass('item-has-status item-completed');
307
+ sections[item.section_id][1]++;
308
  } else if (item.status) {
309
  $item.addClass('item-has-status').removeClass('item-completed');
310
  } else {
311
  $item.removeClass('item-has-status').removeClass('item-completed');
312
  }
 
313
  if (item.type === 'lp_quiz') {
314
+ $item.find('.item-result').html(LP.Hook.applyFilters('item_result_text', item.results + '%'));
 
 
 
 
 
 
 
 
 
315
  }
316
  sections[item.section_id][0]++;
317
  }, this);
322
  if (!data) {
323
  return;
324
  }
 
325
  $section.find('.section-header span.step').html(LP.Hook.applyFilters('section_header_span_text', data[1] + '/' + data[0]));
326
  });
327
  $itemProgress.eq(0).html(data.completed_items_text.replace('%d', itemsCompleted).replace('%d', itemsCount));
328
  var passingCondition = parseInt(this.$('.course-progress .lp-course-progress').data('passing-condition'));
 
 
 
 
 
329
  this.$('.button-finish-course').toggleClass('hide-if-js', !(data.results >= passingCondition));
 
330
  if (data.setUrl) {
331
  LP.setUrl(data.setUrl);
332
  }
376
  that.$('.course-item.item-current .button-load-item').trigger('click', {force: true});
377
  }, 500);
378
  },
 
 
 
 
 
 
 
379
  _loadItem : function (e, f) {
380
  e.preventDefault();
381
  var that = this,
382
  $target = $(e.target),
383
+ id = $target.hasClass('button-load-item') ? $target.data('id') : $target.find('.button-load-item').data('id');
384
  f = f || {force: false};
385
  if (!id || this.itemLoading) {
386
  return;
686
  this.remove();
687
 
688
  /*var $root = $(this).removeClass('block-content'),
689
+ overflow = $root.attr('overflow');
690
+ $root.css('overflow', overflow).removeAttr('overflow');*/
691
  LP.unblockContent();
692
  $('html, body').css('overflow', '');
693
  $(document).off('focusin').trigger('learn_press_popup_course_remove').unbind('learn_press_unblock_content', this.hideScrollBar);
694
  },
695
+ hideScrollBar : function () {
696
  $('html, body').each(function () {
697
  var $root = $(this).css('overflow', 'hidden');
698
  })
712
  _loadItem : function (e) {
713
  var $iframe = $('<iframe webkitallowfullscreen mozallowfullscreen allowfullscreen />').src($(e.target).attr('href') + '?content-item-only=yes');
714
  this.$('#popup-content-inner').html($iframe);
715
+ return '';
716
+ e.preventDefault();
717
+ $.ajax({
718
+ url : $(e.target).attr('href'),
719
+ success: this._ajaxLoadItemSuccess
720
+ });
721
  },
722
  _ajaxLoadItemSuccess: function (response) {
723
  this.$('#popup-content-inner').html($(response).contents().find('.lp_course'));
assets/js/global.js CHANGED
@@ -143,8 +143,6 @@ if (typeof window.LP == 'undefined') {
143
  };
144
  String.prototype.addQueryVar = function (name, value) {
145
  var url = this;
146
- var m = url.split('#');
147
- url = m[0];
148
  if (name.match(/\[/)) {
149
  url += url.match(/\?/) ? '&' : '?';
150
  url += name + '=' + value;
@@ -156,16 +154,14 @@ if (typeof window.LP == 'undefined') {
156
  url += name + '=' + value;
157
  }
158
  }
159
- return url + (m[1] ? '#' + m[1] : '');
160
  };
161
  String.prototype.removeQueryVar = function (name) {
162
  var url = this;
163
- var m = url.split('#');
164
- url = m[0];
165
  name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
166
  var regex = new RegExp("[\\?&]" + name + "([\[][^=]*)?=([^&#]*)", 'g');
167
  url = url.replace(regex, '');
168
- return url + (m[1] ? '#' + m[1] : '');
169
  };
170
 
171
  if ($.isEmptyObject("") == false) {
@@ -557,14 +553,14 @@ if (typeof window.LP == 'undefined') {
557
  },
558
 
559
  parseResponse: function (response, type) {
560
- var m = response.match(/<-- LP_AJAX_START -->(.*)<-- LP_AJAX_END -->/);
561
  if (m) {
562
  response = m[1];
563
  }
564
  return (type || "json") == "json" ? this.parseJSON(response) : response;
565
  },
566
  parseJSON : function (data) {
567
- var m = data.match(/<-- LP_AJAX_START -->(.*)<-- LP_AJAX_END -->/);
568
  try {
569
  if (m) {
570
  data = $.parseJSON(m[1]);
@@ -572,6 +568,7 @@ if (typeof window.LP == 'undefined') {
572
  data = $.parseJSON(data);
573
  }
574
  } catch (e) {
 
575
  data = {};
576
  }
577
  return data;
@@ -620,21 +617,21 @@ if (typeof window.LP == 'undefined') {
620
  });
621
  },
622
 
623
- funcArgs2Array: function (args) {
624
  var arr = [];
625
  for (var i = 0; i < args.length; i++) {
626
  arr.push(args[i]);
627
  }
628
  return arr;
629
  },
630
- addFilter : function (action, callback) {
631
  var $doc = $(document),
632
  event = 'LP.' + action;
633
  $doc.on(event, callback);
634
  LP.log($doc.data('events'));
635
  return this;
636
  },
637
- applyFilters : function () {
638
  var $doc = $(document),
639
  action = arguments[0],
640
  args = this.funcArgs2Array(arguments);
@@ -644,10 +641,10 @@ if (typeof window.LP == 'undefined') {
644
  }
645
  return args[1];
646
  },
647
- addAction : function (action, callback) {
648
  return this.addFilter(action, callback);
649
  },
650
- doAction : function () {
651
  var $doc = $(document),
652
  action = arguments[0],
653
  args = this.funcArgs2Array(arguments);
@@ -656,7 +653,7 @@ if (typeof window.LP == 'undefined') {
656
  $doc.trigger.apply($doc, args);
657
  }
658
  },
659
- toElement : function (element, args) {
660
  if ($(element).length == 0) {
661
  return;
662
  }
@@ -673,7 +670,7 @@ if (typeof window.LP == 'undefined') {
673
  scrollTop: $(element).offset().top - args.offset
674
  }, args.duration, args.callback);
675
  },
676
- uniqueId : function (prefix, more_entropy) {
677
  if (typeof prefix === 'undefined') {
678
  prefix = '';
679
  }
@@ -715,21 +712,21 @@ if (typeof window.LP == 'undefined') {
715
 
716
  return retId;
717
  },
718
- log : function () {
719
  //if (typeof LEARN_PRESS_DEBUG != 'undefined' && LEARN_PRESS_DEBUG && console) {
720
  for (var i = 0, n = arguments.length; i < n; i++) {
721
  console.log(arguments[i]);
722
  }
723
  //}
724
  },
725
- blockContent : function () {
726
  if ($('#learn-press-block-content').length == 0) {
727
  $(LP.template('learn-press-template-block-content', {})).appendTo($('body'));
728
  }
729
  LP.hideMainScrollbar().addClass('block-content');
730
  $(document).trigger('learn_press_block_content');
731
  },
732
- unblockContent: function () {
733
  setTimeout(function () {
734
  LP.showMainScrollbar().removeClass('block-content');
735
  $(document).trigger('learn_press_unblock_content');
@@ -759,7 +756,7 @@ if (typeof window.LP == 'undefined') {
759
  });
760
  return $el;
761
  },
762
- template : _.memoize(function (id, data) {
763
  var compiled,
764
  options = {
765
  evaluate : /<#([\s\S]+?)#>/g,
@@ -776,7 +773,7 @@ if (typeof window.LP == 'undefined') {
776
  }, function (a, b) {
777
  return a + '-' + JSON.stringify(b);
778
  }),
779
- alert : function (localize, callback) {
780
  var title = '',
781
  message = '';
782
  if (typeof localize == 'string') {
@@ -795,7 +792,7 @@ if (typeof window.LP == 'undefined') {
795
  });
796
  this._on_alert_show();
797
  },
798
- confirm : function (localize, callback) {
799
  var title = '',
800
  message = '';
801
 
@@ -816,7 +813,7 @@ if (typeof window.LP == 'undefined') {
816
  this._on_alert_show();
817
 
818
  },
819
- _on_alert_show: function () {
820
  var $container = $('#popup_container'),
821
  $placeholder = $('<span id="popup_container_placeholder" />').insertAfter($container).data('xxx', $container);
822
  $container.stop().css('top', '-=50').css('opacity', '0').animate({
@@ -824,7 +821,7 @@ if (typeof window.LP == 'undefined') {
824
  opacity: 1
825
  }, 250);
826
  },
827
- _on_alert_hide: function () {
828
  var $holder = $("#popup_container_placeholder"),
829
  $container = $holder.data('xxx');
830
  if ($container) {
@@ -838,7 +835,7 @@ if (typeof window.LP == 'undefined') {
838
  $(this).remove();
839
  });
840
  },
841
- sendMessage : function (data, object, targetOrigin, transfer) {
842
  if ($.isPlainObject(data)) {
843
  data = JSON.stringify(data);
844
  }
@@ -846,7 +843,7 @@ if (typeof window.LP == 'undefined') {
846
  targetOrigin = targetOrigin || '*';
847
  object.postMessage(data, targetOrigin, transfer);
848
  },
849
- receiveMessage: function (event, b) {
850
  var target = event.origin || event.originalEvent.origin,
851
  data = event.data || event.originalEvent.data || '';
852
  if (typeof data === 'string' || data instanceof String) {
143
  };
144
  String.prototype.addQueryVar = function (name, value) {
145
  var url = this;
 
 
146
  if (name.match(/\[/)) {
147
  url += url.match(/\?/) ? '&' : '?';
148
  url += name + '=' + value;
154
  url += name + '=' + value;
155
  }
156
  }
157
+ return url;
158
  };
159
  String.prototype.removeQueryVar = function (name) {
160
  var url = this;
 
 
161
  name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
162
  var regex = new RegExp("[\\?&]" + name + "([\[][^=]*)?=([^&#]*)", 'g');
163
  url = url.replace(regex, '');
164
+ return url;
165
  };
166
 
167
  if ($.isEmptyObject("") == false) {
553
  },
554
 
555
  parseResponse: function (response, type) {
556
+ var m = response.match(/<!-- LP_AJAX_START -->(.*)<!-- LP_AJAX_END -->/);
557
  if (m) {
558
  response = m[1];
559
  }
560
  return (type || "json") == "json" ? this.parseJSON(response) : response;
561
  },
562
  parseJSON : function (data) {
563
+ var m = data.match(/<!-- LP_AJAX_START -->(.*)<!-- LP_AJAX_END -->/);
564
  try {
565
  if (m) {
566
  data = $.parseJSON(m[1]);
568
  data = $.parseJSON(data);
569
  }
570
  } catch (e) {
571
+ LP.log(e);
572
  data = {};
573
  }
574
  return data;
617
  });
618
  },
619
 
620
+ funcArgs2Array : function (args) {
621
  var arr = [];
622
  for (var i = 0; i < args.length; i++) {
623
  arr.push(args[i]);
624
  }
625
  return arr;
626
  },
627
+ addFilter : function (action, callback) {
628
  var $doc = $(document),
629
  event = 'LP.' + action;
630
  $doc.on(event, callback);
631
  LP.log($doc.data('events'));
632
  return this;
633
  },
634
+ applyFilters : function () {
635
  var $doc = $(document),
636
  action = arguments[0],
637
  args = this.funcArgs2Array(arguments);
641
  }
642
  return args[1];
643
  },
644
+ addAction : function (action, callback) {
645
  return this.addFilter(action, callback);
646
  },
647
+ doAction : function () {
648
  var $doc = $(document),
649
  action = arguments[0],
650
  args = this.funcArgs2Array(arguments);
653
  $doc.trigger.apply($doc, args);
654
  }
655
  },
656
+ toElement : function (element, args) {
657
  if ($(element).length == 0) {
658
  return;
659
  }
670
  scrollTop: $(element).offset().top - args.offset
671
  }, args.duration, args.callback);
672
  },
673
+ uniqueId : function (prefix, more_entropy) {
674
  if (typeof prefix === 'undefined') {
675
  prefix = '';
676
  }
712
 
713
  return retId;
714
  },
715
+ log : function () {
716
  //if (typeof LEARN_PRESS_DEBUG != 'undefined' && LEARN_PRESS_DEBUG && console) {
717
  for (var i = 0, n = arguments.length; i < n; i++) {
718
  console.log(arguments[i]);
719
  }
720
  //}
721
  },
722
+ blockContent : function () {
723
  if ($('#learn-press-block-content').length == 0) {
724
  $(LP.template('learn-press-template-block-content', {})).appendTo($('body'));
725
  }
726
  LP.hideMainScrollbar().addClass('block-content');
727
  $(document).trigger('learn_press_block_content');
728
  },
729
+ unblockContent : function () {
730
  setTimeout(function () {
731
  LP.showMainScrollbar().removeClass('block-content');
732
  $(document).trigger('learn_press_unblock_content');
756
  });
757
  return $el;
758
  },
759
+ template : _.memoize(function (id, data) {
760
  var compiled,
761
  options = {
762
  evaluate : /<#([\s\S]+?)#>/g,
773
  }, function (a, b) {
774
  return a + '-' + JSON.stringify(b);
775
  }),
776
+ alert : function (localize, callback) {
777
  var title = '',
778
  message = '';
779
  if (typeof localize == 'string') {
792
  });
793
  this._on_alert_show();
794
  },
795
+ confirm : function (localize, callback) {
796
  var title = '',
797
  message = '';
798
 
813
  this._on_alert_show();
814
 
815
  },
816
+ _on_alert_show : function () {
817
  var $container = $('#popup_container'),
818
  $placeholder = $('<span id="popup_container_placeholder" />').insertAfter($container).data('xxx', $container);
819
  $container.stop().css('top', '-=50').css('opacity', '0').animate({
821
  opacity: 1
822
  }, 250);
823
  },
824
+ _on_alert_hide : function () {
825
  var $holder = $("#popup_container_placeholder"),
826
  $container = $holder.data('xxx');
827
  if ($container) {
835
  $(this).remove();
836
  });
837
  },
838
+ sendMessage : function (data, object, targetOrigin, transfer) {
839
  if ($.isPlainObject(data)) {
840
  data = JSON.stringify(data);
841
  }
843
  targetOrigin = targetOrigin || '*';
844
  object.postMessage(data, targetOrigin, transfer);
845
  },
846
+ receiveMessage : function (event, b) {
847
  var target = event.origin || event.originalEvent.origin,
848
  data = event.data || event.originalEvent.data || '';
849
  if (typeof data === 'string' || data instanceof String) {
assets/js/global.min.js CHANGED
@@ -395,7 +395,7 @@ if (typeof window.LP == "undefined") {
395
  }
396
  window.location.href = url
397
  }, parseJSON : function (data) {
398
- var m = data.match(/<-- LP_AJAX_START -->(.*)<-- LP_AJAX_END -->/);
399
  try {
400
  if (m) {
401
  data = $.parseJSON(m[1])
@@ -408,7 +408,7 @@ if (typeof window.LP == "undefined") {
408
  }
409
  return data
410
  }, parseResponse : function (response, type) {
411
- var m = response.match(/<-- LP_AJAX_START -->(.*)<-- LP_AJAX_END -->/);
412
  if (m) {
413
  response = m[1]
414
  }
395
  }
396
  window.location.href = url
397
  }, parseJSON : function (data) {
398
+ var m = data.match(/<!-- LP_AJAX_START -->(.*)<!-- LP_AJAX_END -->/);
399
  try {
400
  if (m) {
401
  data = $.parseJSON(m[1])
408
  }
409
  return data
410
  }, parseResponse : function (response, type) {
411
+ var m = response.match(/<!-- LP_AJAX_START -->(.*)<!-- LP_AJAX_END -->/);
412
  if (m) {
413
  response = m[1]
414
  }
inc/admin/class-lp-admin-ajax.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
 
3
- if ( !defined( 'ABSPATH' ) ) {
4
  exit; // Exit if accessed directly
5
  }
6
- if ( !class_exists( 'LP_Admin_Ajax' ) ) {
7
 
8
  /**
9
  * Class LP_Admin_Ajax
@@ -12,7 +12,7 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
12
  /**
13
  * Add action ajax
14
  */
15
- public static function init() {
16
  $ajaxEvents = array(
17
  'create_page' => false,
18
  'add_quiz_question' => false,
@@ -74,20 +74,20 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
74
  do_action( 'learn_press_admin_ajax_load', __CLASS__ );
75
  }
76
 
77
- public static function load_chart() {
78
- if ( !class_exists( '' ) ) {
79
  require_once LP_PLUGIN_PATH . '/inc/admin/sub-menus/statistics.php';
80
  }
81
  LP_Admin_Submenu_Statistic::instance()->load_chart();
82
  }
83
 
84
- public static function search_course() {
85
  global $wpdb;
86
  $sql = "SELECT ID id, post_title text "
87
- . " FROM {$wpdb->posts} "
88
- . " WHERE post_type='lp_course' "
89
- . " AND post_status in ('publish') "
90
- . " AND post_title like %s";
91
  if ( current_user_can( LP_TEACHER_ROLE ) ) {
92
  $user_id = learn_press_get_current_user_id();
93
  $sql .= " AND post_author=" . intval( $user_id ) . " ";
@@ -100,13 +100,13 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
100
  exit();
101
  }
102
 
103
- public static function search_course_category() {
104
  global $wpdb;
105
  $sql = "SELECT `t`.`term_id` as `id`, "
106
- . " `t`.`name` `text` "
107
- . " FROM {$wpdb->terms} t "
108
- . " INNER JOIN {$wpdb->term_taxonomy} tt ON t.term_id = tt.term_id AND taxonomy='course_category' "
109
- . " WHERE `t`.`name` LIKE %s";
110
  $s = '%' . filter_input( INPUT_GET, 'q' ) . '%';
111
  $query = $wpdb->prepare( $sql, $s );
112
  $items = $wpdb->get_results( $query );
@@ -115,7 +115,7 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
115
  exit();
116
  }
117
 
118
- public static function remove_course_items() {
119
  $id = learn_press_get_request( 'id' );
120
  if ( $id ) {
121
  global $wpdb;
@@ -135,8 +135,8 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
135
  die();
136
  }
137
 
138
- public static function search_users() {
139
- if ( !current_user_can( 'edit_lp_orders' ) ) {
140
  die( - 1 );
141
  }
142
 
@@ -161,7 +161,7 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
161
 
162
  $customers = $customers_query->get_results();
163
 
164
- if ( !empty( $customers ) ) {
165
  foreach ( $customers as $customer ) {
166
  $found_customers[] = array(
167
  'label' => $customer->display_name . ' (#' . $customer->ID . ' &ndash; ' . sanitize_email( $customer->user_email ) . ')',
@@ -174,7 +174,7 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
174
  die();
175
  }
176
 
177
- public static function json_search_customer_name( $query ) {
178
  global $wpdb;
179
 
180
  $term = stripslashes( $_GET['term'] );
@@ -188,7 +188,7 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
188
  $query->query_where .= $wpdb->prepare( " OR user_name.meta_value LIKE %s ", '%' . $term . '%' );
189
  }
190
 
191
- public static function dismiss_notice() {
192
  $context = learn_press_get_request( 'context' );
193
  $transient = learn_press_get_request( 'transient' );
194
 
@@ -202,7 +202,7 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
202
  die();
203
  }
204
 
205
- public static function _modal_search_items_not_found( $message, $type ) {
206
  switch ( $type ) {
207
  case 'lp_lesson':
208
  $message = __( 'There are no available lessons for this course, please use ', 'learnpress' );
@@ -221,62 +221,50 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
221
  return $message;
222
  }
223
 
224
- /**
225
- * Filter to exclude the items has already added to it's parent.
226
- * Each item only use one time
227
- *
228
- * @param $exclude
229
- * @param $type
230
- * @param string $context
231
- * @param null $context_id
232
- *
233
- * @return array
234
- */
235
- public static function _modal_search_items_exclude( $exclude, $type, $context = '', $context_id = null ) {
236
  global $wpdb;
237
- $used_items = array();
 
238
  switch ( $type ) {
239
  case 'lp_lesson':
240
  case 'lp_quiz':
241
- $query = $wpdb->prepare( "
242
  SELECT item_id
243
- FROM {$wpdb->prefix}learnpress_section_items si
244
- INNER JOIN {$wpdb->prefix}learnpress_sections s ON s.section_id = si.section_id
245
- INNER JOIN {$wpdb->posts} p ON p.ID = s.section_course_id
246
  WHERE %d
247
- AND p.post_type = %s
248
- ", 1, LP_COURSE_CPT );
249
- $used_items = $wpdb->get_col( $query );
 
 
250
  break;
251
  case 'lp_question':
252
- $query = $wpdb->prepare( "
253
  SELECT question_id
254
  FROM {$wpdb->prefix}learnpress_quiz_questions
255
- INNER JOIN {$wpdb->posts} q ON q.ID = qq.quiz_id
256
  WHERE %d
257
- AND q.post_type = %s
258
- ", 1, LP_QUIZ_CPT );
259
- $used_items = $wpdb->get_col( $query );
260
  break;
261
 
262
  }
263
- if ( $used_items && $exclude ) {
264
- $exclude = array_merge( $exclude, $used_items );
265
- } else if ( $used_items ) {
266
- $exclude = $used_items;
267
  }
268
 
269
- return array_unique( $exclude );
270
  }
271
 
272
- public static function add_item_to_section() {
273
  global $wpdb;
274
  $section = learn_press_get_request( 'section' );
275
- if ( !$section ) {
276
  wp_die( __( 'Error', 'learnpress' ) );
277
  }
278
- $items = (array) learn_press_get_request( 'item' );
279
- if ( !$items ) {
280
  $max_order = $wpdb->get_var( $wpdb->prepare( "SELECT max() FROM {$wpdb}learnpress_section_items WHERE section_id = %d", $section ) );
281
  foreach ( $items as $item ) {
282
 
@@ -284,20 +272,20 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
284
  }
285
  }
286
 
287
- public static function modal_search_items() {
288
  global $wpdb;
289
 
290
  $user = learn_press_get_current_user();
291
- $term = (string) ( stripslashes( learn_press_get_request( 'term' ) ) );
292
- $type = (string) ( stripslashes( learn_press_get_request( 'type' ) ) );
293
- $context = (string) ( stripslashes( learn_press_get_request( 'context' ) ) );
294
- $context_id = (string) ( stripslashes( learn_press_get_request( 'context_id' ) ) );
295
  $exclude = array();
296
 
297
- if ( !empty( $_GET['exclude'] ) ) {
298
  $exclude = array_map( 'intval', $_GET['exclude'] );
299
  }
300
- $exclude = array_unique( (array) apply_filters( 'learn_press_modal_search_items_exclude', $exclude, $type, $context, $context_id ) );
301
  $exclude = array_map( 'intval', $exclude );
302
  $args = array(
303
  'post_type' => array( $type ),
@@ -307,7 +295,7 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
307
  'orderby' => 'parent title',
308
  'exclude' => $exclude
309
  );
310
- if ( !$user->is_admin() ) {
311
  $args['author'] = $user->id;
312
  }
313
 
@@ -338,10 +326,10 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
338
  $posts = get_posts( $args );
339
  $found_items = array();
340
 
341
- if ( !empty( $posts ) ) {
342
  foreach ( $posts as $post ) {
343
- $found_items[$post->ID] = $post;
344
- $found_items[$post->ID]->post_title = !empty( $post->post_title ) ? $post->post_title : sprintf( '(%s)', __( 'Untitled', 'learnpress' ) );
345
  }
346
  }
347
 
@@ -377,11 +365,11 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
377
  learn_press_send_json( $response );
378
  }
379
 
380
- public static function remove_quiz_question() {
381
  global $wpdb;
382
  $quiz_id = learn_press_get_request( 'quiz_id' );
383
  $question_id = learn_press_get_request( 'question_id' );
384
- if ( !wp_verify_nonce( learn_press_get_request( 'remove-nonce' ), 'remove_quiz_question' ) ) {
385
  wp_die( __( 'Error', 'learnpress' ) );
386
  }
387
  $query = $wpdb->prepare( "
@@ -395,28 +383,28 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
395
  $user_id = get_current_user_id();
396
  $type = get_post_meta( $question_id, '_lp_type', true );
397
  if ( $type ) {
398
- $question_types = get_user_meta( $user_id, '_learn_press_memorize_question_types', true );
399
- $question_types = !$question_types ? array() : $question_types;
400
- $counter = !empty ( $question_types[$type] ) && $question_types[$type] ? absint( $question_types[$type] ) : 0;
401
- $question_types[$type] = $counter ? $counter -- : 0;
402
  update_user_meta( $user_id, '_learn_press_memorize_question_types', $question_types );
403
  }
404
  // end trigger change user memorize question types
405
  die();
406
  }
407
 
408
- public static function search_questions() {
409
  global $wpdb;
410
 
411
  $quiz_id = learn_press_get_request( 'quiz_id' );
412
  $user = learn_press_get_current_user();
413
- if ( !$user->is_admin() && get_post_field( 'post_author', $quiz_id ) != get_current_user_id() ) {
414
  wp_die( __( 'You have no permission to access this section.', 'learnpress' ) );
415
  }
416
- $term = (string) ( stripslashes( learn_press_get_request( 'term' ) ) );
417
  $exclude = array();
418
 
419
- if ( !empty( $_GET['exclude'] ) ) {
420
  $exclude = array_map( 'intval', $_GET['exclude'] );
421
  }
422
 
@@ -440,7 +428,7 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
440
  'orderby' => 'parent title',
441
  'exclude' => $exclude
442
  );
443
- if ( !$user->is_admin() ) {
444
  $args['author'] = $user->id;
445
  }
446
  if ( $term ) {
@@ -449,9 +437,9 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
449
  $posts = get_posts( $args );
450
  $found_questions = array();
451
 
452
- if ( !empty( $posts ) ) {
453
  foreach ( $posts as $post ) {
454
- $found_questions[$post->ID] = !empty( $post->post_title ) ? $post->post_title : sprintf( '(%s)', __( 'Untitled', 'learnpress' ) );
455
  }
456
  }
457
 
@@ -479,7 +467,7 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
479
  learn_press_send_json( $response );
480
  }
481
 
482
- public static function plugin_action() {
483
  $url = learn_press_get_request( 'url' );
484
  ob_start();
485
  wp_remote_get( $url );
@@ -491,28 +479,28 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
491
  /**
492
  * Remove an item from order
493
  */
494
- public static function remove_order_item() {
495
  // ensure that user has permission
496
- if ( !current_user_can( 'edit_lp_orders' ) ) {
497
  die( __( 'Permission denied', 'learnpress' ) );
498
  }
499
 
500
  // verify nonce
501
  $nonce = learn_press_get_request( 'remove_nonce' );
502
- if ( !wp_verify_nonce( $nonce, 'remove_order_item' ) ) {
503
  die( __( 'Check nonce failed', 'learnpress' ) );
504
  }
505
 
506
  // validate order
507
  $order_id = learn_press_get_request( 'order_id' );
508
- if ( !is_numeric( $order_id ) || get_post_type( $order_id ) != 'lp_order' ) {
509
  die( __( 'Order invalid', 'learnpress' ) );
510
  }
511
 
512
  // validate item
513
  $item_id = learn_press_get_request( 'item_id' );
514
  $post = get_post( learn_press_get_order_item_meta( $item_id, '_course_id' ) );
515
- if ( !$post || ( 'lp_course' !== $post->post_type ) ) {
516
  die( __( 'Course invalid', 'learnpress' ) );
517
  }
518
 
@@ -535,10 +523,10 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
535
  /**
536
  * Add new course to order
537
  */
538
- public static function add_item_to_order() {
539
 
540
  // ensure that user has permission
541
- if ( !current_user_can( 'edit_lp_orders' ) ) {
542
  die( __( 'Permission denied', 'learnpress' ) );
543
  }
544
 
@@ -550,7 +538,7 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
550
 
551
  // validate order
552
  $order_id = learn_press_get_request( 'order_id' );
553
- if ( !is_numeric( $order_id ) || get_post_type( $order_id ) != 'lp_order' ) {
554
  die( __( 'Order invalid', 'learnpress' ) );
555
  }
556
 
@@ -564,7 +552,7 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
564
  // exit(''.__LINE__);
565
  foreach ( $item_ids as $item_id ):
566
  $post = get_post( $item_id );
567
- if ( !$post || ( 'lp_course' !== $post->post_type ) ) {
568
  continue;
569
  // die( __( 'Course invalid', 'learnpress' ) );
570
  }
@@ -616,9 +604,9 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
616
  );
617
  }
618
 
619
- public static function search_courses() {
620
  $nonce = learn_press_get_request( 'nonce' );
621
- if ( !wp_verify_nonce( $nonce, 'search_item_term' ) ) {
622
  LP_Debug::exception( __( 'Verify nonce failed', 'learnpress' ) );
623
  }
624
 
@@ -632,9 +620,9 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
632
  )
633
  );
634
  $found_courses = array();
635
- if ( !empty( $posts ) ) {
636
  foreach ( $posts as $post ) {
637
- $found_courses[$post] = array(
638
  'title' => get_the_title( $post ),
639
  'permalink' => get_the_permalink( $post )
640
  );
@@ -646,7 +634,7 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
646
  learn_press_send_json( $found_courses );
647
  }
648
 
649
- public static function remove_course_section() {
650
  $id = learn_press_get_request( 'id' );
651
  if ( $id ) {
652
  global $wpdb;
@@ -666,7 +654,7 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
666
  die();
667
  }
668
 
669
- public static function toggle_lesson_preview() {
670
  $id = learn_press_get_request( 'lesson_id' );
671
  if ( get_post_type( $id ) == 'lp_lesson' && wp_verify_nonce( learn_press_get_request( 'nonce' ), 'learn-press-toggle-lesson-preview' ) ) {
672
  $previewable = learn_press_get_request( 'previewable' );
@@ -678,7 +666,7 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
678
  die();
679
  }
680
 
681
- public static function add_new_item() {
682
  $post_type = learn_press_get_request( 'type' );
683
  $post_title = learn_press_get_request( 'name' );
684
  $response = array();
@@ -696,7 +684,7 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
696
  learn_press_send_json( $response );
697
  }
698
 
699
- public static function quick_add_item() {
700
  $post_type = learn_press_get_request( 'type' );
701
  $post_title = learn_press_get_request( 'name' );
702
  $response = array();
@@ -718,7 +706,7 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
718
  learn_press_send_json( $response );
719
  }
720
 
721
- public static function update_editor_hidden() {
722
  if ( $id = learn_press_get_request( 'course_id' ) ) {
723
  if ( learn_press_get_request( 'is_hidden' ) ) {
724
  update_post_meta( $id, '_lp_editor_hidden', 'yes' );
@@ -729,14 +717,14 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
729
  learn_press_send_json( $_POST );
730
  }
731
 
732
- public static function update_quiz_question_state() {
733
  $hidden = learn_press_get_request( 'hidden' );
734
  $post = learn_press_get_request( 'quiz_id' );
735
  update_post_meta( $post, '_admin_hidden_questions', $hidden );
736
  die();
737
  }
738
 
739
- public static function update_curriculum_section_state() {
740
  $hidden = learn_press_get_request( 'hidden' );
741
  $post = learn_press_get_request( 'course_id' );
742
  update_post_meta( $post, '_admin_hidden_sections', $hidden );
@@ -746,8 +734,8 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
746
  /**
747
  * Create a new page with the title passed via $_REQUEST
748
  */
749
- public static function create_page() {
750
- $page_name = !empty( $_REQUEST['page_name'] ) ? $_REQUEST['page_name'] : '';
751
  $response = array();
752
  if ( $page_name ) {
753
  $args = array(
@@ -774,7 +762,7 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
774
  die();
775
  }
776
 
777
- public static function add_quiz_question() {
778
  global $post;
779
  $id = learn_press_get_request( 'id' );
780
  $quiz_id = learn_press_get_request( 'quiz_id' );
@@ -786,14 +774,14 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
786
  );
787
  $post = get_post( $quiz_id );
788
  setup_postdata( $post );
789
- if ( !$id ) {
790
  $args_item = array(
791
  'post_title' => $name,
792
  'post_type' => LP_QUESTION_CPT,
793
  'post_status' => 'publish'
794
  );
795
  $args_item = apply_filters( 'learnpress_quiz_insert_item_args', $args_item, $quiz_id );
796
- $id = wp_insert_post( $args_item );
797
  if ( $id ) {
798
  add_post_meta( $id, '_lp_type', $type );
799
  }
@@ -817,10 +805,10 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
817
  $response['html'] = ob_get_clean();
818
 
819
  // trigger change user memorize question types
820
- $question_types = get_user_meta( $user_id, '_learn_press_memorize_question_types', true );
821
- $question_types = !$question_types ? array() : $question_types;
822
- $type = get_post_meta( $id, '_lp_type', true );
823
- $question_types[$type] = !empty ( $question_types[$type] ) ? absint( $question_types[$type] ) + 1 : 1;
824
  update_user_meta( $user_id, '_learn_press_memorize_question_types', $question_types );
825
  // end trigger change user memorize question types
826
  }
@@ -828,7 +816,7 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
828
  die();
829
  }
830
 
831
- public static function convert_question_type() {
832
  if ( ( $from = learn_press_get_request( 'from' ) ) && ( $to = learn_press_get_request( 'to' ) ) && $question_id = learn_press_get_request( 'question_id' ) ) {
833
  $data = array();
834
  parse_str( $_POST['data'], $data );
@@ -837,10 +825,10 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
837
  $question = LP_Question_Factory::get_question( $question_id, array( 'type' => $to ) );
838
 
839
  // trigger change user memorize question types
840
- $user_id = get_current_user_id();
841
- $question_types = get_user_meta( $user_id, '_learn_press_memorize_question_types', true );
842
- $question_types[$from] = !empty( $question_types[$from] ) && $question_types[$from] ? absint( $question_types[$from] ) - 1 : 0;
843
- $question_types[$to] = !empty( $question_types[$to] ) && $question_types[$to] ? absint( $question_types[$to] ) + 1 : 1;
844
  update_user_meta( $user_id, '_learn_press_memorize_question_types', $question_types );
845
  // end trigger change user memorize question types
846
  if ( 'auto-draft' === $question->post->post_status ) {
@@ -864,8 +852,8 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
864
  /**
865
  * Install sample data or dismiss the notice depending on user's option
866
  */
867
- public static function install_sample_data() {
868
- $yes = !empty( $_REQUEST['yes'] ) ? $_REQUEST['yes'] : '';
869
  $response = array( 'result' => 'fail' );
870
  $retry_button = sprintf( '<a href="" class="button yes" data-action="yes">%s</a>', __( 'Try again!', 'learnpress' ) );
871
  $dismiss_button = sprintf( '<a href="" class="button disabled no" data-action="no">%s</a>', __( 'Cancel', 'learnpress' ) );
@@ -911,12 +899,12 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
911
  /**
912
  * Activate a bundle of add-ons, if an add-on is not installed then install it first
913
  */
914
- public static function bundle_activate_add_ons() {
915
  global $learn_press_add_ons;
916
  include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api..
917
  $response = array( 'addons' => array() );
918
 
919
- if ( !current_user_can( 'activate_plugins' ) ) {
920
  $response['error'] = __( 'You do not have sufficient permissions to deactivate plugins for this site.', 'learnpress' );
921
  } else {
922
 
@@ -924,7 +912,7 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
924
 
925
  if ( $add_ons ) {
926
  foreach ( $add_ons as $slug ) {
927
- $response['addons'][$slug] = learn_press_install_and_active_add_on( $slug );
928
  }
929
  }
930
  }
@@ -934,30 +922,30 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
934
  /**
935
  * Activate a bundle of add-ons, if an add-on is not installed then install it first
936
  */
937
- public static function bundle_activate_add_on() {
938
  $response = array();
939
  include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api..
940
- if ( !current_user_can( 'activate_plugins' ) ) {
941
  $response['error'] = __( 'You do not have sufficient permissions to deactivate plugins for this site.', 'learnpress' );
942
  } else {
943
- $slug = !empty( $_REQUEST['plugin'] ) ? $_REQUEST['plugin'] : null;
944
- $response[$slug] = learn_press_install_and_active_add_on( $slug );
945
  }
946
  learn_press_send_json( $response );
947
  }
948
 
949
- public static function plugin_install() {
950
- $plugin_name = !empty( $_REQUEST['plugin'] ) ? $_REQUEST['plugin'] : '';
951
  $response = learn_press_install_add_on( $plugin_name );
952
  learn_press_send_json( $response );
953
  die();
954
  }
955
 
956
- public static function update_add_on_status() {
957
- $plugin = !empty( $_REQUEST['plugin'] ) ? $_REQUEST['plugin'] : '';
958
- $t = !empty( $_REQUEST['t'] ) ? $_REQUEST['t'] : '';
959
  $response = array();
960
- if ( !current_user_can( 'activate_plugins' ) ) {
961
  $response['error'] = __( 'You do not have sufficient permissions to deactivate plugins for this site.', 'learnpress' );
962
  }
963
  if ( $plugin && $t ) {
@@ -977,8 +965,8 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
977
  /**
978
  * Output the image to browser with text and params passed via $_GET
979
  */
980
- public static function dummy_image() {
981
- $text = !empty( $_REQUEST['text'] ) ? $_REQUEST['text'] : '';
982
  learn_press_text_image( $text, $_GET );
983
  die();
984
  }
@@ -986,8 +974,8 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
986
  /**
987
  * Get edit|view link of a page
988
  */
989
- public static function get_page_permalink() {
990
- $page_id = !empty( $_REQUEST['page_id'] ) ? $_REQUEST['page_id'] : '';
991
  ?>
992
  <a href="<?php echo get_edit_post_link( $page_id ); ?>" target="_blank"><?php _e( 'Edit Page', 'learnpress' ); ?></a>
993
  <a href="<?php echo get_permalink( $page_id ); ?>" target="_blank"><?php _e( 'View Page', 'learnpress' ); ?></a>
@@ -999,9 +987,9 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
999
  /**
1000
  *
1001
  */
1002
- public function custom_stats() {
1003
- $from = !empty( $_REQUEST['from'] ) ? $_REQUEST['from'] : 0;
1004
- $to = !empty( $_REQUEST['to'] ) ? $_REQUEST['to'] : 0;
1005
  $date_diff = strtotime( $to ) - strtotime( $from );
1006
  if ( $date_diff <= 0 || $from == 0 || $to == 0 ) {
1007
  die();
@@ -1013,7 +1001,7 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
1013
  /**
1014
  * Quick add lesson with only title
1015
  */
1016
- public static function quick_add_lesson() {
1017
 
1018
  $lesson_title = $_POST['lesson_title'];
1019
 
@@ -1043,7 +1031,7 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
1043
  /**
1044
  * Add a new quiz with the title only
1045
  */
1046
- public static function quick_add_quiz() {
1047
  $quiz_title = $_POST['quiz_title'];
1048
 
1049
  $new_quiz = array(
@@ -1069,25 +1057,25 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
1069
  die;
1070
  }
1071
 
1072
- public static function be_teacher() {
1073
  $user_id = get_current_user_id();
1074
  $be_teacher = new WP_User( $user_id );
1075
  $be_teacher->set_role( LP_TEACHER_ROLE );
1076
  die;
1077
  }
1078
 
1079
- public static function ignore_setting_up() {
1080
  update_option( '_lpr_ignore_setting_up', 1, true );
1081
  die;
1082
  }
1083
 
1084
- public static function duplicate_course() {
1085
- if ( empty( $_POST['course_id'] ) || empty( $_POST['_nonce'] ) || !wp_verify_nonce( $_POST['_nonce'], 'lp-duplicate-course' ) ) {
1086
  return;
1087
  }
1088
  global $wpdb;
1089
  $course_id = absint( $_POST['course_id'] );
1090
- $force = !empty( $_POST['content'] ) && $_POST['content'] ? true : false;
1091
 
1092
  $results = array(
1093
  'redirect' => admin_url( 'edit.php?post_type=' . LP_COURSE_CPT )
@@ -1104,8 +1092,8 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
1104
  die();
1105
  }
1106
 
1107
- public static function duplicate_question() {
1108
- if ( empty( $_POST['_nonce'] ) || !wp_verify_nonce( $_POST['_nonce'], 'duplicate-question' ) ) {
1109
  return;
1110
  }
1111
  global $wpdb;
@@ -1114,7 +1102,7 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
1114
  $user_id = learn_press_get_current_user_id();
1115
 
1116
  $new_question_id = learn_press_duplicate_question( $question_id, $quiz_id );
1117
- if ( !is_wp_error( $new_question_id ) ) {
1118
  ob_start();
1119
  $question = LP_Question_Factory::get_question( $new_question_id );
1120
  $post = get_post( $quiz_id );
@@ -1124,10 +1112,10 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
1124
  $response['html'] = ob_get_clean();
1125
 
1126
  // trigger change user memorize question types
1127
- $question_types = get_user_meta( $user_id, '_learn_press_memorize_question_types', true );
1128
- $question_types = !$question_types ? array() : $question_types;
1129
- $type = get_post_meta( $new_question_id, '_lp_type', true );
1130
- $question_types[$type] = !empty ( $question_types[$type] ) ? absint( $question_types[$type] ) + 1 : 1;
1131
  update_user_meta( $user_id, '_learn_press_memorize_question_types', $question_types );
1132
  // end trigger change user memorize question types
1133
  learn_press_send_json( $response );
@@ -1137,11 +1125,11 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
1137
  }
1138
  }
1139
 
1140
- public static function remove_notice_popup() {
1141
 
1142
  if ( isset( $_POST['action'] ) && $_POST['action'] === 'learnpress_remove_notice_popup'
1143
- && isset( $_POST['slug'] ) && !empty( $_POST['slug'] )
1144
- && isset( $_POST['user'] ) && !empty( $_POST['user'] )
1145
  ) {
1146
 
1147
  $slug = 'learnpress_notice_' . $_POST['slug'] . '_' . $_POST['user'];
@@ -1155,4 +1143,5 @@ if ( !class_exists( 'LP_Admin_Ajax' ) ) {
1155
 
1156
  }
1157
  }
1158
- LP_Admin_Ajax::init();
 
1
  <?php
2
 
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
  exit; // Exit if accessed directly
5
  }
6
+ if ( ! class_exists( 'LP_Admin_Ajax' ) ) {
7
 
8
  /**
9
  * Class LP_Admin_Ajax
12
  /**
13
  * Add action ajax
14
  */
15
+ public static function init () {
16
  $ajaxEvents = array(
17
  'create_page' => false,
18
  'add_quiz_question' => false,
74
  do_action( 'learn_press_admin_ajax_load', __CLASS__ );
75
  }
76
 
77
+ public static function load_chart () {
78
+ if ( ! class_exists( '' ) ) {
79
  require_once LP_PLUGIN_PATH . '/inc/admin/sub-menus/statistics.php';
80
  }
81
  LP_Admin_Submenu_Statistic::instance()->load_chart();
82
  }
83
 
84
+ public static function search_course () {
85
  global $wpdb;
86
  $sql = "SELECT ID id, post_title text "
87
+ . " FROM {$wpdb->posts} "
88
+ . " WHERE post_type='lp_course' "
89
+ . " AND post_status in ('publish') "
90
+ . " AND post_title like %s";
91
  if ( current_user_can( LP_TEACHER_ROLE ) ) {
92
  $user_id = learn_press_get_current_user_id();
93
  $sql .= " AND post_author=" . intval( $user_id ) . " ";
100
  exit();
101
  }
102
 
103
+ public static function search_course_category () {
104
  global $wpdb;
105
  $sql = "SELECT `t`.`term_id` as `id`, "
106
+ . " `t`.`name` `text` "
107
+ . " FROM {$wpdb->terms} t "
108
+ . " INNER JOIN {$wpdb->term_taxonomy} tt ON t.term_id = tt.term_id AND taxonomy='course_category' "
109
+ . " WHERE `t`.`name` LIKE %s";
110
  $s = '%' . filter_input( INPUT_GET, 'q' ) . '%';
111
  $query = $wpdb->prepare( $sql, $s );
112
  $items = $wpdb->get_results( $query );
115
  exit();
116
  }
117
 
118
+ public static function remove_course_items () {
119
  $id = learn_press_get_request( 'id' );
120
  if ( $id ) {
121
  global $wpdb;
135
  die();
136
  }
137
 
138
+ public static function search_users () {
139
+ if ( ! current_user_can( 'edit_lp_orders' ) ) {
140
  die( - 1 );
141
  }
142
 
161
 
162
  $customers = $customers_query->get_results();
163
 
164
+ if ( ! empty( $customers ) ) {
165
  foreach ( $customers as $customer ) {
166
  $found_customers[] = array(
167
  'label' => $customer->display_name . ' (#' . $customer->ID . ' &ndash; ' . sanitize_email( $customer->user_email ) . ')',
174
  die();
175
  }
176
 
177
+ public static function json_search_customer_name ( $query ) {
178
  global $wpdb;
179
 
180
  $term = stripslashes( $_GET['term'] );
188
  $query->query_where .= $wpdb->prepare( " OR user_name.meta_value LIKE %s ", '%' . $term . '%' );
189
  }
190
 
191
+ public static function dismiss_notice () {
192
  $context = learn_press_get_request( 'context' );
193
  $transient = learn_press_get_request( 'transient' );
194
 
202
  die();
203
  }
204
 
205
+ public static function _modal_search_items_not_found ( $message, $type ) {
206
  switch ( $type ) {
207
  case 'lp_lesson':
208
  $message = __( 'There are no available lessons for this course, please use ', 'learnpress' );
221
  return $message;
222
  }
223
 
224
+ public static function _modal_search_items_exclude ( $exclude, $type, $context = '', $context_id = null ) {
 
 
 
 
 
 
 
 
 
 
 
225
  global $wpdb;
226
+ $exclude2 = array();
227
+ $user = learn_press_get_current_user();
228
  switch ( $type ) {
229
  case 'lp_lesson':
230
  case 'lp_quiz':
231
+ $query = $wpdb->prepare( "
232
  SELECT item_id
233
+ FROM {$wpdb->prefix}learnpress_section_items
 
 
234
  WHERE %d
235
+ ", 1 );
236
+ $exclude2 = $wpdb->get_col( $query );
237
+ if ( ( $context == 'course' ) && ( get_post_type( $context_id ) == 'lp_course' ) ) {
238
+ $course_author = get_post_field( 'post_author', $context_id );
239
+ }
240
  break;
241
  case 'lp_question':
242
+ $query = $wpdb->prepare( "
243
  SELECT question_id
244
  FROM {$wpdb->prefix}learnpress_quiz_questions
 
245
  WHERE %d
246
+ ", 1 );
247
+ $exclude2 = $wpdb->get_col( $query );
 
248
  break;
249
 
250
  }
251
+ if ( $exclude2 && $exclude ) {
252
+ $exclude = array_merge( $exclude, $exclude2 );
253
+ } else if ( $exclude2 ) {
254
+ $exclude = $exclude2;
255
  }
256
 
257
+ return $exclude;
258
  }
259
 
260
+ public static function add_item_to_section () {
261
  global $wpdb;
262
  $section = learn_press_get_request( 'section' );
263
+ if ( ! $section ) {
264
  wp_die( __( 'Error', 'learnpress' ) );
265
  }
266
+ $items = (array)learn_press_get_request( 'item' );
267
+ if ( ! $items ) {
268
  $max_order = $wpdb->get_var( $wpdb->prepare( "SELECT max() FROM {$wpdb}learnpress_section_items WHERE section_id = %d", $section ) );
269
  foreach ( $items as $item ) {
270
 
272
  }
273
  }
274
 
275
+ public static function modal_search_items () {
276
  global $wpdb;
277
 
278
  $user = learn_press_get_current_user();
279
+ $term = (string)( stripslashes( learn_press_get_request( 'term' ) ) );
280
+ $type = (string)( stripslashes( learn_press_get_request( 'type' ) ) );
281
+ $context = (string)( stripslashes( learn_press_get_request( 'context' ) ) );
282
+ $context_id = (string)( stripslashes( learn_press_get_request( 'context_id' ) ) );
283
  $exclude = array();
284
 
285
+ if ( ! empty( $_GET['exclude'] ) ) {
286
  $exclude = array_map( 'intval', $_GET['exclude'] );
287
  }
288
+ $exclude = array_unique( (array)apply_filters( 'learn_press_modal_search_items_exclude', $exclude, $type, $context, $context_id ) );
289
  $exclude = array_map( 'intval', $exclude );
290
  $args = array(
291
  'post_type' => array( $type ),
295
  'orderby' => 'parent title',
296
  'exclude' => $exclude
297
  );
298
+ if ( ! $user->is_admin() ) {
299
  $args['author'] = $user->id;
300
  }
301
 
326
  $posts = get_posts( $args );
327
  $found_items = array();
328
 
329
+ if ( ! empty( $posts ) ) {
330
  foreach ( $posts as $post ) {
331
+ $found_items[ $post->ID ] = $post;
332
+ $found_items[ $post->ID ]->post_title = ! empty( $post->post_title ) ? $post->post_title : sprintf( '(%s)', __( 'Untitled', 'learnpress' ) );
333
  }
334
  }
335
 
365
  learn_press_send_json( $response );
366
  }
367
 
368
+ public static function remove_quiz_question () {
369
  global $wpdb;
370
  $quiz_id = learn_press_get_request( 'quiz_id' );
371
  $question_id = learn_press_get_request( 'question_id' );
372
+ if ( ! wp_verify_nonce( learn_press_get_request( 'remove-nonce' ), 'remove_quiz_question' ) ) {
373
  wp_die( __( 'Error', 'learnpress' ) );
374
  }
375
  $query = $wpdb->prepare( "
383
  $user_id = get_current_user_id();
384
  $type = get_post_meta( $question_id, '_lp_type', true );
385
  if ( $type ) {
386
+ $question_types = get_user_meta( $user_id, '_learn_press_memorize_question_types', true );
387
+ $question_types = ! $question_types ? array() : $question_types;
388
+ $counter = ! empty ( $question_types[ $type ] ) && $question_types[ $type ] ? absint( $question_types[ $type ] ) : 0;
389
+ $question_types[ $type ] = $counter ? $counter -- : 0;
390
  update_user_meta( $user_id, '_learn_press_memorize_question_types', $question_types );
391
  }
392
  // end trigger change user memorize question types
393
  die();
394
  }
395
 
396
+ public static function search_questions () {
397
  global $wpdb;
398
 
399
  $quiz_id = learn_press_get_request( 'quiz_id' );
400
  $user = learn_press_get_current_user();
401
+ if ( ! $user->is_admin() && get_post_field( 'post_author', $quiz_id ) != get_current_user_id() ) {
402
  wp_die( __( 'You have no permission to access this section.', 'learnpress' ) );
403
  }
404
+ $term = (string)( stripslashes( learn_press_get_request( 'term' ) ) );
405
  $exclude = array();
406
 
407
+ if ( ! empty( $_GET['exclude'] ) ) {
408
  $exclude = array_map( 'intval', $_GET['exclude'] );
409
  }
410
 
428
  'orderby' => 'parent title',
429
  'exclude' => $exclude
430
  );
431
+ if ( ! $user->is_admin() ) {
432
  $args['author'] = $user->id;
433
  }
434
  if ( $term ) {
437
  $posts = get_posts( $args );
438
  $found_questions = array();
439
 
440
+ if ( ! empty( $posts ) ) {
441
  foreach ( $posts as $post ) {
442
+ $found_questions[ $post->ID ] = ! empty( $post->post_title ) ? $post->post_title : sprintf( '(%s)', __( 'Untitled', 'learnpress' ) );
443
  }
444
  }
445
 
467
  learn_press_send_json( $response );
468
  }
469
 
470
+ public static function plugin_action () {
471
  $url = learn_press_get_request( 'url' );
472
  ob_start();
473
  wp_remote_get( $url );
479
  /**
480
  * Remove an item from order
481
  */
482
+ public static function remove_order_item () {
483
  // ensure that user has permission
484
+ if ( ! current_user_can( 'edit_lp_orders' ) ) {
485
  die( __( 'Permission denied', 'learnpress' ) );
486
  }
487
 
488
  // verify nonce
489
  $nonce = learn_press_get_request( 'remove_nonce' );
490
+ if ( ! wp_verify_nonce( $nonce, 'remove_order_item' ) ) {
491
  die( __( 'Check nonce failed', 'learnpress' ) );
492
  }
493
 
494
  // validate order
495
  $order_id = learn_press_get_request( 'order_id' );
496
+ if ( ! is_numeric( $order_id ) || get_post_type( $order_id ) != 'lp_order' ) {
497
  die( __( 'Order invalid', 'learnpress' ) );
498
  }
499
 
500
  // validate item
501
  $item_id = learn_press_get_request( 'item_id' );
502
  $post = get_post( learn_press_get_order_item_meta( $item_id, '_course_id' ) );
503
+ if ( ! $post || ( 'lp_course' !== $post->post_type ) ) {
504
  die( __( 'Course invalid', 'learnpress' ) );
505
  }
506
 
523
  /**
524
  * Add new course to order
525
  */
526
+ public static function add_item_to_order () {
527
 
528
  // ensure that user has permission
529
+ if ( ! current_user_can( 'edit_lp_orders' ) ) {
530
  die( __( 'Permission denied', 'learnpress' ) );
531
  }
532
 
538
 
539
  // validate order
540
  $order_id = learn_press_get_request( 'order_id' );
541
+ if ( ! is_numeric( $order_id ) || get_post_type( $order_id ) != 'lp_order' ) {
542
  die( __( 'Order invalid', 'learnpress' ) );
543
  }
544
 
552
  // exit(''.__LINE__);
553
  foreach ( $item_ids as $item_id ):
554
  $post = get_post( $item_id );
555
+ if ( ! $post || ( 'lp_course' !== $post->post_type ) ) {
556
  continue;
557
  // die( __( 'Course invalid', 'learnpress' ) );
558
  }
604
  );
605
  }
606
 
607
+ public static function search_courses () {
608
  $nonce = learn_press_get_request( 'nonce' );
609
+ if ( ! wp_verify_nonce( $nonce, 'search_item_term' ) ) {
610
  LP_Debug::exception( __( 'Verify nonce failed', 'learnpress' ) );
611
  }
612
 
620
  )
621
  );
622
  $found_courses = array();
623
+ if ( ! empty( $posts ) ) {
624
  foreach ( $posts as $post ) {
625
+ $found_courses[ $post ] = array(
626
  'title' => get_the_title( $post ),
627
  'permalink' => get_the_permalink( $post )
628
  );
634
  learn_press_send_json( $found_courses );
635
  }
636
 
637
+ public static function remove_course_section () {
638
  $id = learn_press_get_request( 'id' );
639
  if ( $id ) {
640
  global $wpdb;
654
  die();
655
  }
656
 
657
+ public static function toggle_lesson_preview () {
658
  $id = learn_press_get_request( 'lesson_id' );
659
  if ( get_post_type( $id ) == 'lp_lesson' && wp_verify_nonce( learn_press_get_request( 'nonce' ), 'learn-press-toggle-lesson-preview' ) ) {
660
  $previewable = learn_press_get_request( 'previewable' );
666
  die();
667
  }
668
 
669
+ public static function add_new_item () {
670
  $post_type = learn_press_get_request( 'type' );
671
  $post_title = learn_press_get_request( 'name' );
672
  $response = array();
684
  learn_press_send_json( $response );
685
  }
686
 
687
+ public static function quick_add_item () {
688
  $post_type = learn_press_get_request( 'type' );
689
  $post_title = learn_press_get_request( 'name' );
690
  $response = array();
706
  learn_press_send_json( $response );
707
  }
708
 
709
+ public static function update_editor_hidden () {
710
  if ( $id = learn_press_get_request( 'course_id' ) ) {
711
  if ( learn_press_get_request( 'is_hidden' ) ) {
712
  update_post_meta( $id, '_lp_editor_hidden', 'yes' );
717
  learn_press_send_json( $_POST );
718
  }
719
 
720
+ public static function update_quiz_question_state () {
721
  $hidden = learn_press_get_request( 'hidden' );
722
  $post = learn_press_get_request( 'quiz_id' );
723
  update_post_meta( $post, '_admin_hidden_questions', $hidden );
724
  die();
725
  }
726
 
727
+ public static function update_curriculum_section_state () {
728
  $hidden = learn_press_get_request( 'hidden' );
729
  $post = learn_press_get_request( 'course_id' );
730
  update_post_meta( $post, '_admin_hidden_sections', $hidden );
734
  /**
735
  * Create a new page with the title passed via $_REQUEST
736
  */
737
+ public static function create_page () {
738
+ $page_name = ! empty( $_REQUEST['page_name'] ) ? $_REQUEST['page_name'] : '';
739
  $response = array();
740
  if ( $page_name ) {
741
  $args = array(
762
  die();
763
  }
764
 
765
+ public static function add_quiz_question () {
766
  global $post;
767
  $id = learn_press_get_request( 'id' );
768
  $quiz_id = learn_press_get_request( 'quiz_id' );
774
  );
775
  $post = get_post( $quiz_id );
776
  setup_postdata( $post );
777
+ if ( ! $id ) {
778
  $args_item = array(
779
  'post_title' => $name,
780
  'post_type' => LP_QUESTION_CPT,
781
  'post_status' => 'publish'
782
  );
783
  $args_item = apply_filters( 'learnpress_quiz_insert_item_args', $args_item, $quiz_id );
784
+ $id = wp_insert_post( $args_item );
785
  if ( $id ) {
786
  add_post_meta( $id, '_lp_type', $type );
787
  }
805
  $response['html'] = ob_get_clean();
806
 
807
  // trigger change user memorize question types
808
+ $question_types = get_user_meta( $user_id, '_learn_press_memorize_question_types', true );
809
+ $question_types = ! $question_types ? array() : $question_types;
810
+ $type = get_post_meta( $id, '_lp_type', true );
811
+ $question_types[ $type ] = ! empty ( $question_types[ $type ] ) ? absint( $question_types[ $type ] ) + 1 : 1;
812
  update_user_meta( $user_id, '_learn_press_memorize_question_types', $question_types );
813
  // end trigger change user memorize question types
814
  }
816
  die();
817
  }
818
 
819
+ public static function convert_question_type () {
820
  if ( ( $from = learn_press_get_request( 'from' ) ) && ( $to = learn_press_get_request( 'to' ) ) && $question_id = learn_press_get_request( 'question_id' ) ) {
821
  $data = array();
822
  parse_str( $_POST['data'], $data );
825
  $question = LP_Question_Factory::get_question( $question_id, array( 'type' => $to ) );
826
 
827
  // trigger change user memorize question types
828
+ $user_id = get_current_user_id();
829
+ $question_types = get_user_meta( $user_id, '_learn_press_memorize_question_types', true );
830
+ $question_types[ $from ] = ! empty( $question_types[ $from ] ) && $question_types[ $from ] ? absint( $question_types[ $from ] ) - 1 : 0;
831
+ $question_types[ $to ] = ! empty( $question_types[ $to ] ) && $question_types[ $to ] ? absint( $question_types[ $to ] ) + 1 : 1;
832
  update_user_meta( $user_id, '_learn_press_memorize_question_types', $question_types );
833
  // end trigger change user memorize question types
834
  if ( 'auto-draft' === $question->post->post_status ) {
852
  /**
853
  * Install sample data or dismiss the notice depending on user's option
854
  */
855
+ public static function install_sample_data () {
856
+ $yes = ! empty( $_REQUEST['yes'] ) ? $_REQUEST['yes'] : '';
857
  $response = array( 'result' => 'fail' );
858
  $retry_button = sprintf( '<a href="" class="button yes" data-action="yes">%s</a>', __( 'Try again!', 'learnpress' ) );
859
  $dismiss_button = sprintf( '<a href="" class="button disabled no" data-action="no">%s</a>', __( 'Cancel', 'learnpress' ) );
899
  /**
900
  * Activate a bundle of add-ons, if an add-on is not installed then install it first
901
  */
902
+ public static function bundle_activate_add_ons () {
903
  global $learn_press_add_ons;
904
  include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api..
905
  $response = array( 'addons' => array() );
906
 
907
+ if ( ! current_user_can( 'activate_plugins' ) ) {
908
  $response['error'] = __( 'You do not have sufficient permissions to deactivate plugins for this site.', 'learnpress' );
909
  } else {
910
 
912
 
913
  if ( $add_ons ) {
914
  foreach ( $add_ons as $slug ) {
915
+ $response['addons'][ $slug ] = learn_press_install_and_active_add_on( $slug );
916
  }
917
  }
918
  }
922
  /**
923
  * Activate a bundle of add-ons, if an add-on is not installed then install it first
924
  */
925
+ public static function bundle_activate_add_on () {
926
  $response = array();
927
  include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api..
928
+ if ( ! current_user_can( 'activate_plugins' ) ) {
929
  $response['error'] = __( 'You do not have sufficient permissions to deactivate plugins for this site.', 'learnpress' );
930
  } else {
931
+ $slug = ! empty( $_REQUEST['plugin'] ) ? $_REQUEST['plugin'] : null;
932
+ $response[ $slug ] = learn_press_install_and_active_add_on( $slug );
933
  }
934
  learn_press_send_json( $response );
935
  }
936
 
937
+ public static function plugin_install () {
938
+ $plugin_name = ! empty( $_REQUEST['plugin'] ) ? $_REQUEST['plugin'] : '';
939
  $response = learn_press_install_add_on( $plugin_name );
940
  learn_press_send_json( $response );
941
  die();
942
  }
943
 
944
+ public static function update_add_on_status () {
945
+ $plugin = ! empty( $_REQUEST['plugin'] ) ? $_REQUEST['plugin'] : '';
946
+ $t = ! empty( $_REQUEST['t'] ) ? $_REQUEST['t'] : '';
947
  $response = array();
948
+ if ( ! current_user_can( 'activate_plugins' ) ) {
949
  $response['error'] = __( 'You do not have sufficient permissions to deactivate plugins for this site.', 'learnpress' );
950
  }
951
  if ( $plugin && $t ) {
965
  /**
966
  * Output the image to browser with text and params passed via $_GET
967
  */
968
+ public static function dummy_image () {
969
+ $text = ! empty( $_REQUEST['text'] ) ? $_REQUEST['text'] : '';
970
  learn_press_text_image( $text, $_GET );
971
  die();
972
  }
974
  /**
975
  * Get edit|view link of a page
976
  */
977
+ public static function get_page_permalink () {
978
+ $page_id = ! empty( $_REQUEST['page_id'] ) ? $_REQUEST['page_id'] : '';
979
  ?>
980
  <a href="<?php echo get_edit_post_link( $page_id ); ?>" target="_blank"><?php _e( 'Edit Page', 'learnpress' ); ?></a>
981
  <a href="<?php echo get_permalink( $page_id ); ?>" target="_blank"><?php _e( 'View Page', 'learnpress' ); ?></a>
987
  /**
988
  *
989
  */
990
+ public function custom_stats () {
991
+ $from = ! empty( $_REQUEST['from'] ) ? $_REQUEST['from'] : 0;
992
+ $to = ! empty( $_REQUEST['to'] ) ? $_REQUEST['to'] : 0;
993
  $date_diff = strtotime( $to ) - strtotime( $from );
994
  if ( $date_diff <= 0 || $from == 0 || $to == 0 ) {
995
  die();
1001
  /**
1002
  * Quick add lesson with only title
1003
  */
1004
+ public static function quick_add_lesson () {
1005
 
1006
  $lesson_title = $_POST['lesson_title'];
1007
 
1031
  /**
1032
  * Add a new quiz with the title only
1033
  */
1034
+ public static function quick_add_quiz () {
1035
  $quiz_title = $_POST['quiz_title'];
1036
 
1037
  $new_quiz = array(
1057
  die;
1058
  }
1059
 
1060
+ public static function be_teacher () {
1061
  $user_id = get_current_user_id();
1062
  $be_teacher = new WP_User( $user_id );
1063
  $be_teacher->set_role( LP_TEACHER_ROLE );
1064
  die;
1065
  }
1066
 
1067
+ public static function ignore_setting_up () {
1068
  update_option( '_lpr_ignore_setting_up', 1, true );
1069
  die;
1070
  }
1071
 
1072
+ public static function duplicate_course () {
1073
+ if ( empty( $_POST['course_id'] ) || empty( $_POST['_nonce'] ) || ! wp_verify_nonce( $_POST['_nonce'], 'lp-duplicate-course' ) ) {
1074
  return;
1075
  }
1076
  global $wpdb;
1077
  $course_id = absint( $_POST['course_id'] );
1078
+ $force = ! empty( $_POST['content'] ) && $_POST['content'] ? true : false;
1079
 
1080
  $results = array(
1081
  'redirect' => admin_url( 'edit.php?post_type=' . LP_COURSE_CPT )
1092
  die();
1093
  }
1094
 
1095
+ public static function duplicate_question () {
1096
+ if ( empty( $_POST['_nonce'] ) || ! wp_verify_nonce( $_POST['_nonce'], 'duplicate-question' ) ) {
1097
  return;
1098
  }
1099
  global $wpdb;
1102
  $user_id = learn_press_get_current_user_id();
1103
 
1104
  $new_question_id = learn_press_duplicate_question( $question_id, $quiz_id );
1105
+ if ( ! is_wp_error( $new_question_id ) ) {
1106
  ob_start();
1107
  $question = LP_Question_Factory::get_question( $new_question_id );
1108
  $post = get_post( $quiz_id );
1112
  $response['html'] = ob_get_clean();
1113
 
1114
  // trigger change user memorize question types
1115
+ $question_types = get_user_meta( $user_id, '_learn_press_memorize_question_types', true );
1116
+ $question_types = ! $question_types ? array() : $question_types;
1117
+ $type = get_post_meta( $new_question_id, '_lp_type', true );
1118
+ $question_types[ $type ] = ! empty ( $question_types[ $type ] ) ? absint( $question_types[ $type ] ) + 1 : 1;
1119
  update_user_meta( $user_id, '_learn_press_memorize_question_types', $question_types );
1120
  // end trigger change user memorize question types
1121
  learn_press_send_json( $response );
1125
  }
1126
  }
1127
 
1128
+ public static function remove_notice_popup () {
1129
 
1130
  if ( isset( $_POST['action'] ) && $_POST['action'] === 'learnpress_remove_notice_popup'
1131
+ && isset( $_POST['slug'] ) && ! empty( $_POST['slug'] )
1132
+ && isset( $_POST['user'] ) && ! empty( $_POST['user'] )
1133
  ) {
1134
 
1135
  $slug = 'learnpress_notice_' . $_POST['slug'] . '_' . $_POST['user'];
1143
 
1144
  }
1145
  }
1146
+ LP_Admin_Ajax::init();
1147
+
inc/admin/class-lp-admin-menu.php CHANGED
@@ -26,9 +26,6 @@ class LP_Admin_Menu {
26
  add_action( 'admin_menu', array( $this, 'notify_new_course' ) );
27
  add_action( 'init', array( $this, 'menu_content' ) );
28
  add_action( 'init', 'learn_press_admin_update_settings', 1000 );
29
- if ( apply_filters( 'learn_press_show_admin_bar_courses_page', true ) ) {
30
- add_action( 'admin_bar_menu', array( $this, 'admin_bar_menus' ), 50 );
31
- }
32
 
33
  // auto include file for admin page
34
  // example: slug = learn_press_settings -> file = inc/admin/sub-menus/settings.php
@@ -44,27 +41,6 @@ class LP_Admin_Menu {
44
  }
45
  }
46
 
47
- public function admin_bar_menus( $wp_admin_bar ) {
48
- if ( !is_admin() || !is_user_logged_in() ) {
49
- return;
50
- }
51
-
52
- if ( !is_user_member_of_blog() && !is_super_admin() ) {
53
- return;
54
- }
55
-
56
- if ( get_option( 'page_on_front' ) == learn_press_get_page_id( 'courses' ) ) {
57
- return;
58
- }
59
-
60
- $wp_admin_bar->add_node( array(
61
- 'parent' => 'site-name',
62
- 'id' => 'courses-page',
63
- 'title' => __( 'View Courses', 'learnpress' ),
64
- 'href' => learn_press_get_page_link( 'courses' )
65
- ) );
66
- }
67
-
68
  /**
69
  * Register for menu for admin
70
  */
26
  add_action( 'admin_menu', array( $this, 'notify_new_course' ) );
27
  add_action( 'init', array( $this, 'menu_content' ) );
28
  add_action( 'init', 'learn_press_admin_update_settings', 1000 );
 
 
 
29
 
30
  // auto include file for admin page
31
  // example: slug = learn_press_settings -> file = inc/admin/sub-menus/settings.php
41
  }
42
  }
43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  /**
45
  * Register for menu for admin
46
  */
inc/admin/class-lp-profile.php ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ exit; // Exit if accessed directly
4
+ }
5
+
6
+ if ( ! class_exists( 'LP_Profile' ) ) {
7
+ /**
8
+ * Class LP_Profile
9
+ */
10
+ class LP_Profile {
11
+ /**
12
+ * Constructor
13
+ */
14
+ public function __construct() {
15
+ add_filter( 'learn_press_profile_methods', array( $this, 'learn_press_profile_method' ) );
16
+ // add_action( 'wp_loaded', array( $this, 'learn_press_process_profile' ) );
17
+ add_action( 'learn_press_before_profile_content', array( $this, 'learn_press_add_tabs_scripts' ) );
18
+ add_action( 'learn_press_add_profile_tab', array( $this, 'learn_press_add_profile_tab' ) );
19
+ add_filter( 'learn_press_user_info_tab_content', array( $this, 'learn_press_user_info_tab_content' ), 10, 2 );
20
+ add_filter( 'learn_press_user_courses_tab_content', array( $this, 'learn_press_user_courses_tab_content' ), 10, 2 );
21
+ add_filter( 'learn_press_user_quizzes_tab_content', array( $this, 'learn_press_user_quizzes_tab_content' ), 10, 2 );
22
+ add_action( 'learn_press_enrolled_course_after_title', array( $this, 'end_title_content' ), 10, 2 );
23
+ }
24
+
25
+ /**
26
+ * Process profile
27
+ */
28
+ public function learn_press_process_profile() {
29
+ if ( learn_press_has_profile_method() ) {
30
+ if ( learn_press_get_profile_page_id() == 0 ) {
31
+ $profile = array(
32
+ 'post_title' => 'Profile',
33
+ 'post_content' => '[learn_press_profile]',
34
+ 'post_type' => 'page',
35
+ 'post_status' => 'publish',
36
+ );
37
+ $profile_page_id = wp_insert_post( $profile );
38
+ update_post_meta( $profile_page_id, '_lpr_is_profile_page', 1 );
39
+ }
40
+ } else {
41
+ wp_delete_post( learn_press_get_profile_page_id(), true );
42
+ }
43
+ }
44
+
45
+ /*
46
+ * Profile methods
47
+ */
48
+ public function learn_press_profile_method( $methods ) {
49
+ $methods['lpr_profile'] = __( 'LearnPress Profile', 'learnpress' );
50
+
51
+ return $methods;
52
+ }
53
+
54
+ /*
55
+ * Enqueue jquery ui scripts
56
+ */
57
+ public function learn_press_add_tabs_scripts() {
58
+ /*wp_enqueue_style( 'lpr-jquery-ui-css', LP_CSS_URL . 'jquery-ui.css' );
59
+ wp_enqueue_script( 'lpr-jquery-ui-js', LP_JS_URL . 'jquery-ui.js', array( 'jquery' ), '', false );*/
60
+ }
61
+
62
+ /*
63
+ * Add profile tab
64
+ */
65
+ public function learn_press_add_profile_tab( $user ) {
66
+ $content = '';
67
+ $tabs = apply_filters(
68
+ 'learn_press_profile_tabs',
69
+ array(
70
+ 10 => array(
71
+ 'tab_id' => 'user_info',
72
+ 'tab_name' => __( 'User Information', 'learnpress' ),
73
+ 'tab_content' => apply_filters( 'learn_press_user_info_tab_content', $content, $user )
74
+ ),
75
+ 20 => array(
76
+ 'tab_id' => 'user_courses',
77
+ 'tab_name' => __( 'Courses', 'learnpress' ),
78
+ 'tab_content' => apply_filters( 'learn_press_user_courses_tab_content', $content, $user )
79
+ )/*,
80
+ 30 => array(
81
+ 'tab_id' => 'user_quizzes',
82
+ 'tab_name' => __( 'Quiz Results', 'learnpress' ),
83
+ 'tab_content' => apply_filters( 'learn_press_user_quizzes_tab_content', $content, $user )
84
+ )*/
85
+ ),
86
+ $user
87
+ );
88
+ ksort( $tabs );
89
+ echo '<ul>';
90
+ foreach ( $tabs as $tab ) {
91
+ echo '<li><a href="#' . $tab['tab_id'] . '">' . $tab['tab_name'] . '</a></li>';
92
+ }
93
+ echo '</ul>';
94
+ foreach ( $tabs as $tab ) {
95
+ echo '<div id="' . $tab['tab_id'] . '">' . $tab['tab_content'] . '</div>';
96
+ }
97
+ }
98
+
99
+ /*
100
+ * Add content for user information tab
101
+ */
102
+ public function learn_press_user_info_tab_content( $content, $user ) {
103
+ ob_start();
104
+ learn_press_get_template( 'profile/user-info.php', array( 'user' => $user ) );
105
+ $content .= ob_get_clean();
106
+ return $content;
107
+ }
108
+
109
+ /*
110
+ * Add content for user courses tab
111
+ */
112
+ public function learn_press_user_courses_tab_content( $content, $user ) {
113
+ ob_start();
114
+ learn_press_get_template( 'profile/user-courses.php', array( 'user' => $user ) );
115
+ $content .= ob_get_clean();
116
+ return $content;
117
+ }
118
+
119
+
120
+ /*
121
+ * Add content for user quiz results tab
122
+ */
123
+ public function learn_press_user_quizzes_tab_content( $content, $user ) {
124
+ ob_start();
125
+ learn_press_get_template( 'profile/user-quizzes.php', array( 'content' => $content, 'user' => $user ) );
126
+ $content .= ob_get_clean();
127
+ return $content;
128
+ }
129
+
130
+ public function end_title_content( $course, $user ) {
131
+ if ( learn_press_user_has_passed_course( $course->ID, $user->ID ) ) {
132
+ _e( '<span class="course-status passed">Passed</span>', 'learnpress' );
133
+ } else {
134
+
135
+ }
136
+ }
137
+ }
138
+ new LP_Profile;
139
+ }
inc/admin/dashboard-statistics/class-lp-statistic-status.php CHANGED
@@ -12,15 +12,15 @@ if ( !class_exists( 'LP_Statistic_Status' ) ) :
12
  * @since 2.0
13
  */
14
  public static function render() {
15
- $order_statuses = learn_press_get_order_statuses(true, true);
16
  $eduma_data = self::get_eduma_info( 14058034 );
 
17
  $specific_statuses = array( 'lp-completed', 'lp-failed', 'lp-on-hold' );
18
- foreach ( $order_statuses as $status ) {
19
  if ( !in_array( $status, $specific_statuses ) ) {
20
  $specific_statuses[] = $status;
21
  }
22
  }
23
- $counts = learn_press_count_orders( array( 'status' => $specific_statuses ) );
24
  ?>
25
  <ul class="learnpress-statistic-status">
26
  <li class="full-width">
@@ -37,7 +37,7 @@ if ( !class_exists( 'LP_Statistic_Status' ) ) :
37
  if ( !$status_object ) {
38
  continue;
39
  }
40
- $count = $counts[$status];
41
  ?>
42
  <li>
43
  <?php if ( $count ): ?>
12
  * @since 2.0
13
  */
14
  public static function render() {
15
+ $order_statuses = learn_press_get_register_order_statuses();
16
  $eduma_data = self::get_eduma_info( 14058034 );
17
+ $xx = array_keys( $order_statuses );
18
  $specific_statuses = array( 'lp-completed', 'lp-failed', 'lp-on-hold' );
19
+ foreach ( $xx as $status ) {
20
  if ( !in_array( $status, $specific_statuses ) ) {
21
  $specific_statuses[] = $status;
22
  }
23
  }
 
24
  ?>
25
  <ul class="learnpress-statistic-status">
26
  <li class="full-width">
37
  if ( !$status_object ) {
38
  continue;
39
  }
40
+ $count = count( learn_press_get_orders( array( 'post_status' => $status ) ) );
41
  ?>
42
  <li>
43
  <?php if ( $count ): ?>
inc/admin/includes/class-markdown-parse.php CHANGED
@@ -239,7 +239,7 @@ class Markdown_Parser {
239
  var $predef_titles = array();
240
 
241
 
242
- function __construct() {
243
  #
244
  # Constructor function. Initialize appropriate member variables.
245
  #
@@ -1691,7 +1691,7 @@ class MarkdownExtra_Parser extends Markdown_Parser {
1691
  var $predef_abbr = array();
1692
 
1693
 
1694
- function __construct() {
1695
  #
1696
  # Constructor function. Initialize the parser object.
1697
  #
@@ -1717,7 +1717,7 @@ class MarkdownExtra_Parser extends Markdown_Parser {
1717
  "doAbbreviations" => 70,
1718
  );
1719
 
1720
- parent::__construct();
1721
  }
1722
 
1723
 
@@ -2268,15 +2268,13 @@ class MarkdownExtra_Parser extends Markdown_Parser {
2268
  if ($matches[3] == '-' && preg_match('{^- }', $matches[1]))
2269
  return $matches[0];
2270
  $level = $matches[3]{0} == '=' ? 1 : 2;
2271
- $id =& $matches[2];
2272
- $attr = $this->_doHeaders_attr($id);
2273
  $block = "<h$level$attr>".$this->runSpanGamut($matches[1])."</h$level>";
2274
  return "\n" . $this->hashBlock($block) . "\n\n";
2275
  }
2276
  function _doHeaders_callback_atx($matches) {
2277
  $level = strlen($matches[1]);
2278
- $id =& $matches[3];
2279
- $attr = $this->_doHeaders_attr($id);
2280
  $block = "<h$level$attr>".$this->runSpanGamut($matches[2])."</h$level>";
2281
  return "\n" . $this->hashBlock($block) . "\n\n";
2282
  }
239
  var $predef_titles = array();
240
 
241
 
242
+ function Markdown_Parser() {
243
  #
244
  # Constructor function. Initialize appropriate member variables.
245
  #
1691
  var $predef_abbr = array();
1692
 
1693
 
1694
+ function MarkdownExtra_Parser() {
1695
  #
1696
  # Constructor function. Initialize the parser object.
1697
  #
1717
  "doAbbreviations" => 70,
1718
  );
1719
 
1720
+ parent::Markdown_Parser();
1721
  }
1722
 
1723
 
2268
  if ($matches[3] == '-' && preg_match('{^- }', $matches[1]))
2269
  return $matches[0];
2270
  $level = $matches[3]{0} == '=' ? 1 : 2;
2271
+ $attr = $this->_doHeaders_attr($id =& $matches[2]);
 
2272
  $block = "<h$level$attr>".$this->runSpanGamut($matches[1])."</h$level>";
2273
  return "\n" . $this->hashBlock($block) . "\n\n";
2274
  }
2275
  function _doHeaders_callback_atx($matches) {
2276
  $level = strlen($matches[1]);
2277
+ $attr = $this->_doHeaders_attr($id =& $matches[3]);
 
2278
  $block = "<h$level$attr>".$this->runSpanGamut($matches[2])."</h$level>";
2279
  return "\n" . $this->hashBlock($block) . "\n\n";
2280
  }
inc/admin/lp-admin-functions.php CHANGED
@@ -7,7 +7,7 @@
7
  * @version 1.0
8
  */
9
 
10
- if ( !defined( 'ABSPATH' ) ) {
11
  exit;
12
  }
13
  /**
@@ -18,8 +18,8 @@ if ( !defined( 'ABSPATH' ) ) {
18
  *
19
  * @return mixed
20
  */
21
- function learn_press_get_admin_view( $name, $plugin_file = null ) {
22
- if ( !preg_match( '/\.(.*)$/', $name ) ) {
23
  $name .= '.php';
24
  }
25
  if ( $plugin_file ) {
@@ -41,8 +41,8 @@ function learn_press_get_admin_view( $name, $plugin_file = null ) {
41
  *
42
  * @return bool
43
  */
44
- function learn_press_admin_view( $name, $args = array(), $include_once = false, $return = false ) {
45
- $view = learn_press_get_admin_view( $name, !empty( $args['plugin_file'] ) ? $args['plugin_file'] : null );
46
  if ( file_exists( $view ) ) {
47
  ob_start();
48
  // extract parameters as local variables if passed
@@ -55,7 +55,7 @@ function learn_press_admin_view( $name, $args = array(), $include_once = false,
55
  }
56
  do_action( 'learn_press_after_display_admin_view', $name, $args );
57
  $output = ob_get_clean();
58
- if ( !$return ) {
59
  echo $output;
60
  }
61
 
@@ -74,7 +74,7 @@ function learn_press_admin_view( $name, $args = array(), $include_once = false,
74
  *
75
  * @return mixed|string
76
  */
77
- function learn_press_pages_dropdown( $name, $selected = false, $args = array() ) {
78
  $id = null;
79
  $class = null;
80
  $css = null;
@@ -151,7 +151,7 @@ function learn_press_pages_dropdown( $name, $selected = false, $args = array() )
151
  *
152
  * @return string
153
  */
154
- function learn_press_dropdown_question_types( $args = array() ) {
155
  $args = wp_parse_args(
156
  $args,
157
  array(
@@ -162,7 +162,7 @@ function learn_press_dropdown_question_types( $args = array() ) {
162
  'echo' => true
163
  )
164
  );
165
- if ( !$args['id'] ) {
166
  $args['id'] = $args['name'];
167
  }
168
  $args['class'] = 'lp-dropdown-question-types' . ( $args['class'] ? ' ' . $args['class'] : '' );
@@ -186,7 +186,7 @@ function learn_press_dropdown_question_types( $args = array() ) {
186
  *
187
  * @return string
188
  */
189
- function learn_press_field_question_duration( $args = array(), $question ) {
190
  global $post;
191
  $duration_type = get_post_meta( $post->ID, "_lp_duration_type", true );
192
  $value = get_post_meta( $question->id, '_question_duration', true );
@@ -211,21 +211,21 @@ function learn_press_field_question_duration( $args = array(), $question ) {
211
  );
212
  $args['value'] = $value;
213
 
214
- if ( !$args['id'] ) {
215
  $args['id'] = $args['name'];
216
  }
217
 
218
  return '<span class="' . esc_attr( $wrap_class ) . '">' . sprintf(
219
- '<input type="number" class="%s" name="%s" id="%s" value="%s" step="%s" min="%s" max="%s" placeholder="%s"/>',
220
- $args['class'],
221
- $args['name'],
222
- empty( $args['clone'] ) ? $args['id'] : '',
223
- $args['value'],
224
- $args['step'],
225
- $args['min'],
226
- !empty( $args['max'] ) ? $args['max'] : '',
227
- $args['placeholder']
228
- ) . $args['placeholder'] . '</span>';
229
  }
230
 
231
  /**
@@ -235,7 +235,7 @@ function learn_press_field_question_duration( $args = array(), $question ) {
235
  *
236
  * @return string
237
  */
238
- function learn_press_email_formats_dropdown( $args = array() ) {
239
  $args = wp_parse_args(
240
  $args,
241
  array(
@@ -272,8 +272,8 @@ function learn_press_email_formats_dropdown( $args = array() ) {
272
  /**
273
  * Translate javascript text
274
  */
275
- function learn_press_admin_localize_script() {
276
- if ( defined( 'LP_DOING_AJAX' ) || !is_admin() ) {
277
  return;
278
  }
279
  $translate = array(
@@ -302,7 +302,7 @@ add_action( 'init', 'learn_press_admin_localize_script' );
302
  *
303
  * @return mixed
304
  */
305
- function learn_press_settings_tabs_array() {
306
  $tabs = array(
307
  'general' => __( 'General', 'learnpress' ),
308
  'courses' => __( 'Courses', 'learnpress' ),
@@ -324,7 +324,7 @@ function learn_press_settings_tabs_array() {
324
  *
325
  * @return int
326
  */
327
- function learn_press_get_order_by_time( $by, $time ) {
328
  global $wpdb;
329
  $user_id = get_current_user_id();
330
 
@@ -376,7 +376,7 @@ function learn_press_get_order_by_time( $by, $time ) {
376
  *
377
  * @return int
378
  */
379
- function learn_press_get_courses_by_status( $status ) {
380
  global $wpdb;
381
  $user_id = get_current_user_id();
382
  $courses = $wpdb->get_var(
@@ -400,7 +400,7 @@ function learn_press_get_courses_by_status( $status ) {
400
  *
401
  * @return int
402
  */
403
- function learn_press_get_courses_by_price( $fee ) {
404
  global $wpdb;
405
  $user_id = get_current_user_id();
406
  $courses = $wpdb->get_var(
@@ -429,7 +429,7 @@ function learn_press_get_courses_by_price( $fee ) {
429
  *
430
  * @return array
431
  */
432
- function learn_press_get_chart_students( $from = null, $by = null, $time_ago ) {
433
  $labels = array();
434
  $datasets = array();
435
  if ( is_null( $from ) ) {
@@ -478,7 +478,7 @@ function learn_press_get_chart_students( $from = null, $by = null, $time_ago ) {
478
  *
479
  * @return array
480
  */
481
- function learn_press_get_chart_users( $from = null, $by = null, $time_ago ) {
482
  global $wpdb;
483
 
484
  $labels = array();
@@ -534,7 +534,7 @@ function learn_press_get_chart_users( $from = null, $by = null, $time_ago ) {
534
  ", $_sql_format, $_from, $_to );
535
  if ( $_results = $wpdb->get_results( $query ) ) {
536
  foreach ( $_results as $k => $v ) {
537
- $results['all'][$v->d] = $v;
538
  }
539
  }
540
  $query = $wpdb->prepare( "
@@ -549,7 +549,7 @@ function learn_press_get_chart_users( $from = null, $by = null, $time_ago ) {
549
 
550
  if ( $_results = $wpdb->get_results( $query ) ) {
551
  foreach ( $_results as $k => $v ) {
552
- $results['instructors'][$v->d] = $v;
553
  }
554
  }
555
  for ( $i = - $time_ago + 1; $i <= 0; $i ++ ) {
@@ -557,8 +557,8 @@ function learn_press_get_chart_users( $from = null, $by = null, $time_ago ) {
557
  $labels[] = date( $date_format, $date );
558
  $key = date( $_key_format, $date );
559
 
560
- $all = !empty( $results['all'][$key] ) ? $results['all'][$key]->c : 0;
561
- $instructors = !empty( $results['instructors'][$key] ) ? $results['instructors'][$key]->c : 0;
562
 
563
  $datasets[0]['data'][] = $all;
564
  $datasets[1]['data'][] = $instructors;
@@ -584,13 +584,13 @@ function learn_press_get_chart_users( $from = null, $by = null, $time_ago ) {
584
  );
585
 
586
  foreach ( $dataset_params as $k => $v ) {
587
- $datasets[$k]['fillColor'] = sprintf( $v['color1'], '0.2' );
588
- $datasets[$k]['strokeColor'] = sprintf( $v['color1'], '1' );
589
- $datasets[$k]['pointColor'] = sprintf( $v['color1'], '1' );
590
- $datasets[$k]['pointStrokeColor'] = $v['color2'];
591
- $datasets[$k]['pointHighlightFill'] = $v['color2'];
592
- $datasets[$k]['pointHighlightStroke'] = sprintf( $v['color1'], '1' );
593
- $datasets[$k]['label'] = $v['label'];
594
  }
595
 
596
  return array(
@@ -610,7 +610,7 @@ function learn_press_get_chart_users( $from = null, $by = null, $time_ago ) {
610
  *
611
  * @return array
612
  */
613
- function learn_press_get_chart_courses( $from = null, $by = null, $time_ago ) {
614
  global $wpdb;
615
 
616
  $labels = array();
@@ -678,7 +678,7 @@ function learn_press_get_chart_courses( $from = null, $by = null, $time_ago ) {
678
  ", $_sql_format, 'lp_course', $_from, $_to );
679
  if ( $_results = $wpdb->get_results( $query ) ) {
680
  foreach ( $_results as $k => $v ) {
681
- $results['all'][$v->d] = $v;
682
  }
683
  }
684
  $query = $wpdb->prepare( "
@@ -693,7 +693,7 @@ function learn_press_get_chart_courses( $from = null, $by = null, $time_ago ) {
693
  ", $_sql_format, 'publish', 'lp_course', $_from, $_to );
694
  if ( $_results = $wpdb->get_results( $query ) ) {
695
  foreach ( $_results as $k => $v ) {
696
- $results['publish'][$v->d] = $v;
697
  }
698
  }
699
 
@@ -710,7 +710,7 @@ function learn_press_get_chart_courses( $from = null, $by = null, $time_ago ) {
710
  ", $_sql_format, '_lp_payment', 'yes', 'publish', 'lp_course', $_from, $_to );
711
  if ( $_results = $wpdb->get_results( $query ) ) {
712
  foreach ( $_results as $k => $v ) {
713
- $results['paid'][$v->d] = $v;
714
  }
715
  }
716
 
@@ -719,9 +719,9 @@ function learn_press_get_chart_courses( $from = null, $by = null, $time_ago ) {
719
  $labels[] = date( $date_format, $date );
720
  $key = date( $_key_format, $date );
721
 
722
- $all = !empty( $results['all'][$key] ) ? $results['all'][$key]->c : 0;
723
- $publish = !empty( $results['publish'][$key] ) ? $results['publish'][$key]->c : 0;
724
- $paid = !empty( $results['paid'][$key] ) ? $results['paid'][$key]->c : 0;
725
 
726
  $datasets[0]['data'][] = $all;
727
  $datasets[1]['data'][] = $publish;
@@ -759,13 +759,13 @@ function learn_press_get_chart_courses( $from = null, $by = null, $time_ago ) {
759
  );
760
 
761
  foreach ( $dataset_params as $k => $v ) {
762
- $datasets[$k]['fillColor'] = sprintf( $v['color1'], '0.2' );
763
- $datasets[$k]['strokeColor'] = sprintf( $v['color1'], '1' );
764
- $datasets[$k]['pointColor'] = sprintf( $v['color1'], '1' );
765
- $datasets[$k]['pointStrokeColor'] = $v['color2'];
766
- $datasets[$k]['pointHighlightFill'] = $v['color2'];
767
- $datasets[$k]['pointHighlightStroke'] = sprintf( $v['color1'], '1' );
768
- $datasets[$k]['label'] = $v['label'];
769
  }
770
 
771
  return array(
@@ -785,7 +785,7 @@ function learn_press_get_chart_courses( $from = null, $by = null, $time_ago ) {
785
  *
786
  * @return array
787
  */
788
- function learn_press_get_chart_orders( $from = null, $by = null, $time_ago ) {
789
  global $wpdb;
790
  // var_dump( current_user_can(LP_TEACHER_ROLE) );
791
  // exit();
@@ -842,32 +842,32 @@ function learn_press_get_chart_orders( $from = null, $by = null, $time_ago ) {
842
  $query_where = '';
843
  if ( 'course' === $report_sales_by ) {
844
  $sql_join .= " INNER JOIN `{$wpdb->prefix}learnpress_order_items` `lpoi` "
845
- . " ON o.ID=lpoi.order_id "
846
- . " INNER JOIN {$wpdb->prefix}learnpress_order_itemmeta loim "
847
- . " ON lpoi.order_item_id=loim.learnpress_order_item_id "
848
- . " AND loim.meta_key='_course_id' "
849
- . " AND CAST(loim.meta_value AS SIGNED)=%d ";
850
  if ( current_user_can( LP_TEACHER_ROLE ) ) {
851
  $user_id = learn_press_get_current_user_id();
852
  $sql_join .= $wpdb->prepare( " AND CAST(loim.meta_value AS SIGNED) IN "
853
- . " ( "
854
- . " SELECT ID FROM {$wpdb->posts} p WHERE p.ID = CAST(loim.meta_value AS SIGNED) AND `post_author`=" . intval( $user_id )
855
- . " ) " );
856
  }
857
  $query_join .= $wpdb->prepare( $sql_join, $course_id );
858
 
859
  } elseif ( 'category' === $report_sales_by ) {
860
  $sql_join .= " INNER JOIN `{$wpdb->prefix}learnpress_order_items` `lpoi` "
861
- . " ON o.ID=lpoi.order_id "
862
- . " INNER JOIN {$wpdb->prefix}learnpress_order_itemmeta loim "
863
- . " ON lpoi.order_item_id=loim.learnpress_order_item_id "
864
- . " AND loim.meta_key='_course_id' "
865
- . " AND CAST(loim.meta_value AS SIGNED) IN("
866
- //sub query
867
- . " SELECT tr.object_id "
868
- . " FROM wp_term_taxonomy tt INNER JOIN wp_term_relationships tr "
869
- . " ON tt.term_taxonomy_id = tr.term_taxonomy_id AND tt.taxonomy='course_category' "
870
- . " WHERE tt.term_id=%d)";
871
  $query_join .= $wpdb->prepare( $sql_join, $cat_id );
872
  }
873
  if ( current_user_can( LP_TEACHER_ROLE ) ) {
@@ -896,7 +896,7 @@ function learn_press_get_chart_orders( $from = null, $by = null, $time_ago ) {
896
  if ( $_results = $wpdb->get_results( $query ) ) {
897
  foreach ( $_results as $k => $v ) {
898
  // $results['all'][$v->d] = $v;
899
- $results['completed'][$v->d] = $v;
900
  }
901
  }
902
 
@@ -913,7 +913,7 @@ function learn_press_get_chart_orders( $from = null, $by = null, $time_ago ) {
913
  if ( $_results = $wpdb->get_results( $query ) ) {
914
  foreach ( $_results as $k => $v ) {
915
  // $results['completed'][$v->d] = $v;
916
- $results['pending'][$v->d] = $v;
917
  }
918
  }
919
 
@@ -923,8 +923,8 @@ function learn_press_get_chart_orders( $from = null, $by = null, $time_ago ) {
923
  $labels[] = date( $date_format, $date );
924
  $key = date( $_key_format, $date );
925
 
926
- $completed = !empty( $results['completed'][$key] ) ? $results['completed'][$key]->c : 0;
927
- $pending = !empty( $results['pending'][$key] ) ? $results['pending'][$key]->c : 0;
928
  $all = $completed + $pending;
929
 
930
  $datasets[0]['data'][] = $all;
@@ -951,13 +951,13 @@ function learn_press_get_chart_orders( $from = null, $by = null, $time_ago ) {
951
  );
952
 
953
  foreach ( $dataset_params as $k => $v ) {
954
- $datasets[$k]['fillColor'] = sprintf( $v['color1'], '0.2' );
955
- $datasets[$k]['strokeColor'] = sprintf( $v['color1'], '1' );
956
- $datasets[$k]['pointColor'] = sprintf( $v['color1'], '1' );
957
- $datasets[$k]['pointStrokeColor'] = $v['color2'];
958
- $datasets[$k]['pointHighlightFill'] = $v['color2'];
959
- $datasets[$k]['pointHighlightStroke'] = sprintf( $v['color1'], '1' );
960
- $datasets[$k]['label'] = $v['label'];
961
  }
962
 
963
  return array(
@@ -971,7 +971,7 @@ function learn_press_get_chart_orders( $from = null, $by = null, $time_ago ) {
971
  * Get data about courses to render in the chart
972
  * @return array
973
  */
974
- function learn_press_get_chart_courses2() {
975
  $labels = array(
976
  __( 'Pending Courses / Publish Courses', 'learnpress' ),
977
  __( 'Free Courses / Priced Courses', 'learnpress' )
@@ -1002,12 +1002,12 @@ function learn_press_get_chart_courses2() {
1002
  * Get colors setting up by admin user
1003
  * @return array
1004
  */
1005
- function learn_press_get_admin_colors() {
1006
  $admin_color = get_user_meta( get_current_user_id(), 'admin_color', true );
1007
  global $_wp_admin_css_colors;
1008
  $colors = array();
1009
- if ( !empty( $_wp_admin_css_colors[$admin_color]->colors ) ) {
1010
- $colors = $_wp_admin_css_colors[$admin_color]->colors;
1011
  }
1012
  if ( empty ( $colors[0] ) ) {
1013
  $colors[0] = '#000000';
@@ -1024,7 +1024,7 @@ function learn_press_get_admin_colors() {
1024
  *
1025
  * @param array $chart
1026
  */
1027
- function learn_press_process_chart( $chart = array() ) {
1028
  $data = json_encode(
1029
  array(
1030
  'labels' => $chart['labels'],
@@ -1037,7 +1037,7 @@ function learn_press_process_chart( $chart = array() ) {
1037
  /**
1038
  * Print out the configuration for admin chart
1039
  */
1040
- function learn_press_config_chart() {
1041
  $colors = learn_press_get_admin_colors();
1042
  $config = array(
1043
  'scaleShowGridLines' => true,
@@ -1064,14 +1064,14 @@ function learn_press_config_chart() {
1064
  echo json_encode( $config );
1065
  }
1066
 
1067
- function set_post_order_in_admin( $wp_query ) {
1068
  global $pagenow;
1069
  if ( isset( $_GET['post_type'] ) ) {
1070
  $post_type = $_GET['post_type'];
1071
  } else {
1072
  $post_type = '';
1073
  }
1074
- if ( is_admin() && 'edit.php' == $pagenow && $post_type == LP_COURSE_CPT && !isset( $_GET['orderby'] ) ) {
1075
  $wp_query->set( 'orderby', 'date' );
1076
  $wp_query->set( 'order', 'DSC' );
1077
  }
@@ -1085,7 +1085,7 @@ add_filter( 'pre_get_posts', 'set_post_order_in_admin' );
1085
  *
1086
  * @return mixed
1087
  */
1088
- function learn_press_add_row_action_link( $actions ) {
1089
  global $post;
1090
  if ( LP_COURSE_CPT == $post->post_type ) {
1091
  $duplicate_link = admin_url( 'edit.php?post_type=lp_course&action=lp-duplicate-course&post=' . $post->ID . '&nonce=' . wp_create_nonce( 'lp-duplicate-' . $post->ID ) );
@@ -1132,7 +1132,7 @@ function learn_press_add_row_action_link( $actions ) {
1132
  add_filter( 'post_row_actions', 'learn_press_add_row_action_link' );
1133
  add_filter( 'page_row_actions', 'learn_press_add_row_action_link' );
1134
 
1135
- function learn_press_copy_post_meta( $from_id, $to_id ) {
1136
  global $wpdb;
1137
  $course_meta = $wpdb->get_results(
1138
  $wpdb->prepare( "SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id = %d", $from_id )
@@ -1158,7 +1158,7 @@ function learn_press_copy_post_meta( $from_id, $to_id ) {
1158
  *
1159
  * @author TuNN
1160
  */
1161
- function learn_press_process_duplicate_action() {
1162
 
1163
  $wp_list_table = _get_list_table( 'WP_Posts_List_Table' );
1164
  $action = $wp_list_table->current_action();
@@ -1166,19 +1166,19 @@ function learn_press_process_duplicate_action() {
1166
  if ( isset( $_REQUEST['action'] ) && $action == 'lp-duplicate-course' ) {
1167
  // current is not usefully because this feature using ajax action
1168
  $post_id = isset( $_REQUEST['post'] ) ? $_REQUEST['post'] : 0;
1169
- $nonce = !empty( $_REQUEST['nonce'] ) ? $_REQUEST['nonce'] : '';
1170
- if ( !wp_verify_nonce( $nonce, 'lp-duplicate-' . $post_id ) ) {
1171
  wp_die( __( 'Error', 'learnpress' ) );
1172
  }
1173
  if ( $post_id && is_array( $post_id ) ) {
1174
  $post_id = array_shift( $post_id );
1175
  }
1176
  // check for post is exists
1177
- if ( !( $post_id && $post = get_post( $post_id ) ) ) {
1178
  wp_die( __( 'Oops! The course does not exist.', 'learnpress' ) );
1179
  }
1180
  // ensure that user can create course
1181
- if ( !current_user_can( 'edit_posts' ) ) {
1182
  wp_die( __( 'Sorry! You have not permission to duplicate this course.', 'learnpress' ) );
1183
  }
1184
 
@@ -1206,7 +1206,7 @@ function learn_press_process_duplicate_action() {
1206
  // insert new course and get it ID
1207
  $new_post_id = wp_insert_post( $args );
1208
 
1209
- if ( !$new_post_id ) {
1210
  LP_Admin_Notice::add_redirect( __( '<p>Sorry! Duplicate course failed!</p>', 'learnpress' ) );
1211
  wp_redirect( admin_url( 'edit.php?post_type=lp_course' ) );
1212
  exit();
@@ -1249,7 +1249,7 @@ function learn_press_process_duplicate_action() {
1249
  ", $section->section_id );
1250
  if ( $items = $wpdb->get_results( $query ) ) {
1251
  foreach ( $items as $item ) {
1252
- $item_args = (array) $item;
1253
  unset(
1254
  $item_args['ID'],
1255
  $item_args['post_author'],
@@ -1274,19 +1274,19 @@ function learn_press_process_duplicate_action() {
1274
  }
1275
 
1276
  // duplicate action
1277
- $action = !empty( $_REQUEST['lp-action'] ) ? $_REQUEST['lp-action'] : '';
1278
  $actions = array(
1279
  'lp-duplicate-question',
1280
  'lp-duplicate-lesson',
1281
  'lp-duplicate-quiz'
1282
  );
1283
- if ( !in_array( $action, $actions ) ) {
1284
  return;
1285
  }
1286
 
1287
- $post_id = !empty ( $_REQUEST['post'] ) ? $_REQUEST['post'] : 0;
1288
- $nonce = !empty( $_REQUEST['nonce'] ) ? $_REQUEST['nonce'] : '';
1289
- if ( !$post_id || !wp_verify_nonce( $nonce, 'lp-duplicate-' . $post_id ) ) {
1290
  return;
1291
  }
1292
  // only duplicate question. not assign any data
@@ -1308,7 +1308,7 @@ function learn_press_process_duplicate_action() {
1308
  $success = __( 'Quiz duplicated.', 'learnpress' );
1309
  }
1310
 
1311
- if ( !$new_post_id ) {
1312
  return;
1313
  }
1314
  $redirect = 0;
@@ -1335,7 +1335,7 @@ add_action( 'load-edit.php', 'learn_press_process_duplicate_action' );
1335
  *
1336
  * @return array
1337
  */
1338
- function learn_press_install_add_on( $plugin_name ) {
1339
  require_once( LP_PLUGIN_PATH . '/inc/admin/class-lp-upgrader.php' );
1340
  $upgrader = new LP_Upgrader();
1341
  global $wp_filesystem;
@@ -1378,14 +1378,14 @@ function learn_press_install_add_on( $plugin_name ) {
1378
  return $response;
1379
  }
1380
 
1381
- function learn_press_accept_become_a_teacher() {
1382
- $action = !empty( $_REQUEST['action'] ) ? $_REQUEST['action'] : '';
1383
- $user_id = !empty( $_REQUEST['user_id'] ) ? $_REQUEST['user_id'] : '';
1384
- if ( !$action || !$user_id || ( $action != 'accept-to-be-teacher' ) ) {
1385
  return;
1386
  }
1387
 
1388
- if ( !learn_press_user_maybe_is_a_teacher( $user_id ) ) {
1389
  $be_teacher = new WP_User( $user_id );
1390
  $be_teacher->set_role( LP_TEACHER_ROLE );
1391
  delete_transient( 'learn_press_become_teacher_sent_' . $user_id );
@@ -1398,7 +1398,7 @@ function learn_press_accept_become_a_teacher() {
1398
 
1399
  add_action( 'plugins_loaded', 'learn_press_accept_become_a_teacher' );
1400
 
1401
- function learn_press_user_become_a_teacher_notice() {
1402
  if ( $user_id = learn_press_get_request( 'user_id' ) && learn_press_get_request( 'become-a-teacher-accepted' ) == 'yes' ) {
1403
  $user = new WP_User( $user_id );
1404
  ?>
@@ -1418,10 +1418,10 @@ add_action( 'admin_notices', 'learn_press_user_become_a_teacher_notice' );
1418
  *
1419
  * @return bool
1420
  */
1421
- function learn_press_is_plugin_install( $plugin ) {
1422
  $installed_plugins = get_plugins();
1423
 
1424
- return isset( $installed_plugins[$plugin] );
1425
  }
1426
 
1427
  /**
@@ -1431,7 +1431,7 @@ function learn_press_is_plugin_install( $plugin ) {
1431
  *
1432
  * @return mixed
1433
  */
1434
- function learn_press_plugin_basename_from_slug( $slug ) {
1435
  $keys = array_keys( get_plugins() );
1436
  foreach ( $keys as $key ) {
1437
  if ( preg_match( '|^' . $slug . '/|', $key ) ) {
@@ -1442,7 +1442,7 @@ function learn_press_plugin_basename_from_slug( $slug ) {
1442
  return $slug;
1443
  }
1444
 
1445
- function learn_press_one_click_install_sample_data_notice() {
1446
  $courses = get_posts(
1447
  array(
1448
  'post_type' => LP_COURSE_CPT,
@@ -1473,16 +1473,16 @@ function learn_press_one_click_install_sample_data_notice() {
1473
 
1474
  //add_action( 'admin_notices', 'learn_press_one_click_install_sample_data_notice' );
1475
 
1476
- function learn_press_request_query( $vars = array() ) {
1477
  global $typenow, $wp_query, $wp_post_statuses;
1478
  if ( LP_ORDER_CPT === $typenow ) {
1479
  // Status
1480
- if ( !isset( $vars['post_status'] ) ) {
1481
  $post_statuses = learn_press_get_order_statuses();
1482
 
1483
  foreach ( $post_statuses as $status => $value ) {
1484
- if ( isset( $wp_post_statuses[$status] ) && false === $wp_post_statuses[$status]->show_in_admin_all_list ) {
1485
- unset( $post_statuses[$status] );
1486
  }
1487
  }
1488
 
@@ -1496,7 +1496,7 @@ function learn_press_request_query( $vars = array() ) {
1496
 
1497
  add_filter( 'request', 'learn_press_request_query', 0 );
1498
 
1499
- function _learn_press_reset_course_data() {
1500
  if ( empty( $_REQUEST['reset-course-data'] ) ) {
1501
  return false;
1502
  }
@@ -1507,12 +1507,12 @@ function _learn_press_reset_course_data() {
1507
  add_action( 'init', '_learn_press_reset_course_data' );
1508
 
1509
  /***********************/
1510
- function learn_press_admin_section_loop_item_class( $item, $section ) {
1511
  $classes = array(
1512
  'lp-section-item'
1513
  );
1514
  $classes[] = 'lp-item-' . $item->post_type;
1515
- if ( !absint( $item->ID ) ) {
1516
  $classes[] = 'lp-item-empty lp-item-new focus';
1517
  }
1518
  $classes = apply_filters( 'learn_press_section_loop_item_class', $classes, $item, $section );
@@ -1523,7 +1523,7 @@ function learn_press_admin_section_loop_item_class( $item, $section ) {
1523
  return $classes;
1524
  }
1525
 
1526
- function learn_press_disable_checked_ontop( $args ) {
1527
 
1528
  if ( 'course_category' == $args['taxonomy'] ) {
1529
  $args['checked_ontop'] = false;
@@ -1534,13 +1534,13 @@ function learn_press_disable_checked_ontop( $args ) {
1534
 
1535
  add_filter( 'wp_terms_checklist_args', 'learn_press_disable_checked_ontop' );
1536
 
1537
- function learn_press_output_admin_template() {
1538
  learn_press_admin_view( 'admin-template.php' );
1539
  }
1540
 
1541
  add_action( 'admin_print_scripts', 'learn_press_output_admin_template' );
1542
 
1543
- function learn_press_output_screen_id() {
1544
  $screen = get_current_screen();
1545
  if ( $screen ) {
1546
  echo "<div style=\"position:fixed;top: 0; left:0; z-index: 99999999; background-color:#FFF;padding:4px;\">" . $screen->id . "</div>";
@@ -1549,7 +1549,7 @@ function learn_press_output_screen_id() {
1549
 
1550
  //add_action( 'admin_head', 'learn_press_output_screen_id' );
1551
 
1552
- function learn_press_get_screens() {
1553
  $screen_id = sanitize_title( __( 'LearnPress', 'learnpress' ) );
1554
  $screens = array(
1555
  'toplevel_page_' . $screen_id,
@@ -1566,7 +1566,7 @@ function learn_press_get_screens() {
1566
  return apply_filters( 'learn_press_screen_ids', $screens );
1567
  }
1568
 
1569
- function learn_press_get_admin_pages() {
1570
  return apply_filters(
1571
  'learn_press_admin_pages',
1572
  array(
@@ -1576,7 +1576,7 @@ function learn_press_get_admin_pages() {
1576
  );
1577
  }
1578
 
1579
- function learn_press_is_post_type_screen( $post_type, $union = 'OR' ) {
1580
  if ( is_array( $post_type ) ) {
1581
  $return = null;
1582
  foreach ( $post_type as $_post_type ) {
@@ -1597,7 +1597,7 @@ function learn_press_is_post_type_screen( $post_type, $union = 'OR' ) {
1597
  return $return;
1598
  }
1599
  $screen = get_current_screen();
1600
- if ( !$screen ) {
1601
  return;
1602
  }
1603
  $screen_id = $screen->id;
@@ -1605,7 +1605,7 @@ function learn_press_is_post_type_screen( $post_type, $union = 'OR' ) {
1605
  return in_array( $screen_id, array( $post_type, "edit-{$post_type}" ) );
1606
  }
1607
 
1608
- function learn_press_get_notice_dismiss( $context, $type = 'transient' ) {
1609
  if ( $type == 'transient' ) {
1610
  return get_transient( 'learn_press_dismiss_notice_' . $context );
1611
  }
@@ -1613,9 +1613,9 @@ function learn_press_get_notice_dismiss( $context, $type = 'transient' ) {
1613
  return get_option( 'learn_press_dismiss_notice_' . $context );
1614
  }
1615
 
1616
- if ( !function_exists( 'learn_press_course_insert_section' ) ) {
1617
 
1618
- function learn_press_course_insert_section( $section = array() ) {
1619
  global $wpdb;
1620
  $section = wp_parse_args(
1621
  $section,
@@ -1641,9 +1641,9 @@ if ( !function_exists( 'learn_press_course_insert_section' ) ) {
1641
 
1642
  }
1643
 
1644
- if ( !function_exists( 'learn_press_course_insert_section_item' ) ) {
1645
 
1646
- function learn_press_course_insert_section_item( $item_data = array() ) {
1647
  global $wpdb;
1648
  $wpdb->insert(
1649
  $wpdb->learnpress_section_items,
@@ -1666,11 +1666,11 @@ if ( !function_exists( 'learn_press_course_insert_section_item' ) ) {
1666
 
1667
  }
1668
 
1669
- if ( !function_exists( 'learn_press_duplicate_post' ) ) {
1670
 
1671
- function learn_press_duplicate_post( $post_id = null, $args = array(), $meta = true ) {
1672
  $post = get_post( $post_id );
1673
- if ( !$post ) {
1674
  return;
1675
  }
1676
  $defalts = array(
@@ -1689,7 +1689,7 @@ if ( !function_exists( 'learn_press_duplicate_post' ) ) {
1689
  );
1690
  $args = wp_parse_args( $args, $defalts );
1691
  $new_post_id = wp_insert_post( $args );
1692
- if ( !is_wp_error( $new_post_id ) && $meta ) {
1693
  learn_press_duplicate_post_meta( $post_id, $new_post_id );
1694
  // assign related tags/categories to new course
1695
  $taxonomies = get_object_taxonomies( $post->post_type );
@@ -1703,23 +1703,23 @@ if ( !function_exists( 'learn_press_duplicate_post' ) ) {
1703
  }
1704
  }
1705
 
1706
- if ( !function_exists( 'learn_press_duplicate_post_meta' ) ) {
1707
  /**
1708
  * duplicate all post meta just in two SQL queries
1709
  */
1710
- function learn_press_duplicate_post_meta( $old_post_id, $new_post_id, $excerpt = array() ) {
1711
  global $wpdb;
1712
  $post_meta_infos = $wpdb->get_results( "SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id=$old_post_id" );
1713
  if ( count( $post_meta_infos ) != 0 ) {
1714
  $excerpt = array_merge( array( '_edit_lock', '_edit_last' ), $excerpt );
1715
- $excerpt = apply_filters( 'learn_press_excerpt_duplicate_post_meta', $excerpt, $old_post_id, $new_post_id );
1716
  $sql_query = "INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) ";
1717
  $sql_query_sel = array();
1718
  foreach ( $post_meta_infos as $meta ) {
1719
  if ( in_array( $meta->meta_key, $excerpt ) ) {
1720
  continue;
1721
  }
1722
- if ( $meta->meta_key === '_lp_course_author' ) {
1723
  $meta->meta_value = get_current_user_id();
1724
  }
1725
  $meta_key = $meta->meta_key;
@@ -1734,11 +1734,11 @@ if ( !function_exists( 'learn_press_duplicate_post_meta' ) ) {
1734
  }
1735
 
1736
  add_filter( 'learn_press_question_types', 'learn_press_sort_questions', 99 );
1737
- if ( !function_exists( 'learn_press_sort_questions' ) ) {
1738
- function learn_press_sort_questions( $types ) {
1739
  $user_id = get_current_user_id();
1740
  $question_types = get_user_meta( $user_id, '_learn_press_memorize_question_types', true );
1741
- if ( !empty( $question_types ) ) {
1742
  $sort = array();
1743
  // re-sort array descending
1744
  arsort( $question_types );
@@ -1747,19 +1747,19 @@ if ( !function_exists( 'learn_press_sort_questions' ) ) {
1747
 
1748
  for ( $i = 0; $i < count( $ktypes ) - 1; $i ++ ) {
1749
  $max = $i;
1750
- if ( !isset( $question_types[$ktypes[$i]] ) ) {
1751
- $question_types[$ktypes[$i]] = 0;
1752
  }
1753
  for ( $j = $i + 1; $j < count( $ktypes ); $j ++ ) {
1754
- if ( isset( $question_types[$ktypes[$j]], $question_types[$ktypes[$max]] )
1755
- && $question_types[$ktypes[$j]] > $question_types[$ktypes[$max]]
1756
  ) {
1757
  $max = $j;
1758
  }
1759
  }
1760
- $tmp = $ktypes[$i];
1761
- $ktypes[$i] = $ktypes[$max];
1762
- $ktypes[$max] = $tmp;
1763
  }
1764
  $ktypes = array_flip( $ktypes );
1765
  $types = array_merge( $ktypes, $types );
@@ -1769,10 +1769,10 @@ if ( !function_exists( 'learn_press_sort_questions' ) ) {
1769
  }
1770
  }
1771
 
1772
- if ( !function_exists( 'learn_press_duplicate_course' ) ) {
1773
 
1774
- function learn_press_duplicate_course( $course_id = null, $force = true ) {
1775
- if ( !function_exists( '_learn_press_get_course_curriculum' ) ) {
1776
  require_once LP_PLUGIN_PATH . 'inc/lp-init.php';
1777
  }
1778
  global $wpdb;
@@ -1781,16 +1781,16 @@ if ( !function_exists( 'learn_press_duplicate_course' ) ) {
1781
  $course_id = array_shift( $course_id );
1782
  }
1783
  // check for post is exists
1784
- if ( !$course_id || !( $post = get_post( $course_id ) ) ) {
1785
  return new WP_Error( __( '<p>Op! The course does not exist</p>', 'learnpress' ) );
1786
  } else {
1787
  // ensure that user can create course
1788
- if ( !current_user_can( 'edit_posts' ) ) {
1789
  return new WP_Error( __( '<p>Sorry! You have not permission to duplicate this course</p>', 'learnpress' ) );
1790
  } else {
1791
  // duplicate course
1792
  $new_course_id = learn_press_duplicate_post( $course_id );
1793
- if ( !$new_course_id || is_wp_error( $new_course_id ) ) {
1794
  return new WP_Error( __( '<p>Sorry! Duplicate course failed!</p>', 'learnpress' ) );
1795
  } else {
1796
  $curriculums = _learn_press_get_course_curriculum( $course_id );
@@ -1830,13 +1830,13 @@ if ( !function_exists( 'learn_press_duplicate_course' ) ) {
1830
 
1831
  }
1832
 
1833
- if ( !function_exists( 'learn_press_duplicate_question' ) ) {
1834
 
1835
- function learn_press_duplicate_question( $question_id = null, $quiz_id = null ) {
1836
- if ( !$question_id || !get_post( $question_id ) ) {
1837
  return new WP_Error( sprintf( __( 'Question id %s is not exists.', 'learnpress' ), $question_id ) );
1838
  }
1839
- if ( $quiz_id && !get_post( $quiz_id ) ) {
1840
  return new WP_Error( sprintf( __( 'Quiz id %s is not exists.', 'learnpress' ), $quiz_id ) );
1841
  }
1842
 
@@ -1896,9 +1896,9 @@ if ( !function_exists( 'learn_press_duplicate_question' ) ) {
1896
 
1897
  }
1898
 
1899
- if ( !function_exists( 'learn_press_duplicate_quiz' ) ) {
1900
 
1901
- function learn_press_duplicate_quiz( $quiz_id = null, $args = array() ) {
1902
  global $wpdb;
1903
  $new_quiz_id = learn_press_duplicate_post( $quiz_id, $args, true );
1904
  $quiz = LP_Quiz::get_quiz( $quiz_id );
@@ -1966,8 +1966,8 @@ if ( !function_exists( 'learn_press_duplicate_quiz' ) ) {
1966
  *
1967
  * @return string
1968
  */
1969
- function learn_press_get_file_version( $file ) {
1970
- if ( !file_exists( $file ) ) {
1971
  return '';
1972
  }
1973
  $fp = fopen( $file, 'r' );
@@ -1989,7 +1989,7 @@ function learn_press_get_file_version( $file ) {
1989
  *
1990
  * @return array|bool
1991
  */
1992
- function learn_press_get_theme_templates( $check = false ) {
1993
  $template_folder = learn_press_template_path();
1994
  $template_path = LP_PLUGIN_PATH . '/templates/';
1995
  $template_dir = get_template_directory();
@@ -2020,22 +2020,22 @@ function learn_press_get_theme_templates( $check = false ) {
2020
  $theme_file = false;
2021
  }
2022
 
2023
- if ( !empty( $theme_file ) ) {
2024
  $core_version = learn_press_get_file_version( $template_path . $file );
2025
  $theme_version = learn_press_get_file_version( $theme_file );
2026
 
2027
  if ( $core_version && ( empty( $theme_version ) || version_compare( $theme_version, $core_version, '<' ) ) ) {
2028
- if ( !$outdated_templates ) {
2029
  $outdated_templates = true;
2030
  }
2031
- $found_files[$theme_folder][] = array(
2032
  str_replace( WP_CONTENT_DIR . '/themes/', '', $theme_file ),
2033
  $theme_version ? $theme_version : '-',
2034
  $core_version,
2035
  true
2036
  );
2037
  } else {
2038
- $found_files[$theme_folder][] = array(
2039
  str_replace( WP_CONTENT_DIR . '/themes/', '', $theme_file ),
2040
  $theme_version ? $theme_version : '?',
2041
  $core_version ? $core_version : '?',
@@ -2048,7 +2048,7 @@ function learn_press_get_theme_templates( $check = false ) {
2048
  }
2049
  }
2050
  if ( sizeof( $found_files ) > 1 ) {
2051
- $found_files = array_merge( $found_files[$t_folder], $found_files[$s_folder] );
2052
  } else {
2053
  $found_files = reset( $found_files );
2054
  }
@@ -2056,7 +2056,7 @@ function learn_press_get_theme_templates( $check = false ) {
2056
  return $check ? $outdated_templates : $found_files;
2057
  }
2058
 
2059
- function learn_press_detect_outdated_template() {
2060
  $template_folder = learn_press_template_path();
2061
  $template_path = LP_PLUGIN_PATH . '/templates/';
2062
  $template_dir = get_template_directory();
@@ -2093,7 +2093,7 @@ function learn_press_detect_outdated_template() {
2093
  }
2094
  }
2095
 
2096
- if ( !empty( $theme_file ) ) {
2097
  $core_version = learn_press_get_file_version( $template_path . $file );
2098
  $theme_version = learn_press_get_file_version( $theme_file );
2099
 
@@ -2106,7 +2106,7 @@ function learn_press_detect_outdated_template() {
2106
  }
2107
  }
2108
  }
2109
- if ( !empty( $child_item ) || !empty( $parent_item ) ) {
2110
 
2111
  return array(
2112
  'parent_item' => $parent_item,
@@ -2117,14 +2117,14 @@ function learn_press_detect_outdated_template() {
2117
  return false;
2118
  }
2119
 
2120
- function learn_press_scan_template_files( $template_path ) {
2121
 
2122
  $files = @scandir( $template_path );
2123
  $result = array();
2124
 
2125
- if ( !empty( $files ) ) {
2126
  foreach ( $files as $key => $value ) {
2127
- if ( !in_array( $value, array( ".", "..", 'index.php', 'index.html' ) ) ) {
2128
  if ( is_dir( $template_path . '/' . $value ) ) {
2129
  $sub_files = learn_press_scan_template_files( $template_path . '/' . $value );
2130
  foreach ( $sub_files as $sub_file ) {
@@ -2140,28 +2140,10 @@ function learn_press_scan_template_files( $template_path ) {
2140
  return $result;
2141
  }
2142
 
2143
- if ( !function_exists( 'learn_press_duplicate_lesson' ) ) {
2144
 
2145
- function learn_press_duplicate_lesson( $lesson_id = null ) {
2146
  return learn_press_duplicate_post( $lesson_id );
2147
  }
2148
 
2149
- }
2150
-
2151
- function learn_press_get_default_section( $section = null ) {
2152
- if ( !$section ) {
2153
- $section = new stdClass();
2154
- }
2155
- foreach ( array(
2156
- 'section_id' => null,
2157
- 'section_name' => '',
2158
- 'section_course_id' => null,
2159
- 'section_order' => null,
2160
- 'section_description' => ''
2161
- ) as $k => $v ) {
2162
- if ( !property_exists( $section, $k ) ) {
2163
- $section->{$k} = $v;
2164
- }
2165
- }
2166
- return $section;
2167
  }
7
  * @version 1.0
8
  */
9
 
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
  exit;
12
  }
13
  /**
18
  *
19
  * @return mixed
20
  */
21
+ function learn_press_get_admin_view ( $name, $plugin_file = null ) {
22
+ if ( ! preg_match( '/\.(.*)$/', $name ) ) {
23
  $name .= '.php';
24
  }
25
  if ( $plugin_file ) {
41
  *
42
  * @return bool
43
  */
44
+ function learn_press_admin_view ( $name, $args = array(), $include_once = false, $return = false ) {
45
+ $view = learn_press_get_admin_view( $name, ! empty( $args['plugin_file'] ) ? $args['plugin_file'] : null );
46
  if ( file_exists( $view ) ) {
47
  ob_start();
48
  // extract parameters as local variables if passed
55
  }
56
  do_action( 'learn_press_after_display_admin_view', $name, $args );
57
  $output = ob_get_clean();
58
+ if ( ! $return ) {
59
  echo $output;
60
  }
61
 
74
  *
75
  * @return mixed|string
76
  */
77
+ function learn_press_pages_dropdown ( $name, $selected = false, $args = array() ) {
78
  $id = null;
79
  $class = null;
80
  $css = null;
151
  *
152
  * @return string
153
  */
154
+ function learn_press_dropdown_question_types ( $args = array() ) {
155
  $args = wp_parse_args(
156
  $args,
157
  array(
162
  'echo' => true
163
  )
164
  );
165
+ if ( ! $args['id'] ) {
166
  $args['id'] = $args['name'];
167
  }
168
  $args['class'] = 'lp-dropdown-question-types' . ( $args['class'] ? ' ' . $args['class'] : '' );
186
  *
187
  * @return string
188
  */
189
+ function learn_press_field_question_duration ( $args = array(), $question ) {
190
  global $post;
191
  $duration_type = get_post_meta( $post->ID, "_lp_duration_type", true );
192
  $value = get_post_meta( $question->id, '_question_duration', true );
211
  );
212
  $args['value'] = $value;
213
 
214
+ if ( ! $args['id'] ) {
215
  $args['id'] = $args['name'];
216
  }
217
 
218
  return '<span class="' . esc_attr( $wrap_class ) . '">' . sprintf(
219
+ '<input type="number" class="%s" name="%s" id="%s" value="%s" step="%s" min="%s" max="%s" placeholder="%s"/>',
220
+ $args['class'],
221
+ $args['name'],
222
+ empty( $args['clone'] ) ? $args['id'] : '',
223
+ $args['value'],
224
+ $args['step'],
225
+ $args['min'],
226
+ ! empty( $args['max'] ) ? $args['max'] : '',
227
+ $args['placeholder']
228
+ ) . $args['placeholder'] . '</span>';
229
  }
230
 
231
  /**
235
  *
236
  * @return string
237
  */
238
+ function learn_press_email_formats_dropdown ( $args = array() ) {
239
  $args = wp_parse_args(
240
  $args,
241
  array(
272
  /**
273
  * Translate javascript text
274
  */
275
+ function learn_press_admin_localize_script () {
276
+ if ( defined( 'LP_DOING_AJAX' ) || ! is_admin() ) {
277
  return;
278
  }
279
  $translate = array(
302
  *
303
  * @return mixed
304
  */
305
+ function learn_press_settings_tabs_array () {
306
  $tabs = array(
307
  'general' => __( 'General', 'learnpress' ),
308
  'courses' => __( 'Courses', 'learnpress' ),
324
  *
325
  * @return int
326
  */
327
+ function learn_press_get_order_by_time ( $by, $time ) {
328
  global $wpdb;
329
  $user_id = get_current_user_id();
330
 
376
  *
377
  * @return int
378
  */
379
+ function learn_press_get_courses_by_status ( $status ) {
380
  global $wpdb;
381
  $user_id = get_current_user_id();
382
  $courses = $wpdb->get_var(
400
  *
401
  * @return int
402
  */
403
+ function learn_press_get_courses_by_price ( $fee ) {
404
  global $wpdb;
405
  $user_id = get_current_user_id();
406
  $courses = $wpdb->get_var(
429
  *
430
  * @return array
431
  */
432
+ function learn_press_get_chart_students ( $from = null, $by = null, $time_ago ) {
433
  $labels = array();
434
  $datasets = array();
435
  if ( is_null( $from ) ) {
478
  *
479
  * @return array
480
  */
481
+ function learn_press_get_chart_users ( $from = null, $by = null, $time_ago ) {
482
  global $wpdb;
483
 
484
  $labels = array();
534
  ", $_sql_format, $_from, $_to );
535
  if ( $_results = $wpdb->get_results( $query ) ) {
536
  foreach ( $_results as $k => $v ) {
537
+ $results['all'][ $v->d ] = $v;
538
  }
539
  }
540
  $query = $wpdb->prepare( "
549
 
550
  if ( $_results = $wpdb->get_results( $query ) ) {
551
  foreach ( $_results as $k => $v ) {
552
+ $results['instructors'][ $v->d ] = $v;
553
  }
554
  }
555
  for ( $i = - $time_ago + 1; $i <= 0; $i ++ ) {
557
  $labels[] = date( $date_format, $date );
558
  $key = date( $_key_format, $date );
559
 
560
+ $all = ! empty( $results['all'][ $key ] ) ? $results['all'][ $key ]->c : 0;
561
+ $instructors = ! empty( $results['instructors'][ $key ] ) ? $results['instructors'][ $key ]->c : 0;
562
 
563
  $datasets[0]['data'][] = $all;
564
  $datasets[1]['data'][] = $instructors;
584
  );
585
 
586
  foreach ( $dataset_params as $k => $v ) {
587
+ $datasets[ $k ]['fillColor'] = sprintf( $v['color1'], '0.2' );
588
+ $datasets[ $k ]['strokeColor'] = sprintf( $v['color1'], '1' );
589
+ $datasets[ $k ]['pointColor'] = sprintf( $v['color1'], '1' );
590
+ $datasets[ $k ]['pointStrokeColor'] = $v['color2'];
591
+ $datasets[ $k ]['pointHighlightFill'] = $v['color2'];
592
+ $datasets[ $k ]['pointHighlightStroke'] = sprintf( $v['color1'], '1' );
593
+ $datasets[ $k ]['label'] = $v['label'];
594
  }
595
 
596
  return array(
610
  *
611
  * @return array
612
  */
613
+ function learn_press_get_chart_courses ( $from = null, $by = null, $time_ago ) {
614
  global $wpdb;
615
 
616
  $labels = array();
678
  ", $_sql_format, 'lp_course', $_from, $_to );
679
  if ( $_results = $wpdb->get_results( $query ) ) {
680
  foreach ( $_results as $k => $v ) {
681
+ $results['all'][ $v->d ] = $v;
682
  }
683
  }
684
  $query = $wpdb->prepare( "
693
  ", $_sql_format, 'publish', 'lp_course', $_from, $_to );
694
  if ( $_results = $wpdb->get_results( $query ) ) {
695
  foreach ( $_results as $k => $v ) {
696
+ $results['publish'][ $v->d ] = $v;
697
  }
698
  }
699
 
710
  ", $_sql_format, '_lp_payment', 'yes', 'publish', 'lp_course', $_from, $_to );
711
  if ( $_results = $wpdb->get_results( $query ) ) {
712
  foreach ( $_results as $k => $v ) {
713
+ $results['paid'][ $v->d ] = $v;
714
  }
715
  }
716
 
719
  $labels[] = date( $date_format, $date );
720
  $key = date( $_key_format, $date );
721
 
722
+ $all = ! empty( $results['all'][ $key ] ) ? $results['all'][ $key ]->c : 0;
723
+ $publish = ! empty( $results['publish'][ $key ] ) ? $results['publish'][ $key ]->c : 0;
724
+ $paid = ! empty( $results['paid'][ $key ] ) ? $results['paid'][ $key ]->c : 0;
725
 
726
  $datasets[0]['data'][] = $all;
727
  $datasets[1]['data'][] = $publish;
759
  );
760
 
761
  foreach ( $dataset_params as $k => $v ) {
762
+ $datasets[ $k ]['fillColor'] = sprintf( $v['color1'], '0.2' );
763
+ $datasets[ $k ]['strokeColor'] = sprintf( $v['color1'], '1' );
764
+ $datasets[ $k ]['pointColor'] = sprintf( $v['color1'], '1' );
765
+ $datasets[ $k ]['pointStrokeColor'] = $v['color2'];
766
+ $datasets[ $k ]['pointHighlightFill'] = $v['color2'];
767
+ $datasets[ $k ]['pointHighlightStroke'] = sprintf( $v['color1'], '1' );
768
+ $datasets[ $k ]['label'] = $v['label'];
769
  }
770
 
771
  return array(
785
  *
786
  * @return array
787
  */
788
+ function learn_press_get_chart_orders ( $from = null, $by = null, $time_ago ) {
789
  global $wpdb;
790
  // var_dump( current_user_can(LP_TEACHER_ROLE) );
791
  // exit();
842
  $query_where = '';
843
  if ( 'course' === $report_sales_by ) {
844
  $sql_join .= " INNER JOIN `{$wpdb->prefix}learnpress_order_items` `lpoi` "
845
+ . " ON o.ID=lpoi.order_id "
846
+ . " INNER JOIN {$wpdb->prefix}learnpress_order_itemmeta loim "
847
+ . " ON lpoi.order_item_id=loim.learnpress_order_item_id "
848
+ . " AND loim.meta_key='_course_id' "
849
+ . " AND CAST(loim.meta_value AS SIGNED)=%d ";
850
  if ( current_user_can( LP_TEACHER_ROLE ) ) {
851
  $user_id = learn_press_get_current_user_id();
852
  $sql_join .= $wpdb->prepare( " AND CAST(loim.meta_value AS SIGNED) IN "
853
+ . " ( "
854
+ . " SELECT ID FROM {$wpdb->posts} p WHERE p.ID = CAST(loim.meta_value AS SIGNED) AND `post_author`=" . intval( $user_id )
855
+ . " ) " );
856
  }
857
  $query_join .= $wpdb->prepare( $sql_join, $course_id );
858
 
859
  } elseif ( 'category' === $report_sales_by ) {
860
  $sql_join .= " INNER JOIN `{$wpdb->prefix}learnpress_order_items` `lpoi` "
861
+ . " ON o.ID=lpoi.order_id "
862
+ . " INNER JOIN {$wpdb->prefix}learnpress_order_itemmeta loim "
863
+ . " ON lpoi.order_item_id=loim.learnpress_order_item_id "
864
+ . " AND loim.meta_key='_course_id' "
865
+ . " AND CAST(loim.meta_value AS SIGNED) IN("
866
+ //sub query
867
+ . " SELECT tr.object_id "
868
+ . " FROM wp_term_taxonomy tt INNER JOIN wp_term_relationships tr "
869
+ . " ON tt.term_taxonomy_id = tr.term_taxonomy_id AND tt.taxonomy='course_category' "
870
+ . " WHERE tt.term_id=%d)";
871
  $query_join .= $wpdb->prepare( $sql_join, $cat_id );
872
  }
873
  if ( current_user_can( LP_TEACHER_ROLE ) ) {
896
  if ( $_results = $wpdb->get_results( $query ) ) {
897
  foreach ( $_results as $k => $v ) {
898
  // $results['all'][$v->d] = $v;
899
+ $results['completed'][ $v->d ] = $v;
900
  }
901
  }
902
 
913
  if ( $_results = $wpdb->get_results( $query ) ) {
914
  foreach ( $_results as $k => $v ) {
915
  // $results['completed'][$v->d] = $v;
916
+ $results['pending'][ $v->d ] = $v;
917
  }
918
  }
919
 
923
  $labels[] = date( $date_format, $date );
924
  $key = date( $_key_format, $date );
925
 
926
+ $completed = ! empty( $results['completed'][ $key ] ) ? $results['completed'][ $key ]->c : 0;
927
+ $pending = ! empty( $results['pending'][ $key ] ) ? $results['pending'][ $key ]->c : 0;
928
  $all = $completed + $pending;
929
 
930
  $datasets[0]['data'][] = $all;
951
  );
952
 
953
  foreach ( $dataset_params as $k => $v ) {
954
+ $datasets[ $k ]['fillColor'] = sprintf( $v['color1'], '0.2' );
955
+ $datasets[ $k ]['strokeColor'] = sprintf( $v['color1'], '1' );
956
+ $datasets[ $k ]['pointColor'] = sprintf( $v['color1'], '1' );
957
+ $datasets[ $k ]['pointStrokeColor'] = $v['color2'];
958
+ $datasets[ $k ]['pointHighlightFill'] = $v['color2'];
959
+ $datasets[ $k ]['pointHighlightStroke'] = sprintf( $v['color1'], '1' );
960
+ $datasets[ $k ]['label'] = $v['label'];
961
  }
962
 
963
  return array(
971
  * Get data about courses to render in the chart
972
  * @return array
973
  */
974
+ function learn_press_get_chart_courses2 () {
975
  $labels = array(
976
  __( 'Pending Courses / Publish Courses', 'learnpress' ),
977
  __( 'Free Courses / Priced Courses', 'learnpress' )
1002
  * Get colors setting up by admin user
1003
  * @return array
1004
  */
1005
+ function learn_press_get_admin_colors () {
1006
  $admin_color = get_user_meta( get_current_user_id(), 'admin_color', true );
1007
  global $_wp_admin_css_colors;
1008
  $colors = array();
1009
+ if ( ! empty( $_wp_admin_css_colors[ $admin_color ]->colors ) ) {
1010
+ $colors = $_wp_admin_css_colors[ $admin_color ]->colors;
1011
  }
1012
  if ( empty ( $colors[0] ) ) {
1013
  $colors[0] = '#000000';
1024
  *
1025
  * @param array $chart
1026
  */
1027
+ function learn_press_process_chart ( $chart = array() ) {
1028
  $data = json_encode(
1029
  array(
1030
  'labels' => $chart['labels'],
1037
  /**
1038
  * Print out the configuration for admin chart
1039
  */
1040
+ function learn_press_config_chart () {
1041
  $colors = learn_press_get_admin_colors();
1042
  $config = array(
1043
  'scaleShowGridLines' => true,
1064
  echo json_encode( $config );
1065
  }
1066
 
1067
+ function set_post_order_in_admin ( $wp_query ) {
1068
  global $pagenow;
1069
  if ( isset( $_GET['post_type'] ) ) {
1070
  $post_type = $_GET['post_type'];
1071
  } else {
1072
  $post_type = '';
1073
  }
1074
+ if ( is_admin() && 'edit.php' == $pagenow && $post_type == LP_COURSE_CPT && ! isset( $_GET['orderby'] ) ) {
1075
  $wp_query->set( 'orderby', 'date' );
1076
  $wp_query->set( 'order', 'DSC' );
1077
  }
1085
  *
1086
  * @return mixed
1087
  */
1088
+ function learn_press_add_row_action_link ( $actions ) {
1089
  global $post;
1090
  if ( LP_COURSE_CPT == $post->post_type ) {
1091
  $duplicate_link = admin_url( 'edit.php?post_type=lp_course&action=lp-duplicate-course&post=' . $post->ID . '&nonce=' . wp_create_nonce( 'lp-duplicate-' . $post->ID ) );
1132
  add_filter( 'post_row_actions', 'learn_press_add_row_action_link' );
1133
  add_filter( 'page_row_actions', 'learn_press_add_row_action_link' );
1134
 
1135
+ function learn_press_copy_post_meta ( $from_id, $to_id ) {
1136
  global $wpdb;
1137
  $course_meta = $wpdb->get_results(
1138
  $wpdb->prepare( "SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id = %d", $from_id )
1158
  *
1159
  * @author TuNN
1160
  */
1161
+ function learn_press_process_duplicate_action () {
1162
 
1163
  $wp_list_table = _get_list_table( 'WP_Posts_List_Table' );
1164
  $action = $wp_list_table->current_action();
1166
  if ( isset( $_REQUEST['action'] ) && $action == 'lp-duplicate-course' ) {
1167
  // current is not usefully because this feature using ajax action
1168
  $post_id = isset( $_REQUEST['post'] ) ? $_REQUEST['post'] : 0;
1169
+ $nonce = ! empty( $_REQUEST['nonce'] ) ? $_REQUEST['nonce'] : '';
1170
+ if ( ! wp_verify_nonce( $nonce, 'lp-duplicate-' . $post_id ) ) {
1171
  wp_die( __( 'Error', 'learnpress' ) );
1172
  }
1173
  if ( $post_id && is_array( $post_id ) ) {
1174
  $post_id = array_shift( $post_id );
1175
  }
1176
  // check for post is exists
1177
+ if ( ! ( $post_id && $post = get_post( $post_id ) ) ) {
1178
  wp_die( __( 'Oops! The course does not exist.', 'learnpress' ) );
1179
  }
1180
  // ensure that user can create course
1181
+ if ( ! current_user_can( 'edit_posts' ) ) {
1182
  wp_die( __( 'Sorry! You have not permission to duplicate this course.', 'learnpress' ) );
1183
  }
1184
 
1206
  // insert new course and get it ID
1207
  $new_post_id = wp_insert_post( $args );
1208
 
1209
+ if ( ! $new_post_id ) {
1210
  LP_Admin_Notice::add_redirect( __( '<p>Sorry! Duplicate course failed!</p>', 'learnpress' ) );
1211
  wp_redirect( admin_url( 'edit.php?post_type=lp_course' ) );
1212
  exit();
1249
  ", $section->section_id );
1250
  if ( $items = $wpdb->get_results( $query ) ) {
1251
  foreach ( $items as $item ) {
1252
+ $item_args = (array)$item;
1253
  unset(
1254
  $item_args['ID'],
1255
  $item_args['post_author'],
1274
  }
1275
 
1276
  // duplicate action
1277
+ $action = ! empty( $_REQUEST['lp-action'] ) ? $_REQUEST['lp-action'] : '';
1278
  $actions = array(
1279
  'lp-duplicate-question',
1280
  'lp-duplicate-lesson',
1281
  'lp-duplicate-quiz'
1282
  );
1283
+ if ( ! in_array( $action, $actions ) ) {
1284
  return;
1285
  }
1286
 
1287
+ $post_id = ! empty ( $_REQUEST['post'] ) ? $_REQUEST['post'] : 0;
1288
+ $nonce = ! empty( $_REQUEST['nonce'] ) ? $_REQUEST['nonce'] : '';
1289
+ if ( ! $post_id || ! wp_verify_nonce( $nonce, 'lp-duplicate-' . $post_id ) ) {
1290
  return;
1291
  }
1292
  // only duplicate question. not assign any data
1308
  $success = __( 'Quiz duplicated.', 'learnpress' );
1309
  }
1310
 
1311
+ if ( ! $new_post_id ) {
1312
  return;
1313
  }
1314
  $redirect = 0;
1335
  *
1336
  * @return array
1337
  */
1338
+ function learn_press_install_add_on ( $plugin_name ) {
1339
  require_once( LP_PLUGIN_PATH . '/inc/admin/class-lp-upgrader.php' );
1340
  $upgrader = new LP_Upgrader();
1341
  global $wp_filesystem;
1378
  return $response;
1379
  }
1380
 
1381
+ function learn_press_accept_become_a_teacher () {
1382
+ $action = ! empty( $_REQUEST['action'] ) ? $_REQUEST['action'] : '';
1383
+ $user_id = ! empty( $_REQUEST['user_id'] ) ? $_REQUEST['user_id'] : '';
1384
+ if ( ! $action || ! $user_id || ( $action != 'accept-to-be-teacher' ) ) {
1385
  return;
1386
  }
1387
 
1388
+ if ( ! learn_press_user_maybe_is_a_teacher( $user_id ) ) {
1389
  $be_teacher = new WP_User( $user_id );
1390
  $be_teacher->set_role( LP_TEACHER_ROLE );
1391
  delete_transient( 'learn_press_become_teacher_sent_' . $user_id );
1398
 
1399
  add_action( 'plugins_loaded', 'learn_press_accept_become_a_teacher' );
1400
 
1401
+ function learn_press_user_become_a_teacher_notice () {
1402
  if ( $user_id = learn_press_get_request( 'user_id' ) && learn_press_get_request( 'become-a-teacher-accepted' ) == 'yes' ) {
1403
  $user = new WP_User( $user_id );
1404
  ?>
1418
  *
1419
  * @return bool
1420
  */
1421
+ function learn_press_is_plugin_install ( $plugin ) {
1422
  $installed_plugins = get_plugins();
1423
 
1424
+ return isset( $installed_plugins[ $plugin ] );
1425
  }
1426
 
1427
  /**
1431
  *
1432
  * @return mixed
1433
  */
1434
+ function learn_press_plugin_basename_from_slug ( $slug ) {
1435
  $keys = array_keys( get_plugins() );
1436
  foreach ( $keys as $key ) {
1437
  if ( preg_match( '|^' . $slug . '/|', $key ) ) {
1442
  return $slug;
1443
  }
1444
 
1445
+ function learn_press_one_click_install_sample_data_notice () {
1446
  $courses = get_posts(
1447
  array(
1448
  'post_type' => LP_COURSE_CPT,
1473
 
1474
  //add_action( 'admin_notices', 'learn_press_one_click_install_sample_data_notice' );
1475
 
1476
+ function learn_press_request_query ( $vars = array() ) {
1477
  global $typenow, $wp_query, $wp_post_statuses;
1478
  if ( LP_ORDER_CPT === $typenow ) {
1479
  // Status
1480
+ if ( ! isset( $vars['post_status'] ) ) {
1481
  $post_statuses = learn_press_get_order_statuses();
1482
 
1483
  foreach ( $post_statuses as $status => $value ) {
1484
+ if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) {
1485
+ unset( $post_statuses[ $status ] );
1486
  }
1487
  }
1488
 
1496
 
1497
  add_filter( 'request', 'learn_press_request_query', 0 );
1498
 
1499
+ function _learn_press_reset_course_data () {
1500
  if ( empty( $_REQUEST['reset-course-data'] ) ) {
1501
  return false;
1502
  }
1507
  add_action( 'init', '_learn_press_reset_course_data' );
1508
 
1509
  /***********************/
1510
+ function learn_press_admin_section_loop_item_class ( $item, $section ) {
1511
  $classes = array(
1512
  'lp-section-item'
1513
  );
1514
  $classes[] = 'lp-item-' . $item->post_type;
1515
+ if ( ! absint( $item->ID ) ) {
1516
  $classes[] = 'lp-item-empty lp-item-new focus';
1517
  }
1518
  $classes = apply_filters( 'learn_press_section_loop_item_class', $classes, $item, $section );
1523
  return $classes;
1524
  }
1525
 
1526
+ function learn_press_disable_checked_ontop ( $args ) {
1527
 
1528
  if ( 'course_category' == $args['taxonomy'] ) {
1529
  $args['checked_ontop'] = false;
1534
 
1535
  add_filter( 'wp_terms_checklist_args', 'learn_press_disable_checked_ontop' );
1536
 
1537
+ function learn_press_output_admin_template () {
1538
  learn_press_admin_view( 'admin-template.php' );
1539
  }
1540
 
1541
  add_action( 'admin_print_scripts', 'learn_press_output_admin_template' );
1542
 
1543
+ function learn_press_output_screen_id () {
1544
  $screen = get_current_screen();
1545
  if ( $screen ) {
1546
  echo "<div style=\"position:fixed;top: 0; left:0; z-index: 99999999; background-color:#FFF;padding:4px;\">" . $screen->id . "</div>";
1549
 
1550
  //add_action( 'admin_head', 'learn_press_output_screen_id' );
1551
 
1552
+ function learn_press_get_screens () {
1553
  $screen_id = sanitize_title( __( 'LearnPress', 'learnpress' ) );
1554
  $screens = array(
1555
  'toplevel_page_' . $screen_id,
1566
  return apply_filters( 'learn_press_screen_ids', $screens );
1567
  }
1568
 
1569
+ function learn_press_get_admin_pages () {
1570
  return apply_filters(
1571
  'learn_press_admin_pages',
1572
  array(
1576
  );
1577
  }
1578
 
1579
+ function learn_press_is_post_type_screen ( $post_type, $union = 'OR' ) {
1580
  if ( is_array( $post_type ) ) {
1581
  $return = null;
1582
  foreach ( $post_type as $_post_type ) {
1597
  return $return;
1598
  }
1599
  $screen = get_current_screen();
1600
+ if ( ! $screen ) {
1601
  return;
1602
  }
1603
  $screen_id = $screen->id;
1605
  return in_array( $screen_id, array( $post_type, "edit-{$post_type}" ) );
1606
  }
1607
 
1608
+ function learn_press_get_notice_dismiss ( $context, $type = 'transient' ) {
1609
  if ( $type == 'transient' ) {
1610
  return get_transient( 'learn_press_dismiss_notice_' . $context );
1611
  }
1613
  return get_option( 'learn_press_dismiss_notice_' . $context );
1614
  }
1615
 
1616
+ if ( ! function_exists( 'learn_press_course_insert_section' ) ) {
1617
 
1618
+ function learn_press_course_insert_section ( $section = array() ) {
1619
  global $wpdb;
1620
  $section = wp_parse_args(
1621
  $section,
1641
 
1642
  }
1643
 
1644
+ if ( ! function_exists( 'learn_press_course_insert_section_item' ) ) {
1645
 
1646
+ function learn_press_course_insert_section_item ( $item_data = array() ) {
1647
  global $wpdb;
1648
  $wpdb->insert(
1649
  $wpdb->learnpress_section_items,
1666
 
1667
  }
1668
 
1669
+ if ( ! function_exists( 'learn_press_duplicate_post' ) ) {
1670
 
1671
+ function learn_press_duplicate_post ( $post_id = null, $args = array(), $meta = true ) {
1672
  $post = get_post( $post_id );
1673
+ if ( ! $post ) {
1674
  return;
1675
  }
1676
  $defalts = array(
1689
  );
1690
  $args = wp_parse_args( $args, $defalts );
1691
  $new_post_id = wp_insert_post( $args );
1692
+ if ( ! is_wp_error( $new_post_id ) && $meta ) {
1693
  learn_press_duplicate_post_meta( $post_id, $new_post_id );
1694
  // assign related tags/categories to new course
1695
  $taxonomies = get_object_taxonomies( $post->post_type );
1703
  }
1704
  }
1705
 
1706
+ if ( ! function_exists( 'learn_press_duplicate_post_meta' ) ) {
1707
  /**
1708
  * duplicate all post meta just in two SQL queries
1709
  */
1710
+ function learn_press_duplicate_post_meta ( $old_post_id, $new_post_id, $excerpt = array() ) {
1711
  global $wpdb;
1712
  $post_meta_infos = $wpdb->get_results( "SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id=$old_post_id" );
1713
  if ( count( $post_meta_infos ) != 0 ) {
1714
  $excerpt = array_merge( array( '_edit_lock', '_edit_last' ), $excerpt );
1715
+ $excerpt = apply_filters('learn_press_excerpt_duplicate_post_meta', $excerpt, $old_post_id, $new_post_id);
1716
  $sql_query = "INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) ";
1717
  $sql_query_sel = array();
1718
  foreach ( $post_meta_infos as $meta ) {
1719
  if ( in_array( $meta->meta_key, $excerpt ) ) {
1720
  continue;
1721
  }
1722
+ if ($meta->meta_key === '_lp_course_author') {
1723
  $meta->meta_value = get_current_user_id();
1724
  }
1725
  $meta_key = $meta->meta_key;
1734
  }
1735
 
1736
  add_filter( 'learn_press_question_types', 'learn_press_sort_questions', 99 );
1737
+ if ( ! function_exists( 'learn_press_sort_questions' ) ) {
1738
+ function learn_press_sort_questions ( $types ) {
1739
  $user_id = get_current_user_id();
1740
  $question_types = get_user_meta( $user_id, '_learn_press_memorize_question_types', true );
1741
+ if ( ! empty( $question_types ) ) {
1742
  $sort = array();
1743
  // re-sort array descending
1744
  arsort( $question_types );
1747
 
1748
  for ( $i = 0; $i < count( $ktypes ) - 1; $i ++ ) {
1749
  $max = $i;
1750
+ if ( ! isset( $question_types[ $ktypes[ $i ] ] ) ) {
1751
+ $question_types[ $ktypes[ $i ] ] = 0;
1752
  }
1753
  for ( $j = $i + 1; $j < count( $ktypes ); $j ++ ) {
1754
+ if ( isset( $question_types[ $ktypes[ $j ] ], $question_types[ $ktypes[ $max ] ] )
1755
+ && $question_types[ $ktypes[ $j ] ] > $question_types[ $ktypes[ $max ] ]
1756
  ) {
1757
  $max = $j;
1758
  }
1759
  }
1760
+ $tmp = $ktypes[ $i ];
1761
+ $ktypes[ $i ] = $ktypes[ $max ];
1762
+ $ktypes[ $max ] = $tmp;
1763
  }
1764
  $ktypes = array_flip( $ktypes );
1765
  $types = array_merge( $ktypes, $types );
1769
  }
1770
  }
1771
 
1772
+ if ( ! function_exists( 'learn_press_duplicate_course' ) ) {
1773
 
1774
+ function learn_press_duplicate_course ( $course_id = null, $force = true ) {
1775
+ if ( ! function_exists( '_learn_press_get_course_curriculum' ) ) {
1776
  require_once LP_PLUGIN_PATH . 'inc/lp-init.php';
1777
  }
1778
  global $wpdb;
1781
  $course_id = array_shift( $course_id );
1782
  }
1783
  // check for post is exists
1784
+ if ( ! $course_id || ! ( $post = get_post( $course_id ) ) ) {
1785
  return new WP_Error( __( '<p>Op! The course does not exist</p>', 'learnpress' ) );
1786
  } else {
1787
  // ensure that user can create course
1788
+ if ( ! current_user_can( 'edit_posts' ) ) {
1789
  return new WP_Error( __( '<p>Sorry! You have not permission to duplicate this course</p>', 'learnpress' ) );
1790
  } else {
1791
  // duplicate course
1792
  $new_course_id = learn_press_duplicate_post( $course_id );
1793
+ if ( ! $new_course_id || is_wp_error( $new_course_id ) ) {
1794
  return new WP_Error( __( '<p>Sorry! Duplicate course failed!</p>', 'learnpress' ) );
1795
  } else {
1796
  $curriculums = _learn_press_get_course_curriculum( $course_id );
1830
 
1831
  }
1832
 
1833
+ if ( ! function_exists( 'learn_press_duplicate_question' ) ) {
1834
 
1835
+ function learn_press_duplicate_question ( $question_id = null, $quiz_id = null ) {
1836
+ if ( ! $question_id || ! get_post( $question_id ) ) {
1837
  return new WP_Error( sprintf( __( 'Question id %s is not exists.', 'learnpress' ), $question_id ) );
1838
  }
1839
+ if ( $quiz_id && ! get_post( $quiz_id ) ) {
1840
  return new WP_Error( sprintf( __( 'Quiz id %s is not exists.', 'learnpress' ), $quiz_id ) );
1841
  }
1842
 
1896
 
1897
  }
1898
 
1899
+ if ( ! function_exists( 'learn_press_duplicate_quiz' ) ) {
1900
 
1901
+ function learn_press_duplicate_quiz ( $quiz_id = null, $args = array() ) {
1902
  global $wpdb;
1903
  $new_quiz_id = learn_press_duplicate_post( $quiz_id, $args, true );
1904
  $quiz = LP_Quiz::get_quiz( $quiz_id );
1966
  *
1967
  * @return string
1968
  */
1969
+ function learn_press_get_file_version ( $file ) {
1970
+ if ( ! file_exists( $file ) ) {
1971
  return '';
1972
  }
1973
  $fp = fopen( $file, 'r' );
1989
  *
1990
  * @return array|bool
1991
  */
1992
+ function learn_press_get_theme_templates ( $check = false ) {
1993
  $template_folder = learn_press_template_path();
1994
  $template_path = LP_PLUGIN_PATH . '/templates/';
1995
  $template_dir = get_template_directory();
2020
  $theme_file = false;
2021
  }
2022
 
2023
+ if ( ! empty( $theme_file ) ) {
2024
  $core_version = learn_press_get_file_version( $template_path . $file );
2025
  $theme_version = learn_press_get_file_version( $theme_file );
2026
 
2027
  if ( $core_version && ( empty( $theme_version ) || version_compare( $theme_version, $core_version, '<' ) ) ) {
2028
+ if ( ! $outdated_templates ) {
2029
  $outdated_templates = true;
2030
  }
2031
+ $found_files[ $theme_folder ][] = array(
2032
  str_replace( WP_CONTENT_DIR . '/themes/', '', $theme_file ),
2033
  $theme_version ? $theme_version : '-',
2034
  $core_version,
2035
  true
2036
  );
2037
  } else {
2038
+ $found_files[ $theme_folder ][] = array(
2039
  str_replace( WP_CONTENT_DIR . '/themes/', '', $theme_file ),
2040
  $theme_version ? $theme_version : '?',
2041
  $core_version ? $core_version : '?',
2048
  }
2049
  }
2050
  if ( sizeof( $found_files ) > 1 ) {
2051
+ $found_files = array_merge( $found_files[ $t_folder ], $found_files[ $s_folder ] );
2052
  } else {
2053
  $found_files = reset( $found_files );
2054
  }
2056
  return $check ? $outdated_templates : $found_files;
2057
  }
2058
 
2059
+ function learn_press_detect_outdated_template () {
2060
  $template_folder = learn_press_template_path();
2061
  $template_path = LP_PLUGIN_PATH . '/templates/';
2062
  $template_dir = get_template_directory();
2093
  }
2094
  }
2095
 
2096
+ if ( ! empty( $theme_file ) ) {
2097
  $core_version = learn_press_get_file_version( $template_path . $file );
2098
  $theme_version = learn_press_get_file_version( $theme_file );
2099
 
2106
  }
2107
  }
2108
  }
2109
+ if ( ! empty( $child_item ) || ! empty( $parent_item ) ) {
2110
 
2111
  return array(
2112
  'parent_item' => $parent_item,
2117
  return false;
2118
  }
2119
 
2120
+ function learn_press_scan_template_files ( $template_path ) {
2121
 
2122
  $files = @scandir( $template_path );
2123
  $result = array();
2124
 
2125
+ if ( ! empty( $files ) ) {
2126
  foreach ( $files as $key => $value ) {
2127
+ if ( ! in_array( $value, array( ".", "..", 'index.php', 'index.html' ) ) ) {
2128
  if ( is_dir( $template_path . '/' . $value ) ) {
2129
  $sub_files = learn_press_scan_template_files( $template_path . '/' . $value );
2130
  foreach ( $sub_files as $sub_file ) {
2140
  return $result;
2141
  }
2142
 
2143
+ if ( ! function_exists( 'learn_press_duplicate_lesson' ) ) {
2144
 
2145
+ function learn_press_duplicate_lesson ( $lesson_id = null ) {
2146
  return learn_press_duplicate_post( $lesson_id );
2147
  }
2148
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2149
  }
inc/admin/meta-boxes/class-course-tabs-field.php CHANGED
@@ -11,7 +11,7 @@ if ( !class_exists( 'RWMB_Course_Tabs_Field' ) ) {
11
  * @class RWMB_Course_lesson_Quiz_Field
12
  */
13
  class RWMB_Course_Tabs_Field extends RWMB_Field {
14
- public static function html( $meta, $field ) {
15
  ob_start();
16
  learn_press_admin_view( 'meta-boxes/course/tabs.php' );
17
  return ob_get_clean();
11
  * @class RWMB_Course_lesson_Quiz_Field
12
  */
13
  class RWMB_Course_Tabs_Field extends RWMB_Field {
14
+ public static function html() {
15
  ob_start();
16
  learn_press_admin_view( 'meta-boxes/course/tabs.php' );
17
  return ob_get_clean();
inc/admin/meta-boxes/class-curriculum-field.php ADDED
@@ -0,0 +1,316 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Prevent loading this file directly
3
+ defined( 'ABSPATH' ) || exit;
4
+
5
+ if ( !class_exists( 'RWMB_Curriculum_Field' ) ) {
6
+ /**
7
+ * Thim Theme
8
+ *
9
+ * Manage Course, Lesson, Quiz
10
+ *
11
+ * @class RWMB_Course_lesson_Quiz_Field
12
+ */
13
+ class RWMB_Curriculum_Field extends RWMB_Field {
14
+ /**
15
+ * Enqueue scripts and styles
16
+ *
17
+ * @return void
18
+ */
19
+ public static function admin_enqueue_scripts() {
20
+
21
+ LP_Assets::enqueue_script( 'learn-press-modal-search-items' );
22
+ LP_Assets::add_localize(
23
+ array(
24
+ 'confirm_remove_section_lesson' => __( 'Do you want to remove this lesson permanently?', 'learnpress' ),
25
+ 'confirm_remove_section_quiz' => __( 'Do you want to remove this quiz permanently?', 'learnpress' ),
26
+ 'confirm_remove_section' => __( 'Do you want to remove this section permanently?', 'learnpress' ),
27
+ 'add_new_quiz' => __( 'New quiz added', 'learnpress' ),
28
+ 'add_new_lesson' => __( 'New lesson added', 'learnpress' ),
29
+ 'add_new_section' => __( 'New section added', 'learnpress' ),
30
+ 'remove_section_lesson' => __( 'The lesson removed', 'learnpress' ),
31
+ 'remove_section_quiz' => __( 'The quiz removed', 'learnpress' ),
32
+ 'remove_section' => __( 'The section removed', 'learnpress' ),
33
+ 'section_ordered' => __( 'The ordering completed', 'learnpress' ),
34
+ 'add_lesson_to_section' => __( 'Lesson added to section completed!', 'learnpress' ),
35
+ 'add_quiz_to_section' => __( 'Quiz added to section completed!', 'learnpress' ),
36
+ 'update_lesson_quiz' => __( '%s updated', 'learnpress' ),
37
+ 'quick_edit_name' => __( 'Click to quick edit name', 'learnpress' ),
38
+ 'save_course' => __( 'Save Course', 'learnpress' ),
39
+ 'submit_course_review' => __( 'Submit for Review', 'learnpress' )
40
+ ), null, 'learn-press-mb-course'
41
+ );
42
+ }
43
+
44
+ /**
45
+ * Get field HTML
46
+ *
47
+ * @param mixed $meta
48
+ * @param array $field
49
+ *
50
+ * @return string
51
+ */
52
+ public static function html( $meta, $field ) {
53
+ global $post;
54
+ $course = LP_Course::get_course( $post );
55
+ $view = learn_press_get_admin_view( 'meta-boxes/course/curriculum.php' );
56
+ ob_start();
57
+ include $view;
58
+ return ob_get_clean();
59
+ }
60
+
61
+ /**
62
+ * Normalize parameters for field
63
+ *
64
+ * @param array $field
65
+ *
66
+ * @return array
67
+ */
68
+ public static function normalize_field( $field ) {
69
+ $field = wp_parse_args( $field, array(
70
+ 'size' => 30,
71
+ 'datalist' => false,
72
+ 'placeholder' => '',
73
+ ) );
74
+
75
+ return $field;
76
+ }
77
+
78
+ /**
79
+ * Create datalist, if any
80
+ *
81
+ * @param array $field
82
+ *
83
+ * @return array
84
+ */
85
+ public static function datalist_html( $field ) {
86
+ if ( !$field['datalist'] ) {
87
+ return '';
88
+ }
89
+
90
+ $datalist = $field['datalist'];
91
+ $html = sprintf(
92
+ '<datalist id="%s">',
93
+ $datalist['id']
94
+ );
95
+
96
+ foreach ( $datalist['options'] as $option ) {
97
+ $html .= sprintf( '<option value="%s"></option>', $option );
98
+ }
99
+
100
+ $html .= '</datalist>';
101
+
102
+ return $html;
103
+ }
104
+
105
+ /**
106
+ * Save meta value
107
+ * If field is cloneable, value is saved as a single entry in DB
108
+ * Otherwise value is saved as multiple entries (for backward compatibility)
109
+ *
110
+ * TODO: A good way to ALWAYS save values in single entry in DB, while maintaining backward compatibility
111
+ *
112
+ * @param $new
113
+ * @param $old
114
+ * @param $post_id
115
+ * @param $field
116
+ */
117
+ public static function save( $new, $old, $post_id, $field ) {
118
+
119
+ if ( empty( $new ) ) {
120
+ delete_post_meta( $post_id, $field['id'] );
121
+ } else {
122
+ $new = array_values( $new );
123
+ for ( $n = count( $new ), $i = $n - 1; $i >= 0; $i -- ) {
124
+ if ( !$new[$i]['name'] ) unset( $new[$i] );
125
+ }
126
+ $new = array_values( $new );
127
+ update_post_meta( $post_id, $field['id'], $new );
128
+ }
129
+ }
130
+
131
+ public static function add_actions() {
132
+ // Do same actions as file field
133
+ parent::add_actions();
134
+
135
+ /*add_action( 'wp_ajax_lpr_quick_add', array( __CLASS__, 'quick_add' ) );
136
+ add_action( 'wp_ajax_lpr_update_course_curriculum', array( __CLASS__, 'update_course_curriculum' ) );
137
+ add_action( 'wp_ajax_lpr_quick_edit_lesson_quiz_name', array( __CLASS__, 'quick_edit_lesson_quiz_name' ) );
138
+ add_action( 'wp_ajax_lpr_update_section_state', array( __CLASS__, 'update_section_state' ) );
139
+ add_action( 'wp_ajax_lpr_remove_lesson_quiz', array( __CLASS__, 'remove_lesson_quiz' ) );*/
140
+
141
+ ///add_action( 'save_post', array( __CLASS__, 'update_course_curriculum' ) );
142
+ add_filter( 'learn_press_loop_section_buttons', array( __CLASS__, 'add_section_buttons' ) );
143
+ //add_filter( 'learn_press_after_section_content', array( __CLASS__, 'section_options' ) );
144
+ }
145
+
146
+ public static function add_section_buttons( $buttons ) {
147
+ $buttons = array_merge(
148
+ $buttons,
149
+ array(
150
+ array(
151
+ 'id' => 'add-lesson',
152
+ 'text' => __( 'Add Lesson', 'learnpress' ),
153
+ 'attr' => 'data-action="add-lesson" data-type="lp_lesson"'
154
+ ),
155
+ array(
156
+ 'id' => 'add-quiz',
157
+ 'text' => __( 'Add Quiz', 'learnpress' ),
158
+ 'attr' => 'data-action="add-quiz" data-type="lp_quiz"'
159
+ )
160
+ )
161
+ );
162
+ return $buttons;
163
+ }
164
+
165
+ public static function section_options() {
166
+ ?>
167
+ <table class="form-table">
168
+ <tr>
169
+ <th>
170
+ <?php _e( 'Using final quiz', 'learnpress' ); ?>
171
+ </th>
172
+ <td>
173
+ <input type="checkbox" />
174
+
175
+ <p class="description"><?php _e( 'User must be complete the final quiz to finish a section.', 'learnpress' ); ?></p>
176
+
177
+ </td>
178
+ </tr>
179
+ </table>
180
+ <?php
181
+ }
182
+
183
+ public static function remove_lesson_quiz() {
184
+ $lesson_quiz_id = $_POST['lesson_quiz_id'];
185
+ delete_post_meta( $lesson_quiz_id, '_lpr_course' );
186
+ update_post_meta( $lesson_quiz_id, '_lpr_course', 0 );
187
+ }
188
+
189
+ public static function update_section_state() {
190
+ $post_id = $_POST['post_id'];
191
+ $section = $_POST['section'];
192
+ update_post_meta( $post_id, '_lpr_course_section_state', $section );
193
+ die();
194
+ }
195
+
196
+ public static function quick_add() {
197
+ //ob_end_flush();
198
+ echo '__LP_JSON__';
199
+ $name = isset( $_POST['name'] ) ? $_POST['name'] : null;
200
+ $type = isset( $_POST['type'] ) ? $_POST['type'] : null;
201
+ $course_id = isset( $_POST['course_id'] ) ? $_POST['course_id'] : null;
202
+ $post = false;
203
+ if ( $name && $type ) {
204
+ $post_id = wp_insert_post(
205
+ array(
206
+ 'post_title' => $name,
207
+ 'post_type' => $type == 'lesson' ? LP_LESSON_CPT : LP_QUIZ_CPT,
208
+ 'post_status' => 'publish'
209
+ )
210
+ );
211
+ if ( $post_id ) {
212
+ $post = get_post( $post_id );
213
+ if ( $course_id ) {
214
+ update_post_meta( $post_id, '_lpr_course', $course_id );
215
+ }
216
+ }
217
+ }
218
+ wp_send_json( $post );
219
+ die();
220
+ }
221
+
222
+ public static function quick_edit_lesson_quiz_name() {
223
+ $id = isset( $_POST['id'] ) ? intval( $_POST['id'] ) : 0;
224
+ echo '__LP_JSON__';
225
+ if ( $id ) {
226
+ $name = $_POST['name'];
227
+ $slug = sanitize_title( $name );
228
+ $post_id = wp_update_post(
229
+ array(
230
+ 'ID' => $id,
231
+ 'post_title' => $name,
232
+ 'post_name' => $slug
233
+ )
234
+ );
235
+ if ( $post_id ) {
236
+ wp_send_json( get_post( $post_id ) );
237
+ }
238
+ }
239
+
240
+ }
241
+
242
+ public static function update_course_curriculum() {
243
+
244
+ $is_ajax = false;
245
+ if ( !empty( $_REQUEST['action'] ) && 'lpr_update_course_curriculum' == $_REQUEST['action'] ) {
246
+ $course_id = isset( $_POST['course_id'] ) ? intval( $_POST['course_id'] ) : 0;
247
+ $is_ajax = true;
248
+ } else {
249
+ if ( LP_COURSE_CPT != get_post_type() ) return;
250
+ global $post;
251
+ $course_id = $post->ID;
252
+ }
253
+ $meta_key = isset( $_POST['meta_key'] ) ? $_POST['meta_key'] : '_lpr_course_lesson_quiz';
254
+ $metadata = isset( $_POST['_lpr_course_lesson_quiz'] ) ? $_POST['_lpr_course_lesson_quiz'] : false;
255
+ if ( !$course_id ) {
256
+ echo '__LP_JSON__';
257
+ wp_send_json(
258
+ array(
259
+ 'message' => __( 'The course is empty', 'learnpress' )
260
+ )
261
+ );
262
+ }
263
+
264
+ $metadata = apply_filters( 'learn_press_course_curriculum', $metadata, $course_id );
265
+ update_post_meta( $course_id, $meta_key, $metadata );
266
+ do_action( 'learn_press_update_course_curriculum', $course_id, $metadata );
267
+
268
+ //
269
+ global $wpdb;
270
+ if ( $metadata ) foreach ( $metadata as $section ) {
271
+ if ( !empty( $section['lesson_quiz'] ) && $lesson_quiz = $section['lesson_quiz'] ) {
272
+ $query = $wpdb->prepare( "
273
+ DELETE FROM {$wpdb->postmeta}
274
+ WHERE meta_key = %s
275
+ AND ( meta_value = %d OR meta_value = %d OR meta_value = %s )
276
+ AND post_id IN(" . join( ',', $lesson_quiz ) . ")
277
+ ", '_lpr_course', $course_id, 0, '' );
278
+
279
+ $wpdb->query( $query );
280
+
281
+ $query = "INSERT INTO {$wpdb->postmeta}(`post_id`, `meta_key`, `meta_value`) VALUES";
282
+ $query_values = array();
283
+ foreach ( $lesson_quiz as $id ) {
284
+ $query_values[] = $wpdb->prepare( "(%d, %s, %d)", $id, '_lpr_course', $course_id );
285
+ }
286
+ $query .= join( ",", $query_values );
287
+ $wpdb->query( $query );
288
+ }
289
+ }
290
+ if ( !$is_ajax ) return;
291
+ wp_send_json(
292
+ array(
293
+ 'message' => __( 'Success', 'learnpress' )
294
+ )
295
+ );
296
+ }
297
+
298
+ public static function meta( $post_id, $saved, $field ) {
299
+ $meta = get_post_meta( $post_id, $field['id'], true );
300
+
301
+ // Use $field['std'] only when the meta box hasn't been saved (i.e. the first time we run)
302
+ $meta = ( !$saved && '' === $meta || array() === $meta ) ? $field['std'] : $meta;
303
+
304
+ // Escape attributes for non-wysiwyg fields
305
+ if ( 'wysiwyg' !== $field['type'] ) {
306
+ //$meta = is_array( $meta ) ? array_map( 'esc_attr', $meta ) : esc_attr( $meta );
307
+ }
308
+
309
+ return $meta;
310
+ }
311
+
312
+ public static function cleanHeader() {
313
+
314
+ }
315
+ }
316
+ }
inc/admin/meta-boxes/class-meta-box-tabs.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Prevent loading this file directly
3
+ defined( 'ABSPATH' ) || exit;
4
+
5
+ if ( !class_exists( 'RWMB_Meta_Box_Tabs_Field' ) ) {
6
+ /**
7
+ * Thim Theme
8
+ *
9
+ * Manage Course, Lesson, Quiz
10
+ *
11
+ * @class RWMB_Course_lesson_Quiz_Field
12
+ */
13
+ class RWMB_Meta_Box_Tabs_Field extends RWMB_Field {
14
+ public static function html() {
15
+ echo 'xxxxxxxxxxxxxx';
16
+ }
17
+ }
18
+ }
inc/admin/settings/class-lp-settings-emails.php CHANGED
@@ -7,7 +7,7 @@
7
  * @package LearnPress/Classes
8
  * @version 1.0
9
  */
10
- if ( ! defined( 'ABSPATH' ) ) {
11
  exit; // Exit if accessed directly
12
  }
13
 
@@ -20,7 +20,7 @@ class LP_Settings_Emails extends LP_Settings_Base {
20
  /**
21
  * Constructor
22
  */
23
- public function __construct () {
24
  $this->id = 'emails';
25
  $this->text = __( 'Emails', 'learnpress' );
26
  parent::__construct();
@@ -31,7 +31,7 @@ class LP_Settings_Emails extends LP_Settings_Base {
31
  *
32
  * @return mixed
33
  */
34
- public function get_sections () {
35
 
36
  $emails = LP_Emails::instance()->emails;
37
 
@@ -39,14 +39,13 @@ class LP_Settings_Emails extends LP_Settings_Base {
39
  'general' => array( 'id' => 'general', 'title' => __( 'General options', 'learnpress' ) )
40
  );
41
 
42
- if ( $emails ) {
43
  foreach ( $emails as $email ) {
44
- $sections[ $email->id ] = array(
45
  'id' => $email->id,
46
  'title' => $email->title
47
  );
48
  }
49
- }
50
 
51
  /* $sections = array(
52
  'general' => __( 'General options', 'learnpress' ),
@@ -56,14 +55,13 @@ class LP_Settings_Emails extends LP_Settings_Base {
56
  'enrolled_course' => __( 'Enrolled course', 'learnpress' ),
57
  'passed_course' => __( 'Passed course', 'learnpress' ),
58
  ); */
59
-
60
  return $sections = apply_filters( 'learn_press_settings_sections_' . $this->id, $sections );
61
  }
62
 
63
  /**
64
  * @param $default_message
65
  */
66
- public function message_editor ( $default_message ) {
67
  $settings = LP()->settings;
68
  $content = stripslashes( $settings->get( $this->section['id'] . '.message', $default_message ) );
69
  $editor_id = 'email_message';
@@ -76,100 +74,80 @@ class LP_Settings_Emails extends LP_Settings_Base {
76
  );
77
  }
78
 
79
- public function get_email_class ( $id ) {
80
  $emails = LP_Emails::instance()->emails;
81
- if ( $emails ) {
82
  foreach ( $emails as $email ) {
83
  if ( $email->id == $id ) {
84
  return $email;
85
  }
86
  }
87
- }
88
-
89
  return false;
90
  }
91
 
92
  /**
93
  *
94
  */
95
- public function output_section_general () {
96
  $view = learn_press_get_admin_view( 'settings/emails/general.php' );
97
  include_once $view;
98
  }
99
 
100
- public function output_section_new_course () {
101
  if ( $email = $this->get_email_class( 'new_course' ) ) {
102
  $email->admin_options( $this );
103
  }
104
  }
105
 
106
- public function output_section_user_order_completed () {
107
  if ( $email = $this->get_email_class( 'user_order_completed' ) ) {
108
  $email->admin_options( $this );
109
  }
110
  }
111
 
112
- public function output_section_user_order_changed_status () {
113
- if ( $email = $this->get_email_class( 'user_order_changed_status' ) ) {
114
- $email->admin_options( $this );
115
- }
116
- }
117
-
118
- public function output_section_rejected_course () {
119
  if ( $email = $this->get_email_class( 'rejected_course' ) ) {
120
  $email->admin_options( $this );
121
  }
122
  }
123
 
124
- public function output_section_new_order () {
125
  if ( $email = $this->get_email_class( 'new_order' ) ) {
126
  $email->admin_options( $this );
127
  }
128
  }
129
 
130
- public function output_section_new_order_customer () {
131
  if ( $email = $this->get_email_class( 'new_order_customer' ) ) {
132
  $email->admin_options( $this );
133
  }
134
  }
135
 
136
- public function output_section_published_course () {
137
  if ( $email = $this->get_email_class( 'published_course' ) ) {
138
  $email->admin_options( $this );
139
  }
140
  }
141
 
142
- public function output_section_enrolled_course () {
143
  if ( $email = $this->get_email_class( 'enrolled_course' ) ) {
144
  $email->admin_options( $this );
145
  }
146
  }
147
 
148
- public function output_section_enrolled_course_admin () {
149
- if ( $email = $this->get_email_class( 'enrolled_course_admin' ) ) {
150
- $email->admin_options( $this );
151
- }
152
- }
153
-
154
- public function output_section_finished_course () {
155
  if ( $email = $this->get_email_class( 'finished_course' ) ) {
156
  $email->admin_options( $this );
157
  }
158
  }
159
 
160
- public function output_section_update_course () {
161
- if ( $email = $this->get_email_class( 'update_course' ) ) {
162
- $email->admin_options( $this );
163
- }
164
- }
165
-
166
- public function output_section_become_an_instructor () {
167
  if ( $email = $this->get_email_class( 'become_an_instructor' ) ) {
168
  $email->admin_options( $this );
169
  }
170
  }
171
 
172
- public function get_settings () {
173
  return apply_filters(
174
  'learn_press_email_settings', array(
175
  array(
@@ -183,11 +161,10 @@ class LP_Settings_Emails extends LP_Settings_Base {
183
  );
184
  }
185
 
186
- public static function instance () {
187
- if ( ! self::$_instance ) {
188
  self::$_instance = new self();
189
  }
190
-
191
  return self::$_instance;
192
  }
193
  }
7
  * @package LearnPress/Classes
8
  * @version 1.0
9
  */
10
+ if ( !defined( 'ABSPATH' ) ) {
11
  exit; // Exit if accessed directly
12
  }
13
 
20
  /**
21
  * Constructor
22
  */
23
+ public function __construct() {
24
  $this->id = 'emails';
25
  $this->text = __( 'Emails', 'learnpress' );
26
  parent::__construct();
31
  *
32
  * @return mixed
33
  */
34
+ public function get_sections() {
35
 
36
  $emails = LP_Emails::instance()->emails;
37
 
39
  'general' => array( 'id' => 'general', 'title' => __( 'General options', 'learnpress' ) )
40
  );
41
 
42
+ if ( $emails )
43
  foreach ( $emails as $email ) {
44
+ $sections[$email->id] = array(
45
  'id' => $email->id,
46
  'title' => $email->title
47
  );
48
  }
 
49
 
50
  /* $sections = array(
51
  'general' => __( 'General options', 'learnpress' ),
55
  'enrolled_course' => __( 'Enrolled course', 'learnpress' ),
56
  'passed_course' => __( 'Passed course', 'learnpress' ),
57
  ); */
 
58
  return $sections = apply_filters( 'learn_press_settings_sections_' . $this->id, $sections );
59
  }
60
 
61
  /**
62
  * @param $default_message
63
  */
64
+ public function message_editor( $default_message ) {
65
  $settings = LP()->settings;
66
  $content = stripslashes( $settings->get( $this->section['id'] . '.message', $default_message ) );
67
  $editor_id = 'email_message';
74
  );
75
  }
76
 
77
+ public function get_email_class( $id ) {
78
  $emails = LP_Emails::instance()->emails;
79
+ if ( $emails )
80
  foreach ( $emails as $email ) {
81
  if ( $email->id == $id ) {
82
  return $email;
83
  }
84
  }
 
 
85
  return false;
86
  }
87
 
88
  /**
89
  *
90
  */
91
+ public function output_section_general() {
92
  $view = learn_press_get_admin_view( 'settings/emails/general.php' );
93
  include_once $view;
94
  }
95
 
96
+ public function output_section_new_course() {
97
  if ( $email = $this->get_email_class( 'new_course' ) ) {
98
  $email->admin_options( $this );
99
  }
100
  }
101
 
102
+ public function output_section_user_order_completed() {
103
  if ( $email = $this->get_email_class( 'user_order_completed' ) ) {
104
  $email->admin_options( $this );
105
  }
106
  }
107
 
108
+ public function output_section_rejected_course() {
 
 
 
 
 
 
109
  if ( $email = $this->get_email_class( 'rejected_course' ) ) {
110
  $email->admin_options( $this );
111
  }
112
  }
113
 
114
+ public function output_section_new_order() {
115
  if ( $email = $this->get_email_class( 'new_order' ) ) {
116
  $email->admin_options( $this );
117
  }
118
  }
119
 
120
+ public function output_section_new_order_customer() {
121
  if ( $email = $this->get_email_class( 'new_order_customer' ) ) {
122
  $email->admin_options( $this );
123
  }
124
  }
125
 
126
+ public function output_section_published_course() {
127
  if ( $email = $this->get_email_class( 'published_course' ) ) {
128
  $email->admin_options( $this );
129
  }
130
  }
131
 
132
+ public function output_section_enrolled_course() {
133
  if ( $email = $this->get_email_class( 'enrolled_course' ) ) {
134
  $email->admin_options( $this );
135
  }
136
  }
137
 
138
+ public function output_section_finished_course() {
 
 
 
 
 
 
139
  if ( $email = $this->get_email_class( 'finished_course' ) ) {
140
  $email->admin_options( $this );
141
  }
142
  }
143
 
144
+ public function output_section_become_an_instructor() {
 
 
 
 
 
 
145
  if ( $email = $this->get_email_class( 'become_an_instructor' ) ) {
146
  $email->admin_options( $this );
147
  }
148
  }
149
 
150
+ public function get_settings() {
151
  return apply_filters(
152
  'learn_press_email_settings', array(
153
  array(
161
  );
162
  }
163
 
164
+ public static function instance() {
165
+ if ( !self::$_instance ) {
166
  self::$_instance = new self();
167
  }
 
168
  return self::$_instance;
169
  }
170
  }
inc/admin/settings/class-lp-settings-general.php CHANGED
@@ -83,17 +83,7 @@ class LP_Settings_General extends LP_Settings_Base {
83
  'default' => 'yes',
84
  'type' => 'checkbox',
85
  'desc' => __( 'Turn on/off debug mode for developer', 'learnpress' )
86
- ),
87
- array(
88
- 'title' => __( 'Logout', 'learnpress' ),
89
- 'type' => 'title'
90
- ),
91
- array(
92
- 'title' => __( 'Redirect to page', 'learnpress' ),
93
- 'id' => $this->get_field_name( 'logout_redirect_page_id' ),
94
- 'default' => '',
95
- 'type' => 'pages-dropdown'
96
- ),
97
  )
98
  );
99
  }
83
  'default' => 'yes',
84
  'type' => 'checkbox',
85
  'desc' => __( 'Turn on/off debug mode for developer', 'learnpress' )
86
+ )
 
 
 
 
 
 
 
 
 
 
87
  )
88
  );
89
  }
inc/admin/views/meta-boxes/course/attributes.php DELETED
@@ -1,45 +0,0 @@
1
-
2
- <?php
3
- global $post;
4
- $postId = $post ? $post->ID : 0;
5
- ?>
6
- <div class="learn-press-course-attributes">
7
- <?php
8
- $attributes = learn_press_get_attributes();
9
- $course_attributes = learn_press_get_course_attributes( $postId );
10
- if ( $attributes ) {
11
- ?>
12
- <ul class="course-attribute-taxonomy">
13
- <?php foreach ( $attributes as $attribute ) { ?>
14
- <?php
15
- $classes = array( 'button add-attribute' );
16
- if ( $course_attributes && !empty( $course_attributes[$attribute->slug] ) ) {
17
- $classes[] = "disabled";
18
- }
19
-
20
- ?>
21
- <li class="<?php echo join( ' ', $classes ); ?>" data-taxonomy="<?php echo $attribute->slug; ?>"><?php echo $attribute->name; ?></li>
22
- <?php } ?>
23
- </ul>
24
-
25
- <ul class="course-attributes">
26
- <?php
27
- if ( $course_attributes ):
28
- foreach ( $course_attributes as $attribute ) {
29
- include learn_press_get_admin_view( 'meta-boxes/course/html-course-attribute' );
30
- }
31
- endif;
32
- ?>
33
- </ul>
34
-
35
- <button class="button button-primary" type="button" id="save-attributes"><?php _e( 'Save attributes', 'learnpres' ); ?></button>
36
- <?php
37
- } else {
38
- printf( '<p class="description">%s <a class="button button-primary" href="%s">%s</a></p>',
39
- __( 'The is no attribute. Please add course attribute first', 'learnpress' ),
40
- esc_url( admin_url( 'edit-tags.php?taxonomy=course_attribute&post_type=lp_course' ) ),
41
- __( 'Add now', 'learnpress' )
42
- );
43
- }
44
- ?>
45
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/admin/views/meta-boxes/course/curriculum.php CHANGED
@@ -4,41 +4,41 @@ $course_sections = $course->get_curriculum();
4
  $hidden_sections = (array) get_post_meta( $post->ID, '_admin_hidden_sections', true );
5
  ?>
6
  <div id="lp-course-curriculum" class="lp-course-curriculum">
7
- <h3 class="curriculum-heading">
8
- <?php _e( 'Curriculum', 'learnpress' ); ?>
9
- <span class="description"><?php _e( 'Outline your course and add content with sections, lessons and quizzes.', 'learnpress' ); ?></span>
10
 
11
- <p align="right" class="items-toggle">
12
- <a href="" data-action="expand" class="dashicons dashicons-arrow-down<?php echo !sizeof( $hidden_sections ) ? ' hide-if-js' : ''; ?>" title="<?php _e( 'Expand All', 'learnpress' ); ?>"></a>
13
- <a href="" data-action="collapse" class="dashicons dashicons-arrow-up<?php echo sizeof( $hidden_sections ) ? ' hide-if-js' : ''; ?>" title="<?php _e( 'Collapse All', 'learnpress' ); ?>"></a>
14
- </p>
15
- </h3>
16
- <!---->
17
- <ul class="curriculum-sections">
18
- <?php
19
- if ( $course_sections ):
20
- foreach ( $course_sections as $k => $section ):
21
 
22
- $content_items = '';
23
 
24
- if ( $section->items ):
25
- foreach ( $section->items as $item ):
26
- $loop_item_view = learn_press_get_admin_view( 'meta-boxes/course/loop-item.php' );
27
- ob_start();
28
- include $loop_item_view;
29
- $content_items .= "\n" . ob_get_clean();
30
- endforeach;
31
- endif;
32
 
33
- include learn_press_get_admin_view( 'meta-boxes/course/loop-section.php' );
34
- endforeach;
35
- unset( $content_items );
36
- endif;
37
- if ( !empty( $section ) )
38
- foreach ( get_object_vars( $section ) as $k => $v ) {
39
- $section->{$k} = null;
40
- }
41
- include learn_press_get_admin_view( 'meta-boxes/course/loop-section.php' );
42
- ?>
43
- </ul>
44
  </div>
4
  $hidden_sections = (array) get_post_meta( $post->ID, '_admin_hidden_sections', true );
5
  ?>
6
  <div id="lp-course-curriculum" class="lp-course-curriculum">
7
+ <h3 class="curriculum-heading">
8
+ <?php _e( 'Curriculum', 'learnpress' ); ?>
9
+ <span class="description"><?php _e( 'Outline your course and add content with sections, lessons and quizzes.', 'learnpress' ); ?></span>
10
 
11
+ <p align="right" class="items-toggle">
12
+ <a href="" data-action="expand" class="dashicons dashicons-arrow-down<?php echo!sizeof( $hidden_sections ) ? ' hide-if-js' : ''; ?>" title="<?php _e( 'Expand All', 'learnpress' ); ?>"></a>
13
+ <a href="" data-action="collapse" class="dashicons dashicons-arrow-up<?php echo sizeof( $hidden_sections ) ? ' hide-if-js' : ''; ?>" title="<?php _e( 'Collapse All', 'learnpress' ); ?>"></a>
14
+ </p>
15
+ </h3>
16
+ <!---->
17
+ <ul class="curriculum-sections">
18
+ <?php
19
+ if ( $course_sections ):
20
+ foreach ( $course_sections as $k => $section ):
21
 
22
+ $content_items = '';
23
 
24
+ if ( $section->items ):
25
+ foreach ( $section->items as $item ):
26
+ $loop_item_view = learn_press_get_admin_view( 'meta-boxes/course/loop-item.php' );
27
+ ob_start();
28
+ include $loop_item_view;
29
+ $content_items .= "\n" . ob_get_clean();
30
+ endforeach;
31
+ endif;
32
 
33
+ include learn_press_get_admin_view( 'meta-boxes/course/loop-section.php' );
34
+ endforeach;
35
+ unset( $content_items );
36
+ endif;
37
+ if ( !empty( $section ) )
38
+ foreach ( get_object_vars( $section ) as $k => $v ) {
39
+ $section->{$k} = null;
40
+ }
41
+ include learn_press_get_admin_view( 'meta-boxes/course/loop-section.php' );
42
+ ?>
43
+ </ul>
44
  </div>
inc/admin/views/meta-boxes/course/html-course-attribute.php DELETED
@@ -1,35 +0,0 @@
1
- <?php
2
- $attribute_taxonomy = get_term_by( 'slug', $attribute['name'], LP_COURSE_ATTRIBUTE );
3
- ?>
4
- <li data-taxonomy="<?php echo $attribute_taxonomy->slug; ?>" class="learn-press-attribute <?php echo $attribute_taxonomy->slug; ?>">
5
- <h4><?php echo $attribute_taxonomy->name; ?></h4>
6
- <div class="learn-press-attribute-data">
7
- <table class="form-table">
8
- <tr>
9
- <th>
10
- <?php _e( 'Name', 'learnpress' ); ?>
11
- </th>
12
- <td>
13
- <?php echo $attribute_taxonomy->name; ?>
14
- </td>
15
- </tr>
16
- <tr>
17
- <th>
18
- <?php _e( 'Values', 'learnpress' ); ?>
19
- </th>
20
- <td>
21
- <?php $attribute_values = learn_press_get_attribute_terms( $attribute_taxonomy->term_id ); ?>
22
- <select class="course-attribute-values" name="course-attribute-values[<?php echo $attribute_taxonomy->term_id; ?>][]" multiple="multiple" style="width: 100%;">
23
- <?php foreach ( $attribute_values as $value ): ?>
24
- <option value="<?php echo $value->slug; ?>"<?php selected( has_term( absint( $value->term_id ), LP_COURSE_ATTRIBUTE . '-' . $attribute_taxonomy->slug, $postId ), true ); ?>>
25
- <?php echo $value->name; ?>
26
- </option>
27
- <?php endforeach; ?>
28
- </select>
29
- </td>
30
- </tr>
31
- </table>
32
- </div>
33
- <?php
34
- ?>
35
- </li>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/admin/views/meta-boxes/course/loop-item.php CHANGED
@@ -5,74 +5,54 @@
5
  * @package Admin/Views
6
  */
7
  if ( !isset( $section ) ) {
8
- $section = null;
9
  }
10
  $section_item_id = !empty( $item->section_item_id ) ? $item->section_item_id : null;
11
- $item_id = !empty( $item->item_id ) ? $item->item_id : null;
12
- $group_name = '_lp_curriculum[__SECTION__][items][' . ( $section_item_id ? $section_item_id : '__ITEM__' ) . ']';
13
- $support_types = learn_press_course_get_support_item_types();
14
 
15
- //$post_item = $item_id ? get_post( $item_id ) : learn_press_post_object( array( 'post_type' => LP_LESSON_CPT ) );
16
- //if($post_item) {
17
- // foreach ( get_object_vars( $post_item ) as $prop => $value ) {
18
- // $item->{$prop} = $value;
19
- // }
20
- //}
21
  if ( !empty( $support_types[$item->post_type] ) ) {
22
- $item_selected = $item->post_type;
23
  } else {
24
- $item_selected = key( $support_types );
25
  }
26
  ?>
27
 
28
  <?php do_action( 'learn_press_admin_before_section_loop_item', $item, $section ); ?>
29
 
30
- <tr <?php learn_press_admin_section_loop_item_class( $item, $section ); ?>
31
- data-text="<?php echo esc_attr( $item->post_title ); ?>"
32
- data-item_id="<?php echo $item_id; ?>"
33
- data-section_item_id="<?php echo $section_item_id; ?>"
34
- data-type="<?php echo $item->post_type; ?>">
35
- <?php do_action( 'learn_press_admin_begin_section_item', $item, $section ); ?>
36
- <td class="section-item-icon">
37
- <div class="learn-press-dropdown-item-types">
38
- <span class="learn-press-icon item-<?php echo $item->post_type; ?>" data-type="<?php echo $item->post_type; ?>"></span>
39
- <ul>
40
- <?php foreach ( $support_types as $_type => $text ) { ?>
41
- <li>
42
- <span
43
- class="learn-press-icon<?php echo $_type == $item_selected ? ' item-selected' : ''; ?> item-<?php echo $_type; ?>"
44
- data-content="<?php echo sprintf( __( 'Switch to %s', 'learnpress' ), $text ); ?>"
45
- data-type="<?php echo $_type; ?>">
46
- </span>
47
- </li>
48
- <?php } ?>
49
- </ul>
50
- </div>
51
- </td>
52
- <td class="section-item-input">
53
- <input type="text"
54
- autocomplete="off"
55
- name="<?php echo $group_name; ?>[name]"
56
- class="lp-item-name no-submit"
57
- data-field="item-name"
58
- value="<?php echo esc_attr( $item->post_title ); ?>"
59
- placeholder="<?php _e( 'Add new item here and press Enter', 'learnpress' ); ?>" />
60
- <input type="hidden" name="<?php echo $group_name; ?>[old_name]" value="<?php echo esc_attr( $item->post_title ); ?>" />
61
- <input type="hidden" name="<?php echo $group_name; ?>[item_id]" value="<?php echo $item_id; ?>" />
62
- <input type="hidden" name="<?php echo $group_name; ?>[section_item_id]" value="<?php echo $section_item_id; ?>" />
63
- <input type="hidden" class="lp-item-type" name="<?php echo $group_name; ?>[post_type]" value="<?php echo $item->post_type; ?>" />
64
- </td>
65
- <td class="section-item-actions">
66
- <p class="lp-item-actions lp-button-actions">
67
- <?php do_action( 'learn_press_admin_begin_section_item_actions', $item, $section ); ?>
68
- <a href="<?php echo absint( $item_id ) ? get_edit_post_link( $item_id ) : '{{data.edit_link}}'; ?>" class="lp-item-action lp-edit dashicons dashicons-edit" target="_blank"></a>
69
- <a href="" class="lp-item-action lp-remove dashicons dashicons-trash" data-confirm-remove="<?php _e( 'Are you sure you want to remove this item?', 'learnpress' ); ?>"></a>
70
  <span class="item-checkbox">
71
  <input type="checkbox" value="<?php echo $section_item_id; ?>" />
72
  <a class="dashicons dashicons-menu"></a>
73
  </span>
74
- <?php do_action( 'learn_press_admin_end_section_item_actions', $item, $section ); ?>
75
- </p>
76
- </td>
77
- <?php do_action( 'learn_press_admin_end_section_item', $item, $section ); ?>
78
  </tr>
5
  * @package Admin/Views
6
  */
7
  if ( !isset( $section ) ) {
8
+ $section = null;
9
  }
10
  $section_item_id = !empty( $item->section_item_id ) ? $item->section_item_id : null;
11
+ $item_id = !empty( $item->item_id ) ? $item->item_id : null;
12
+ $group_name = '_lp_curriculum[__SECTION__][items][' . ( $section_item_id ? $section_item_id : '__ITEM__' ) . ']';
 
13
 
14
+ $support_types = learn_press_course_get_support_item_types();
 
 
 
 
 
15
  if ( !empty( $support_types[$item->post_type] ) ) {
16
+ $item_selected = $item->post_type;
17
  } else {
18
+ $item_selected = key( $support_types );
19
  }
20
  ?>
21
 
22
  <?php do_action( 'learn_press_admin_before_section_loop_item', $item, $section ); ?>
23
 
24
+ <tr <?php learn_press_admin_section_loop_item_class( $item, $section ); ?> data-text="<?php echo esc_attr( $item->post_title ); ?>" data-item_id="<?php echo $item_id; ?>" data-section_item_id="<?php echo $section_item_id; ?>" data-type="<?php echo $item->post_type; ?>">
25
+ <?php do_action( 'learn_press_admin_begin_section_item', $item, $section ); ?>
26
+ <td class="section-item-icon">
27
+ <div class="learn-press-dropdown-item-types">
28
+ <span class="learn-press-icon item-<?php echo $item->post_type; ?>" data-type="<?php echo $item->post_type; ?>"></span>
29
+ <ul>
30
+ <?php foreach ( $support_types as $_type => $text ) { ?>
31
+ <li>
32
+ <span class="learn-press-icon<?php echo $_type == $item_selected ? ' item-selected' : ''; ?> item-<?php echo $_type; ?>" data-content="<?php echo sprintf( __( 'Switch to %s', 'learnpress' ), $text ); ?>" data-type="<?php echo $_type; ?>"></span>
33
+ </li>
34
+ <?php } ?>
35
+ </ul>
36
+ </div>
37
+ </td>
38
+ <td class="section-item-input">
39
+ <input type="text" autocomplete="off" name="<?php echo $group_name; ?>[name]" class="lp-item-name no-submit" data-field="item-name" value="<?php echo esc_attr( $item->post_title ); ?>" placeholder="<?php _e( 'Add new item here and press Enter', 'learnpress' ); ?>" />
40
+ <input type="hidden" name="<?php echo $group_name; ?>[old_name]" value="<?php echo esc_attr( $item->post_title ); ?>" />
41
+ <input type="hidden" name="<?php echo $group_name; ?>[item_id]" value="<?php echo $item_id; ?>" />
42
+ <input type="hidden" name="<?php echo $group_name; ?>[section_item_id]" value="<?php echo $section_item_id; ?>" />
43
+ <input type="hidden" class="lp-item-type" name="<?php echo $group_name; ?>[post_type]" value="<?php echo $item->post_type; ?>" />
44
+ </td>
45
+ <td class="section-item-actions">
46
+ <p class="lp-item-actions lp-button-actions">
47
+ <?php do_action( 'learn_press_admin_begin_section_item_actions', $item, $section ); ?>
48
+ <a href="<?php echo absint( $item_id ) ? get_edit_post_link( $item_id ) : '{{data.edit_link}}'; ?>" class="lp-item-action lp-edit dashicons dashicons-edit" target="_blank"></a>
49
+ <a href="" class="lp-item-action lp-remove dashicons dashicons-trash" data-confirm-remove="<?php _e( 'Are you sure you want to remove this item?', 'learnpress' ); ?>"></a>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  <span class="item-checkbox">
51
  <input type="checkbox" value="<?php echo $section_item_id; ?>" />
52
  <a class="dashicons dashicons-menu"></a>
53
  </span>
54
+ <?php do_action( 'learn_press_admin_end_section_item_actions', $item, $section ); ?>
55
+ </p>
56
+ </td>
57
+ <?php do_action( 'learn_press_admin_end_section_item', $item, $section ); ?>
58
  </tr>
inc/admin/views/meta-boxes/course/loop-section.php CHANGED
@@ -7,8 +7,15 @@
7
  * @param $section_name
8
  * @param $content_items
9
  */
10
-
11
- $section = learn_press_get_default_section( isset( $section ) ? $section : null );
 
 
 
 
 
 
 
12
  $is_hidden = $section->section_id && is_array( $hidden_sections ) && in_array( $section->section_id, $hidden_sections );
13
 
14
  $class = array(
@@ -22,46 +29,68 @@ if ( $is_hidden ) {
22
  }
23
  ?>
24
  <li class="<?php echo join( ' ', $class ); ?>" data-id="<?php echo $section ? $section->section_id : ''; ?>">
25
- <h3 class="curriculum-section-head">
26
- <input name="_lp_curriculum[__SECTION__][name]" type="text" data-field="section-name" placeholder="<?php _e( 'Enter section name and hit enter', 'learnpress' ); ?>" class="lp-section-name no-submit" value="<?php echo esc_attr( $section->section_name ); ?>" />
27
- <p class="lp-section-actions lp-button-actions">
28
- <a href="" data-action="expand" class="dashicons dashicons-arrow-down<?php echo $is_hidden ? '' : ' hide-if-js'; ?>" title="<?php _e( 'Expand', 'learnpress' ); ?>"></a>
29
- <a href="" data-action="collapse" class="dashicons dashicons-arrow-up<?php echo !$is_hidden ? '' : ' hide-if-js'; ?>" title="<?php _e( 'Collapse', 'learnpress' ); ?>"></a>
30
- <a href="" data-action="remove" class="dashicons dashicons-trash" data-confirm-remove="<?php _e( 'Are you sure you want to remove this section?', 'learnpress' ); ?>"></a>
31
- <a href="" class="move"></a>
32
- </p>
33
- </h3>
34
- <div class="curriculum-section-content<?php echo $is_hidden ? ' hide-if-js' : ''; ?>">
35
- <div class="item-bulk-actions">
36
- <input name="_lp_curriculum[__SECTION__][description]" class="lp-section-describe" type="text" value="<?php echo esc_attr( $section->section_description ); ?>" placeholder="<?php _e( 'Describe about this section', 'learnpress' ); ?>" />
37
- <button class="button hide-if-js" type="button" data-action="delete" data-title="<?php _e( 'Remove', 'learnpress' ); ?>" data-confirm-remove="<?php _e( 'Are you sure you want to remove these items from section?', 'learnpress' ); ?>"><?php _e( 'Remove', 'learnpress' ); ?></button>
 
 
 
 
 
 
 
 
38
  <span class="button lp-check-items">
39
  <input class="lp-check-all-items" data-action="check-all" type="checkbox" />
40
  </span>
41
- </div>
42
- <table class="curriculum-section-items">
43
  <?php echo isset( $content_items ) ? $content_items : ''; ?>
44
  <?php
45
  $item = learn_press_post_object( array( 'post_type' => LP_LESSON_CPT ) );
46
  ?>
47
  <?php learn_press_admin_view( 'meta-boxes/course/loop-item.php', array( 'item' => $item ) ); ?>
48
 
49
- </table>
50
  <?php do_action( 'learn_press_after_section_items', $section ); ?>
51
  <?php if ( $buttons = apply_filters( 'learn_press_loop_section_buttons', array() ) ): ?>
52
- <br />
53
- <div class="lp-add-buttons">
54
-
 
 
 
 
 
 
 
 
 
 
 
 
55
  <?php foreach ( learn_press_section_item_types() as $slug => $name ) { ?>
56
  <?php if ( apply_filters( 'learn_press_button_type_select_items', true, $slug ) ) { ?>
57
- <button class="button" type="button" data-action="add-<?php echo $slug; ?>" data-type="<?php echo $slug; ?>">
58
  <?php echo sprintf( __( 'Select %s', 'learnpress' ), $name ); ?>
59
- </button>
60
  <?php } ?>
61
  <?php } ?>
62
-
63
- </div>
 
 
64
  <?php endif; ?>
65
  <?php do_action( 'learn_press_after_section_content', $section ); ?>
66
- </div>
67
  </li>
7
  * @param $section_name
8
  * @param $content_items
9
  */
10
+ if ( empty( $section ) ) {
11
+ $section = (object) array(
12
+ 'section_id' => null,
13
+ 'section_name' => '',
14
+ 'section_course_id' => null,
15
+ 'section_order' => null,
16
+ 'section_description' => ''
17
+ );
18
+ }
19
  $is_hidden = $section->section_id && is_array( $hidden_sections ) && in_array( $section->section_id, $hidden_sections );
20
 
21
  $class = array(
29
  }
30
  ?>
31
  <li class="<?php echo join( ' ', $class ); ?>" data-id="<?php echo $section ? $section->section_id : ''; ?>">
32
+ <h3 class="curriculum-section-head">
33
+ <input name="_lp_curriculum[__SECTION__][name]" type="text" data-field="section-name" placeholder="<?php _e( 'Enter section name and hit enter', 'learnpress' ); ?>" class="lp-section-name no-submit" value="<?php echo esc_attr( $section->section_name ); ?>" />
34
+ <p class="lp-section-actions lp-button-actions">
35
+ <a href="" data-action="expand" class="dashicons dashicons-arrow-down<?php echo $is_hidden ? '' : ' hide-if-js'; ?>" title="<?php _e( 'Expand', 'learnpress' ); ?>"></a>
36
+ <a href="" data-action="collapse" class="dashicons dashicons-arrow-up<?php echo !$is_hidden ? '' : ' hide-if-js'; ?>" title="<?php _e( 'Collapse', 'learnpress' ); ?>"></a>
37
+ <a href="" data-action="remove" class="dashicons dashicons-trash" data-confirm-remove="<?php _e( 'Are you sure you want to remove this section?', 'learnpress' ); ?>"></a>
38
+ <a href="" class="move"></a>
39
+ </p>
40
+ </h3>
41
+ <div class="curriculum-section-content<?php echo $is_hidden ? ' hide-if-js' : ''; ?>">
42
+ <div class="item-bulk-actions">
43
+ <input name="_lp_curriculum[__SECTION__][description]" class="lp-section-describe" type="text" value="<?php echo esc_attr( $section->section_description ); ?>" placeholder="<?php _e( 'Describe about this section', 'learnpress' ); ?>" />
44
+ <button class="button hide-if-js" type="button" data-action="delete" data-title="<?php _e( 'Remove', 'learnpress' ); ?>" data-confirm-remove="<?php _e( 'Are you sure you want to remove these items from section?', 'learnpress' ); ?>"><?php _e( 'Remove', 'learnpress' ); ?></button>
45
+ <!--
46
+ <button class="button" type="button" data-action="delete-forever" disabled="disabled" data-title="<?php _e( 'Delete Forever', 'learnpress' ); ?>"><?php _e( 'Delete Forever', 'learnpress' ); ?></button>
47
+
48
+ <button class="button hide-if-js" type="button" data-action="cancel"><?php _e( 'Cancel', 'learnpress' ); ?></button>-->
49
+ <!--<div class="button lp-check-all-items">
50
+ <input type="checkbox" class="" />
51
+ <span>&dtrif;</span>
52
+ </div>-->
53
  <span class="button lp-check-items">
54
  <input class="lp-check-all-items" data-action="check-all" type="checkbox" />
55
  </span>
56
+ </div>
57
+ <table class="curriculum-section-items">
58
  <?php echo isset( $content_items ) ? $content_items : ''; ?>
59
  <?php
60
  $item = learn_press_post_object( array( 'post_type' => LP_LESSON_CPT ) );
61
  ?>
62
  <?php learn_press_admin_view( 'meta-boxes/course/loop-item.php', array( 'item' => $item ) ); ?>
63
 
64
+ </table>
65
  <?php do_action( 'learn_press_after_section_items', $section ); ?>
66
  <?php if ( $buttons = apply_filters( 'learn_press_loop_section_buttons', array() ) ): ?>
67
+ <br />
68
+ <div class="lp-add-buttons">
69
+ <!--<input type="text" class="regular-text no-submit" name="lp-new-item-name" placeholder="<?php _e( 'Add new lesson or quiz and press Enter', 'learnpress' ); ?>" />
70
+ <div class="button lp-button-dropdown lp-button-add-item disabled">
71
+ <span class="lp-dropdown-label lp-add-new-item"><?php _e( 'Add New', 'learnpress' ); ?></span>
72
+ <span class="lp-dropdown-arrow">+</span>
73
+ <ul class="lp-dropdown-items">
74
+ <?php foreach ( learn_press_section_item_types() as $slug => $name ) { ?>
75
+ <li>
76
+ <a href="" data-type="<?php echo $slug; ?>"><?php echo $name; ?></a>
77
+ </li>
78
+ <?php } ?>
79
+ </ul>
80
+ </div>
81
+ <?php _e( '-OR-', 'learnpress' ); ?>-->
82
  <?php foreach ( learn_press_section_item_types() as $slug => $name ) { ?>
83
  <?php if ( apply_filters( 'learn_press_button_type_select_items', true, $slug ) ) { ?>
84
+ <button class="button" type="button" data-action="add-<?php echo $slug; ?>" data-type="<?php echo $slug; ?>">
85
  <?php echo sprintf( __( 'Select %s', 'learnpress' ), $name ); ?>
86
+ </button>
87
  <?php } ?>
88
  <?php } ?>
89
+ <!--<button class="button " id="add-quiz" type="button" data-action="add-quiz" data-type="lp_quiz">
90
+ <?php _e( 'Select Quizzes', 'learnpress' ); ?>
91
+ </button>-->
92
+ </div>
93
  <?php endif; ?>
94
  <?php do_action( 'learn_press_after_section_content', $section ); ?>
95
+ </div>
96
  </li>
inc/admin/views/meta-boxes/course/review-logs.php CHANGED
@@ -12,11 +12,11 @@ $index = $total_reviews;
12
  <?php if ( $total_reviews ) { ?>
13
  <ul class="learn-press-review-logs clearfix">
14
  <?php foreach ( $reviews as $review ) { ?>
15
- <?php $user = LP_User_Factory::get_user( $review->user_id ); ?>
16
  <li>
17
  <div class="review-index">#<?php echo $index --; ?></div>
18
  <div class="review-user">
19
- <span class="user-avatar"><?php echo $user->get_profile_picture(); ?></span>
20
  </div>
21
  <div class="review-content">
22
  <strong class="user-nicename"><?php echo learn_press_get_profile_display_name( $user ); ?></strong>
12
  <?php if ( $total_reviews ) { ?>
13
  <ul class="learn-press-review-logs clearfix">
14
  <?php foreach ( $reviews as $review ) { ?>
15
+ <?php $user = get_userdata( $review->user_id ); ?>
16
  <li>
17
  <div class="review-index">#<?php echo $index --; ?></div>
18
  <div class="review-user">
19
+ <span class="user-avatar"><?php echo get_avatar( $review->user_id ); ?></span>
20
  </div>
21
  <div class="review-content">
22
  <strong class="user-nicename"><?php echo learn_press_get_profile_display_name( $user ); ?></strong>
inc/admin/views/meta-boxes/order/actions.php CHANGED
@@ -3,7 +3,6 @@ global $post, $action;
3
  $post_type = $post->post_type;
4
  $post_type_object = get_post_type_object( $post_type );
5
  $can_publish = current_user_can( $post_type_object->cap->publish_posts );
6
- $is_multiple =
7
 
8
  $datef = __( 'M j, Y @ H:i' );
9
  if ( 0 != $post->ID ) {
@@ -34,7 +33,7 @@ if ( 0 != $post->ID ) {
34
  <label>
35
  <?php _e( 'Order status', 'learnpress' ); ?>
36
  </label>
37
- <select name="order-status" data-status="<?php echo 'lp-' . $order->get_status(); ?>">
38
  <?php
39
  $statuses = learn_press_get_order_statuses();
40
  foreach ( $statuses as $status => $status_name ) {
@@ -42,7 +41,6 @@ if ( 0 != $post->ID ) {
42
  }
43
  ?>
44
  </select>
45
-
46
  <div class="description order-status-description">
47
  <?php if ( $order->get_status() == 'auto-draft' ) {
48
  echo _learn_press_get_order_status_description( 'lp-pending' );
@@ -50,13 +48,6 @@ if ( 0 != $post->ID ) {
50
  <?php echo _learn_press_get_order_status_description( 'lp-' . $order->get_status() ); ?>
51
  </div>
52
  </div>
53
- <div class="misc-pub-section hide-if-js order-action-section">
54
- <label for="trigger-order-action">
55
- <input type="checkbox" name="trigger-order-action" id="trigger-order-action" value="yes" />
56
- <?php _e( 'Trigger order status action', 'learnpress' ); ?>
57
- </label>
58
- <p class="description"><?php esc_attr_e( 'Check this option to force an action to be triggered. Normally, an action only is triggered after changing to an another action.', 'learnpress' ); ?></p>
59
- </div>
60
 
61
  <div class="misc-pub-section">
62
  <label>
@@ -66,29 +57,15 @@ if ( 0 != $post->ID ) {
66
  <input name="order-customer" type="text" class="wp-suggest-user ui-autocomplete-input" id="admin-email" data-autocomplete-type="search" data-autocomplete-field="user_email" autocomplete="off">
67
  -->
68
  <?php
69
- if ( $order->is_multi_users() ) {
70
- $order->dropdown_users();
71
- ?>
72
- <input type="hidden" name="multi-users" value="yes" />
73
- <?php
74
- wp_enqueue_style( 'select2', RWMB_CSS_URL . 'select2/select2.css' );
75
- wp_enqueue_script( 'select2', RWMB_JS_URL . 'select2/select2.min.js' );
76
- } else {
77
- wp_dropdown_users(
78
- array(
79
- 'show_option_none' => __( '[Guest]', 'learnpress' ),
80
- 'name' => 'order-customer',
81
- 'id' => null,
82
- 'selected' => $order->get_user( 'ID' )
83
- )
84
- );
85
- }
86
- if ( $order->get_status() == 'auto-draft' && !$order->is_multi_users() ) {
87
- ?>
88
- --
89
- <a href="<?php echo add_query_arg( 'multi-users', 'yes' ); ?>"><?php _e( 'Multiple users', 'learnpress' ); ?></a>
90
- <?php
91
- }
92
  // }else{
93
  // echo $order->get_customer_name();
94
  // }
3
  $post_type = $post->post_type;
4
  $post_type_object = get_post_type_object( $post_type );
5
  $can_publish = current_user_can( $post_type_object->cap->publish_posts );
 
6
 
7
  $datef = __( 'M j, Y @ H:i' );
8
  if ( 0 != $post->ID ) {
33
  <label>
34
  <?php _e( 'Order status', 'learnpress' ); ?>
35
  </label>
36
+ <select name="order-status">
37
  <?php
38
  $statuses = learn_press_get_order_statuses();
39
  foreach ( $statuses as $status => $status_name ) {
41
  }
42
  ?>
43
  </select>
 
44
  <div class="description order-status-description">
45
  <?php if ( $order->get_status() == 'auto-draft' ) {
46
  echo _learn_press_get_order_status_description( 'lp-pending' );
48
  <?php echo _learn_press_get_order_status_description( 'lp-' . $order->get_status() ); ?>
49
  </div>
50
  </div>
 
 
 
 
 
 
 
51
 
52
  <div class="misc-pub-section">
53
  <label>
57
  <input name="order-customer" type="text" class="wp-suggest-user ui-autocomplete-input" id="admin-email" data-autocomplete-type="search" data-autocomplete-field="user_email" autocomplete="off">
58
  -->
59
  <?php
60
+ // if($order->get_status() =='' || $order->has_status('pending') ) {
61
+ wp_dropdown_users(
62
+ array(
63
+ 'show_option_none' => __( '[Guest]', 'learnpress' ),
64
+ 'name' => 'order-customer',
65
+ 'id' => null,
66
+ 'selected' => $order->get_user( 'ID' )
67
+ )
68
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  // }else{
70
  // echo $order->get_customer_name();
71
  // }
inc/admin/views/meta-boxes/order/details.php CHANGED
@@ -18,32 +18,19 @@ global $post;
18
  </div>
19
  <div class="order-user-data clearfix">
20
  <div class="order-user-avatar">
21
- <?php if ( $order->is_multi_users() ) { ?>
22
- <div class="avatar-multiple-users">
23
- <span></span>
24
- </div>
25
- <?php } else { ?>
26
- <?php echo get_avatar( $order->get_user( 'ID' ), 120 ); ?>
27
- <?php } ?>
28
  </div>
29
  <div class="order-user-meta">
30
- <?php if ( $order->is_multi_users() ) { ?>
31
- <div class="order-users">
32
- <strong><?php _e( 'Customers', 'learnpress' ); ?></strong>
33
- <p><?php $order->print_users(); ?></p>
34
- </div>
35
- <?php } else { ?>
36
- <div class="user-display-name">
37
- <?php echo $order->get_customer_name(); ?>
38
- </div>
39
- <div class="user-email">
40
- <?php $user_email = $order->get_user( 'user_email' );
41
- echo empty( $user_email ) ? '' : $user_email; ?>
42
- </div>
43
- <div class="user-ip-address">
44
- <?php echo $order->user_ip_address; ?>
45
- </div>
46
- <?php } ?>
47
  <?php if ( $title = $order->get_payment_method_title() ) { ?>
48
  <div class="payment-method-title">
49
  <?php echo $order->order_total == 0 ? $title : sprintf( __( 'Pay via <strong>%s</strong>', 'learnpress' ), $title ); ?>
@@ -103,7 +90,7 @@ global $post;
103
  <?php if ( $note = get_the_excerpt() ) { ?>
104
  <br />
105
  <h3><?php _e( 'Customer Note', 'learnpress' ); ?></h3>
106
- <p class="order-note description"><?php echo $note; ?></p>
107
  <?php } ?>
108
  </div>
109
  <script type="text/html" id="tmpl-learn-press-modal-add-order-courses">
18
  </div>
19
  <div class="order-user-data clearfix">
20
  <div class="order-user-avatar">
21
+ <?php echo get_avatar( $order->get_user( 'ID' ), 120 ); ?>
 
 
 
 
 
 
22
  </div>
23
  <div class="order-user-meta">
24
+ <div class="user-display-name">
25
+ <?php echo $order->get_customer_name(); ?>
26
+ </div>
27
+ <div class="user-email">
28
+ <?php $user_email = $order->get_user( 'user_email' );
29
+ echo empty( $user_email ) ? '' : $user_email; ?>
30
+ </div>
31
+ <div class="user-ip-address">
32
+ <?php echo $order->user_ip_address; ?>
33
+ </div>
 
 
 
 
 
 
 
34
  <?php if ( $title = $order->get_payment_method_title() ) { ?>
35
  <div class="payment-method-title">
36
  <?php echo $order->order_total == 0 ? $title : sprintf( __( 'Pay via <strong>%s</strong>', 'learnpress' ), $title ); ?>
90
  <?php if ( $note = get_the_excerpt() ) { ?>
91
  <br />
92
  <h3><?php _e( 'Customer Note', 'learnpress' ); ?></h3>
93
+ <p class="order-note description"><?php echo $note;?></p>
94
  <?php } ?>
95
  </div>
96
  <script type="text/html" id="tmpl-learn-press-modal-add-order-courses">
inc/admin/views/settings/emails/enrolled-course-admin.php DELETED
@@ -1,76 +0,0 @@
1
- <?php
2
- /**
3
- * Display general settings for emails
4
- *
5
- * @author ThimPress
6
- * @package LearnPress/Admin/Views/Emails
7
- * @version 1.0
8
- */
9
- if ( !defined( 'ABSPATH' ) ) {
10
- exit; // Exit if accessed directly
11
- }
12
-
13
- $settings = LP()->settings;
14
- ?>
15
- <h3><?php _e( 'Send mail for admins & instructors ', 'learnpress' ); ?></h3>
16
- <p class="description">
17
- <?php _e( 'Send this email to admins & instructor when the course is enrolled.', 'learnpress' ); ?>
18
- </p>
19
- <table class="form-table">
20
- <tbody>
21
- <?php do_action( 'learn_press_before_' . $this->id . '_' . $this->section['id'] . '_settings_fields', $settings ); ?>
22
- <tr>
23
- <th scope="row">
24
- <label for="learn-press-emails-enrolled-course-enable"><?php _e( 'Enable', 'learnpress' ); ?></label></th>
25
- <td>
26
- <input type="hidden" name="<?php echo $settings_class->get_field_name( 'emails_enrolled_course_admin[enable]' ); ?>" value="no" />
27
- <input id="learn-press-emails-enrolled-course-enable" type="checkbox" name="<?php echo $settings_class->get_field_name( 'emails_enrolled_course_admin[enable]' ); ?>" value="yes" <?php checked( $settings->get( 'emails_enrolled_course_admin.enable' ) == 'yes' ); ?> />
28
- </td>
29
- </tr>
30
- <tr>
31
- <th scope="row">
32
- <label for="learn-press-emails-enrolled-course-send-admins"><?php _e( 'Send Admins', 'learnpress' ); ?></label></th>
33
- <td>
34
- <input type="hidden" name="<?php echo $settings_class->get_field_name( 'emails_enrolled_course_admin[send_admins]' ); ?>" value="no" />
35
- <input id="learn-press-emails-enrolled-course-send-admins" type="checkbox" name="<?php echo $settings_class->get_field_name( 'emails_enrolled_course_admin[send_admins]' ); ?>" value="yes" <?php checked( $settings->get( 'emails_enrolled_course_admin.send_admins' ) == 'yes' ); ?> />
36
- </td>
37
- </tr>
38
- <?php do_action( 'learn_press_before_subject_' . $this->id . '_' . $this->section['id'] . '_settings_fields', $settings, $settings_class ); ?>
39
- <tr>
40
- <th scope="row">
41
- <label for="learn-press-emails-enrolled-course-subject"><?php _e( 'Subject', 'learnpress' ); ?></label></th>
42
- <td>
43
- <input id="learn-press-emails-enrolled-course-subject" class="regular-text" type="text" name="<?php echo $settings_class->get_field_name( 'emails_enrolled_course_admin[subject]' ); ?>" value="<?php echo $settings->get( 'emails_enrolled_course_admin.subject', $this->default_subject ); ?>" />
44
-
45
- <p class="description">
46
- <?php printf( __( 'Email subject , default: <code>%s</code>', 'learnpress' ), $this->default_subject ); ?>
47
- </p>
48
- </td>
49
- </tr>
50
- <tr>
51
- <th scope="row">
52
- <label for="learn-press-emails-enrolled-course-heading"><?php _e( 'Heading', 'learnpress' ); ?></label></th>
53
- <td>
54
- <input id="learn-press-emails-enrolled-course-heading" class="regular-text" type="text" name="<?php echo $settings_class->get_field_name( 'emails_enrolled_course_admin[heading]' ); ?>" value="<?php echo $settings->get( 'emails_enrolled_course_admin.heading', $this->default_heading ); ?>" />
55
-
56
- <p class="description">
57
- <?php printf( __( 'Email heading, default: <code>%s</code>', 'learnpress' ), $this->default_heading ); ?>
58
- </p>
59
- </td>
60
- </tr>
61
- <!--
62
- <tr>
63
- <th scope="row">
64
- <label for="learn-press-emails-enrolled-course-email-format"><?php _e( 'Email format', 'learnpress' ); ?></label>
65
- </th>
66
- <td>
67
- <?php learn_press_email_formats_dropdown( array( 'name' => $settings_class->get_field_name( 'emails_enrolled_course_admin[email_format]' ), 'id' => 'learn_press_email_formats', 'selected' => $settings->get( 'emails_enrolled_course_admin.email_format' ) ) ); ?>
68
- </td>
69
- </tr>-->
70
- <?php
71
- $view = learn_press_get_admin_view( 'settings/emails/email-template.php' );
72
- include_once $view;
73
- ?>
74
- <?php do_action( 'learn_press_after_' . $this->id . '_' . $this->section['id'] . '_settings_fields', $settings ); ?>
75
- </tbody>
76
- </table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/admin/views/settings/emails/update-course.php DELETED
@@ -1,50 +0,0 @@
1
- <?php
2
- /**
3
- * Display general settings for emails
4
- *
5
- * @author ThimPress
6
- * @package LearnPress/Admin/Views/Emails
7
- * @version 1.0
8
- */
9
- if ( !defined( 'ABSPATH' ) ) {
10
- exit; // Exit if accessed directly
11
- }
12
-
13
- $settings = LP()->settings;
14
- ?>
15
- <h3><?php _e( 'Update course', 'learnpress' ); ?></h3>
16
- <p class="description">
17
- <?php _e( 'Send this email to users have purchased when the course is updated.', 'learnpress' ); ?>
18
- </p>
19
- <table class="form-table">
20
- <tbody>
21
- <?php do_action( 'learn_press_before_' . $this->id . '_' . $this->section['id'] . '_settings_fields', $settings ); ?>
22
- <tr>
23
- <th scope="row">
24
- <label for="learn-press-emails-updated-course-subject"><?php _e( 'Subject', 'learnpress' ); ?></label></th>
25
- <td>
26
- <input id="learn-press-emails-updated-course-subject" class="regular-text" type="text" name="<?php echo $settings_class->get_field_name( 'emails_update_course[subject]' ); ?>" value="<?php echo $settings->get( 'emails_update_course.subject', $this->default_subject ); ?>" />
27
-
28
- <p class="description">
29
- <?php printf( __( 'Email subject , default: <code>%s</code>', 'learnpress' ), $this->default_subject ); ?>
30
- </p>
31
- </td>
32
- </tr>
33
- <tr>
34
- <th scope="row">
35
- <label for="learn-press-emails-updated-course-heading"><?php _e( 'Heading', 'learnpress' ); ?></label></th>
36
- <td>
37
- <input id="learn-press-emails-updated-course-heading" class="regular-text" type="text" name="<?php echo $settings_class->get_field_name( 'emails_update_course[heading]' ); ?>" value="<?php echo $settings->get( 'emails_update_course.heading', $this->default_heading ); ?>" />
38
-
39
- <p class="description">
40
- <?php printf( __( 'Email heading, default: <code>%s</code>', 'learnpress' ), $this->default_heading ); ?>
41
- </p>
42
- </td>
43
- </tr>
44
- <?php
45
- $view = learn_press_get_admin_view( 'settings/emails/email-template.php' );
46
- include_once $view;
47
- ?>
48
- <?php do_action( 'learn_press_after_' . $this->id . '_' . $this->section['id'] . '_settings_fields', $settings ); ?>
49
- </tbody>
50
- </table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/admin/views/settings/emails/user-order-changed-status.php DELETED
@@ -1,68 +0,0 @@
1
- <?php
2
- /**
3
- * Display general settings for emails
4
- *
5
- * @author ThimPress
6
- * @package LearnPress/Admin/Views/Emails
7
- * @version 1.0
8
- */
9
- if ( !defined( 'ABSPATH' ) ) {
10
- exit; // Exit if accessed directly
11
- }
12
-
13
- $settings = LP()->settings;
14
- ?>
15
- <h3><?php _e( 'User order changed status', 'learnpress' ); ?></h3>
16
- <p class="description">
17
- <?php _e( 'Send email to user when the order is changed status.', 'learnpress' ); ?>
18
- </p>
19
- <table class="form-table">
20
- <tbody>
21
- <?php do_action( 'learn_press_before_' . $this->id . '_' . $this->section['id'] . '_settings_fields', $settings ); ?>
22
- <tr>
23
- <th scope="row">
24
- <label for="learn-press-emails-new-order-enable"><?php _e( 'Enable', 'learnpress' ); ?></label></th>
25
- <td>
26
- <input type="hidden" name="<?php echo $settings_class->get_field_name( 'emails_user_order_changed_status[enable]' ); ?>" value="no" />
27
- <input id="learn-press-emails-new-order-enable" type="checkbox" name="<?php echo $settings_class->get_field_name( 'emails_user_order_changed_status[enable]' ); ?>" value="yes" <?php checked( $settings->get( 'emails_user_order_changed_status.enable' ) == 'yes' ); ?>" />
28
- </td>
29
- </tr>
30
- <tr>
31
- <th scope="row">
32
- <label for="learn-press-emails-new-order-subject"><?php _e( 'Subject', 'learnpress' ); ?></label></th>
33
- <td>
34
- <?php $default = $this->default_subject; ?>
35
- <input id="learn-press-emails-new-order-subject" class="regular-text" type="text" name="<?php echo $settings_class->get_field_name( 'emails_user_order_changed_status[subject]' ); ?>" value="<?php echo $settings->get( 'emails_user_order_changed_status.subject', $default ); ?>" />
36
-
37
- <p class="description">
38
- <?php printf( __( 'Email subject, default: <code>%s</code>', 'learnpress' ), $default ); ?>
39
- </p>
40
- </td>
41
- </tr>
42
- <tr>
43
- <th scope="row">
44
- <label for="learn-press-emails-new-order-heading"><?php _e( 'Heading', 'learnpress' ); ?></label></th>
45
- <td>
46
- <?php $default = $this->default_heading; ?>
47
- <input id="learn-press-emails-new-order-heading" class="regular-text" type="text" name="<?php echo $settings_class->get_field_name( 'emails_user_order_changed_status[heading]' ); ?>" value="<?php echo $settings->get( 'emails_user_order_changed_status.heading', $default ); ?>" />
48
-
49
- <p class="description">
50
- <?php printf( __( 'Email heading, default: <code>%s</code>', 'learnpress' ), $default ); ?>
51
- </p>
52
- </td>
53
- </tr>
54
- <!--<tr>
55
- <th scope="row">
56
- <label for="learn-press-emails-new-order-email-format"><?php _e( 'Email format', 'learnpress' ); ?></label>
57
- </th>
58
- <td>
59
- <?php learn_press_email_formats_dropdown( array( 'name' => $settings_class->get_field_name( 'emails_user_order_changed_status[email_format]' ), 'id' => 'learn_press_email_formats', 'selected' => $settings->get( 'emails_user_order_changed_status.email_format', $default ) ) ); ?>
60
- </td>
61
- </tr>-->
62
- <?php
63
- $view = learn_press_get_admin_view( 'settings/emails/email-template.php' );
64
- include_once $view;
65
- ?>
66
- <?php do_action( 'learn_press_after_' . $this->id . '_' . $this->section['id'] . '_settings_fields', $settings ); ?>
67
- </tbody>
68
- </table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/attributes/course.php DELETED
@@ -1,399 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Add attributes feature for course
5
- *
6
- * @since 2.1.4
7
- */
8
- if ( !class_exists( 'LP_Course_Attributes' ) ) {
9
- /**
10
- * Class LP_Course_Attributes
11
- */
12
- class LP_Course_Attributes {
13
- /**
14
- * @var string
15
- */
16
- private $_tax = '';
17
-
18
- /**
19
- * @var bool
20
- */
21
- private $_screen = false;
22
-
23
- /**
24
- * @var null
25
- */
26
- private $_attribute_terms = null;
27
-
28
- /**
29
- * LP_Course_Attributes constructor.
30
- */
31
- public function __construct() {
32
- add_action( 'init', array( $this, 'register' ), 10 );
33
- add_action( 'load-edit-tags.php', array( $this, 'ready' ) );
34
- add_action( 'pre_delete_term', array( $this, 'pre_delete_term' ), 10, 2 );
35
- add_action( 'delete_term', array( $this, 'delete_terms' ), 10, 5 );
36
-
37
- add_filter( 'learn_press_admin_tabs_info', array( $this, 'admin_tab' ) );
38
- add_filter( "course_attribute_row_actions", array( $this, 'row_actions' ), 10, 2 );
39
- add_filter( 'terms_clauses', array( $this, 'term_clauses' ), 10, 3 );
40
- add_filter( 'learn_press_admin_tabs_on_pages', array( $this, 'admin_tabs_pages' ) );
41
-
42
- add_filter( 'learn_press_lp_course_tabs', array( $this, 'course_attributes_tab' ) );
43
- add_action( 'learn_press_admin_load_scripts', array( $this, 'admin_scripts' ) );
44
-
45
- LP_Request_Handler::register(
46
- array(
47
- array(
48
- 'priority' => 100,
49
- 'action' => 'remove-course-attribute-terms',
50
- 'callback' => array( $this, 'remove_terms' )
51
- ),
52
- array(
53
- 'action' => 'add-attribute-to-course',
54
- 'callback' => array( $this, 'add_attribute_to_course' )
55
- ),
56
- array(
57
- 'action' => 'add-attribute-value',
58
- 'callback' => array( $this, 'add_attribute_value' )
59
- ),
60
- array(
61
- 'action' => 'save-attributes',
62
- 'callback' => array( $this, 'save_attributes' )
63
- )
64
- )
65
- );
66
- }
67
-
68
- public function save_attributes( $course_id ) {
69
- $data = learn_press_get_request( 'data' );
70
- $attributes = array();
71
- parse_str( $data, $attributes );
72
- if ( $attributes ) {
73
- $attributes = $attributes['course-attribute-values'];
74
- foreach ( $attributes as $taxonomy_id => $values ) {
75
- if ( !$values ) {
76
- continue;
77
- }
78
- $taxonomy = get_term( $taxonomy_id, LP_COURSE_ATTRIBUTE );
79
- wp_set_object_terms( $course_id, $values, LP_COURSE_ATTRIBUTE . '-' . $taxonomy->slug );
80
- }
81
- }
82
- die();
83
- }
84
-
85
- public function add_attribute_value( $course_id ) {
86
-
87
- if ( LP_COURSE_CPT != get_post_type( $course_id ) ) {
88
- return;
89
- }
90
-
91
- $taxonomy = learn_press_get_request( 'taxonomy' );
92
- $name = learn_press_get_request( 'name' );
93
- $new = learn_press_add_course_attribute_value( $name, $taxonomy );
94
- $response = array();
95
- if ( !is_wp_error( $new ) ) {
96
- $term = get_term_by( 'term_taxonomy_id', $new['term_taxonomy_id'] );
97
- $response['slug'] = $term->slug;
98
- $response['name'] = $term->name;
99
-
100
- $response['result'] = 'success';
101
- } elseif ( !$new ) {
102
- $response['result'] = 'error';
103
- $response['error'] = __( 'Unknown error', 'learnpress' );
104
- } else {
105
- $response['result'] = 'error';
106
- $response['error'] = $new->get_error_messages();
107
- }
108
- learn_press_send_json( $response );
109
- die();
110
- }
111
-
112
- public function add_attribute_to_course( $course_id ) {
113
- $taxonomy = learn_press_get_request( 'taxonomy' );
114
-
115
- if ( LP_COURSE_CPT != get_post_type( $course_id ) ) {
116
- return;
117
- }
118
-
119
- if ( $attribute = learn_press_add_attribute_to_course( $course_id, $taxonomy ) ) {
120
- $postId = $course_id;
121
- include learn_press_get_admin_view( 'meta-boxes/course/html-course-attribute' );
122
- }
123
-
124
- die();
125
- }
126
-
127
- public function admin_scripts() {
128
- LP_Assets::enqueue_script( 'learn-press-course-attributes' );
129
- LP_Assets::enqueue_script( 'select2' );
130
- LP_Assets::enqueue_style( 'learn-press-course-attributes' );
131
- LP_Assets::enqueue_style( 'learn-press-statistics-select2' );
132
-
133
- }
134
-
135
- public function course_attributes_tab( $tabs ) {
136
- $tabs['attributes'] = array(
137
- 'title' => __( 'Attributes', 'learnpress' ),
138
- 'callback' => array( $this, 'course_attributes' )
139
- );
140
- return $tabs;
141
- }
142
-
143
- public function course_attributes() {
144
- include learn_press_admin_view( 'meta-boxes/course/attributes' );
145
- }
146
-
147
- public function remove_terms( $attribute ) {
148
- if ( learn_press_delete_attribute_terms( $attribute ) ) {
149
- learn_press_add_notice( 'Deleted attribute terms', 'learnpress' );
150
- }
151
- wp_redirect( remove_query_arg( 'remove-course-attribute-terms' ) );
152
- }
153
-
154
- /**
155
- * @param int $term
156
- * @param int $tt_id
157
- * @param string $taxonomy
158
- * @param WP_Term $deleted_term
159
- * @param array $object_ids
160
- *
161
- * @return array|bool
162
- */
163
- public function delete_terms( $term, $tt_id, $taxonomy, $deleted_term, $object_ids ) {
164
- if ( LP_COURSE_ATTRIBUTE != $taxonomy ) {
165
- return false;
166
- }
167
- return learn_press_delete_attribute_terms( $deleted_term->slug );
168
- }
169
-
170
- public function pre_delete_term( $term, $taxonomy ) {
171
-
172
- }
173
-
174
- /**
175
- *
176
- */
177
- public function ready() {
178
- if ( !empty( $_REQUEST['taxonomy'] ) && strpos( $_REQUEST['taxonomy'], LP_COURSE_ATTRIBUTE ) !== false ) {
179
- $this->_tax = $_REQUEST['taxonomy'];
180
- $this->_screen = get_current_screen();
181
- if ( $this->_screen->id == 'edit-' . LP_COURSE_ATTRIBUTE ) {
182
- add_filter( "manage_{$this->_screen->id}_columns", array( $this, 'columns' ) );
183
- add_filter( "manage_{$this->_tax}_custom_column", array( $this, 'column' ), 10, 3 );
184
- }
185
- }
186
- }
187
-
188
- /**
189
- * @param $content
190
- * @param $column_name
191
- * @param $term_id
192
- *
193
- * @return string
194
- */
195
- public function column( $content, $column_name, $term_id ) {
196
- if ( $column_name == 'terms' ) {
197
- $attribute = get_term( $term_id );
198
-
199
- if ( $terms = learn_press_get_attribute_terms( $term_id ) ) {
200
- $term_labels = array();
201
- foreach ( $terms as $term ) {
202
- $term_labels[] = sprintf( '<a href="%s">%s</a>', get_edit_term_link( $term->term_id, $term->taxonomy, LP_COURSE_CPT ), $term->name );
203
- }
204
- $content = join( ', ', $term_labels );
205
-
206
- } else {
207
- $content .= __( 'No terms found.', 'learnpress' );
208
- }
209
- $content .= '<div class="row-actions">' . $this->terms_row_actions( $attribute ) . '</div>';
210
-
211
- }
212
- return $content;
213
- }
214
-
215
- /**
216
- * @param $tax
217
- *
218
- * @return string
219
- */
220
- public function terms_row_actions( $tax ) {
221
- $uri = wp_doing_ajax() ? wp_get_referer() : $_SERVER['REQUEST_URI'];
222
- $edit_link = add_query_arg(
223
- 'wp_http_referer',
224
- urlencode( wp_unslash( $uri ) ),
225
- add_query_arg( array( 'taxonomy' => LP_COURSE_ATTRIBUTE . '-' . $tax->slug, 'post_type' => LP_COURSE_CPT ), admin_url( 'term.php' ) )
226
- );
227
- $terms_actions = array(
228
- 'edit' => sprintf(
229
- '<a href="%s" aria-label="%s" >%s </a > ',
230
- esc_url( $edit_link ),
231
- esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $tax->name ) ),
232
- __( 'Edit', 'learnpress' )
233
- ),
234
- 'delete' => sprintf(
235
- '<a href="%s" aria-label="%s" >%s </a > ',
236
- esc_url( add_query_arg( 'remove-course-attribute-terms', $tax->term_id ) ),
237
- '',
238
- __( 'Clear', 'learnpress' )
239
- )
240
- );
241
- return join( ' | ', $terms_actions );
242
- }
243
-
244
- /**
245
- * @param $columns
246
- *
247
- * @return mixed
248
- */
249
- public function columns( $columns ) {
250
- if ( $this->_tax == LP_COURSE_ATTRIBUTE && !empty( $columns['posts'] ) ) {
251
- unset( $columns['posts'] );
252
- }
253
- $columns['terms'] = __( 'Terms', 'learnpress' );
254
- return $columns;
255
- }
256
-
257
- /**
258
- * @param $pages
259
- *
260
- * @return array
261
- */
262
- public function admin_tabs_pages( $pages ) {
263
- if ( !empty( $_REQUEST['taxonomy'] ) && strpos( $_REQUEST['taxonomy'], LP_COURSE_ATTRIBUTE ) !== false ) {
264
- $screen_id = get_current_screen()->id;
265
- $pages[] = $screen_id;
266
- }
267
- return $pages;
268
- }
269
-
270
- /**
271
- * @param $a
272
- * @param $b
273
- * @param $c
274
- *
275
- * @return mixed
276
- */
277
- public function term_clauses( $a, $b, $c ) {
278
- //print_r( func_get_args() );
279
- return $a;
280
- }
281
-
282
- /**
283
- * @param $tabs
284
- *
285
- * @return array
286
- */
287
- public function admin_tab( $tabs ) {
288
- if ( !empty( $_REQUEST['taxonomy'] ) && strpos( $_REQUEST['taxonomy'], LP_COURSE_ATTRIBUTE ) !== false ) {
289
- $screen_id = get_current_screen()->id;
290
- } else {
291
- $screen_id = 'edit-' . LP_COURSE_ATTRIBUTE;
292
- }
293
- $tabs[] = array(
294
- "link" => "edit-tags.php?taxonomy=" . LP_COURSE_ATTRIBUTE . "&post_type=lp_course",
295
- "name" => __( "Attributes", "learnpress" ),
296
- "id" => $screen_id,
297
- );
298
- return $tabs;
299
- }
300
-
301
- public function register() {
302
- register_taxonomy(
303
- LP_COURSE_ATTRIBUTE,
304
- array( 'lp_course' ),
305
- array(
306
- 'label' => __( 'Attribute', 'learnpress' ),
307
- 'labels' => array(
308
- 'name' => __( 'Attributes', 'learnpress' ),
309
- 'singular_name' => __( 'Attribute', 'learnpress' ),
310
- 'menu_name' => __( 'Attributes', 'learnpress' ),
311
- 'add_new_item' => __( 'Add New Attribute', 'learnpress' ),
312
- 'all_items' => __( 'All Attributes', 'learnpress' )
313
- ),
314
- 'show_ui' => true,
315
- 'query_var' => true,
316
- 'show_in_menu' => 'learn_press',
317
- 'public' => false,
318
- 'rewrite' => array(
319
- 'slug' => LP_COURSE_ATTRIBUTE,//empty( $permalinks['category_base'] ) ? _x( 'product - category', 'slug', 'woocommerce' ) : $permalinks['category_base'],
320
- 'with_front' => false,
321
- 'hierarchical' => true,
322
- ),
323
- )
324
- );
325
-
326
- if ( $attributes = learn_press_get_attributes() ) {
327
- foreach ( $attributes as $attribute ) {
328
- $this->_register_custom_attribute( $attribute );
329
- }
330
- }
331
- }
332
-
333
- /**
334
- * @param $actions
335
- * @param $tag
336
- *
337
- * @return mixed
338
- */
339
- public function row_actions( $actions, $tag ) {
340
-
341
- return $actions;
342
- }
343
-
344
- /**
345
- * @param $attribute
346
- */
347
- private function _register_custom_attribute( $attribute ) {
348
- $name = $attribute->name;
349
- $singular_name = $attribute->name;
350
- $tax_data = array(
351
- 'hierarchical' => true,
352
- 'update_count_callback' => '_update_post_term_count',
353
- 'labels' => array(
354
- 'name' => $name,
355
- 'singular_name' => $singular_name,
356
- 'search_items' => sprintf( __( 'Search Course %s', 'learnpress' ), $name ),
357
- 'all_items' => sprintf( __( 'All Course %s', 'learnpress' ), $name ),
358
- 'parent_item' => sprintf( __( 'Parent Course %s', 'learnpress' ), $singular_name ),
359
- 'parent_item_colon' => sprintf( __( 'Parent Course %s:', 'learnpress' ), $singular_name ),
360
- 'edit_item' => sprintf( __( 'Edit Course %s', 'learnpress' ), $singular_name ),
361
- 'update_item' => sprintf( __( 'Update Course %s', 'learnpress' ), $singular_name ),
362
- 'add_new_item' => sprintf( __( 'Add New Course %s', 'learnpress' ), $singular_name ),
363
- 'new_item_name' => sprintf( __( 'New Course %s', 'learnpress' ), $singular_name ),
364
- 'not_found' => sprintf( __( 'No &quot;Course %s&quot; found', 'learnpress' ), $singular_name ),
365
- ),
366
- 'show_ui' => true,
367
- 'show_in_quick_edit' => false,
368
- 'show_in_menu' => false,
369
- 'show_in_nav_menus' => false,
370
- 'meta_box_cb' => false,
371
- 'query_var' => false,
372
- 'rewrite' => false,
373
- 'sort' => false,
374
- 'public' => false,
375
- 'show_in_nav_menus' => false/*,
376
- 'capabilities' => array(
377
- 'manage_terms' => 'manage_lp_course_terms',
378
- 'edit_terms' => 'edit_lp_course_terms',
379
- 'delete_terms' => 'delete_lp_course_terms',
380
- 'assign_terms' => 'assign_lp_course_terms',
381
- )*/
382
- );
383
-
384
- $tax_data['rewrite'] = array(
385
- 'slug' => $attribute->slug,// empty( $permalinks['attribute_base'] ) ? '' : trailingslashit( $permalinks['attribute_base'] ) . sanitize_title( $tax->attribute_name ),
386
- 'with_front' => false,
387
- 'hierarchical' => true
388
- );
389
-
390
- register_taxonomy(
391
- sprintf( '%s-%s', LP_COURSE_ATTRIBUTE, $attribute->slug ),
392
- apply_filters( 'learn_press_course_attribute_object_' . $attribute->slug, array( 'lp_course' ) ),
393
- apply_filters( 'learn_press_course_attribute_args_' . $attribute->slug, $tax_data )
394
- );
395
-
396
- }
397
- }
398
- }
399
- return new LP_Course_Attributes();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/attributes/lp-attributes-functions.php DELETED
@@ -1,175 +0,0 @@
1
- <?php
2
- /**
3
- * Course attributes functions
4
- */
5
- include_once LP_PLUGIN_PATH . '/inc/attributes/course.php';
6
- define( 'LP_COURSE_ATTRIBUTE', 'course_attribute' );
7
- /**
8
- * @return array|int|WP_Error
9
- */
10
- function learn_press_get_attributes() {
11
- return get_terms( LP_COURSE_ATTRIBUTE, array(
12
- 'hide_empty' => false
13
- ) );
14
- }
15
-
16
- /**
17
- * @param $attribute
18
- *
19
- * @return array|int|WP_Error
20
- */
21
- function learn_press_get_attribute_terms( $attribute ) {
22
- $terms = array();
23
- if ( is_array( $attribute ) ) {
24
- foreach ( $attribute as $attr ) {
25
- $_terms = learn_press_get_attribute_terms( $attr );
26
- if ( is_array( $terms ) ) {
27
- $terms = array_merge( $terms, $_terms );
28
- }
29
- }
30
- } else {
31
- if ( is_numeric( $attribute ) && !is_wp_error( $term = get_term( $attribute, LP_COURSE_ATTRIBUTE ) ) ) {
32
- $attribute = $term->slug;
33
- }
34
- $terms = get_terms( sprintf( '%s-%s', LP_COURSE_ATTRIBUTE, $attribute ), array( 'hide_empty' => false ) );
35
- }
36
- return $terms;
37
- }
38
-
39
- /**
40
- * @param $attribute
41
- *
42
- * @return array|bool
43
- */
44
- function learn_press_delete_attribute_terms( $attribute ) {
45
- $deleted_terms = array();
46
- if ( !$terms = learn_press_get_attribute_terms( $attribute ) ) {
47
- return false;
48
- }
49
- foreach ( $terms as $term ) {
50
- if ( !is_wp_error( $deleted = wp_delete_term( $term->term_id, $term->taxonomy ) ) ) {
51
- $deleted_terms[] = $term;
52
- }
53
- }
54
- do_action( 'learn_press_deleted_attribute_terms', $attribute, $deleted_terms );
55
- return $deleted_terms;
56
- }
57
-
58
- /**
59
- * @param $course_id
60
- *
61
- * @return mixed
62
- */
63
- function learn_press_get_course_attributes( $course_id ) {
64
- return get_post_meta( $course_id, '_lp_attributes', true );
65
- }
66
-
67
- /**
68
- * @param $name
69
- * @param $taxonomy
70
- *
71
- * @return array|bool|WP_Error
72
- */
73
- function learn_press_add_course_attribute_value( $name, $taxonomy ) {
74
-
75
- if ( !$name || term_exists( $name, $taxonomy ) ) {
76
- return false;
77
- }
78
- if ( !$term = get_term_by( 'slug', $taxonomy, LP_COURSE_ATTRIBUTE ) ) {
79
- return false;
80
- }
81
-
82
- $new_value = wp_insert_term( $name, sprintf( '%s-%s', LP_COURSE_ATTRIBUTE, $term->slug ) );
83
- return $new_value;
84
- }
85
-
86
- /**
87
- * @param $name
88
- *
89
- * @return array|bool|WP_Error
90
- */
91
- function learn_press_add_course_attribute( $name ) {
92
-
93
- if ( !$name || term_exists( $name, LP_COURSE_ATTRIBUTE ) ) {
94
- return false;
95
- }
96
-
97
- $new_value = wp_insert_term( $name, LP_COURSE_ATTRIBUTE );
98
- return $new_value;
99
- }
100
-
101
- /**
102
- * @param $course_id
103
- * @param $taxonomy
104
- *
105
- * @return bool|mixed|void
106
- */
107
- function learn_press_add_attribute_to_course( $course_id, $taxonomy ) {
108
- if ( !$term = get_term_by( 'slug', $taxonomy, LP_COURSE_ATTRIBUTE ) ) {
109
- return false;
110
- }
111
- $attributes = get_post_meta( $course_id, '_lp_attributes', true );
112
- if ( !is_array( $attributes ) ) {
113
- $attributes = array();
114
- }
115
- $attribute = apply_filters( 'learn_press_update_course_attribute_data', array(
116
- 'name' => $term->slug
117
- ), $course_id, $term );
118
- $attributes[$term->slug] = $attribute;
119
-
120
- $attributes = apply_filters( 'learn_press_update_course_attributes_data', $attributes, $course_id, $term );
121
-
122
- update_post_meta( $course_id, '_lp_attributes', $attributes );
123
- return $attribute;
124
- }
125
-
126
- /**
127
- * @param WP_Query $q
128
- */
129
- add_filter( 'pre_get_posts', function ( $q ) {
130
- global $lp_tax_query;
131
- if ( empty( $_REQUEST['course-filter'] ) ) {
132
- return;
133
- }
134
-
135
- if ( !$q->is_main_query() ) {
136
- return;
137
- }
138
- if ( LP_COURSE_CPT != $q->get( 'post_type' ) ) {
139
- return $q;
140
- }
141
-
142
- if ( $attribute_taxonomies = learn_press_get_attributes() ) {
143
- $attribute_operator = 'and' === strtolower( learn_press_get_request( 'attribute_operator' ) ) ? 'AND' : 'OR';
144
- $value_operator = 'and' === strtolower( learn_press_get_request( 'value_operator' ) ) ? 'AND' : 'IN';
145
- $tax_query = array(
146
- 'relation' => $attribute_operator
147
- );
148
- foreach ( $attribute_taxonomies as $tax ) {
149
- $attribute = $tax->slug;
150
- $taxonomy = LP_COURSE_ATTRIBUTE . '-' . $attribute;
151
- $filter_terms = !empty( $_GET['filter_' . $attribute] ) ? explode( ',', $_GET['filter_' . $attribute] ) : array();
152
-
153
-
154
- if ( empty( $filter_terms ) || !taxonomy_exists( $taxonomy ) ) {
155
- continue;
156
- }
157
-
158
- $tax_query[] = array(
159
- 'taxonomy' => $taxonomy,
160
- 'field' => 'slug',
161
- 'terms' => $filter_terms,
162
- 'operator' => $value_operator,
163
- 'include_children' => false,
164
- );
165
- }
166
- $lp_tax_query = $tax_query;
167
- $q->set( 'tax_query', $tax_query );
168
- }
169
- return $q;
170
- }, 1000 );
171
-
172
- /**
173
- * Register widgets
174
- */
175
- LP_Widget::register( array( 'course-attributes', 'course-filters' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/class-lp-assets.php CHANGED
@@ -203,38 +203,37 @@ class LP_Assets {
203
  $default_path = plugins_url( 'learnpress/assets/' );
204
  $suffix = '';
205
  $deps = array( 'jquery', 'backbone', 'utils' );
206
- $ver = LEARNPRESS_VERSION;
207
 
208
  // global
209
- $scripts->add( 'learn-press-global', $default_path . 'js/global' . $suffix . '.js', $deps, $ver, 1 );
210
- $scripts->add( 'learn-press-jalerts', $default_path . 'js/jquery.alert' . $suffix . '.js', $deps, $ver, 1 );
211
 
212
  // frontend
213
- $scripts->add( 'learn-press-js', $default_path . 'js/frontend/learnpress' . $suffix . '.js', $deps, $ver, 1 );
214
- $scripts->add( 'learn-press-single-course', $default_path . 'js/frontend/single-course' . $suffix . '.js', $deps, $ver, 1 );
215
- $scripts->add( 'learn-press-course-quiz', $default_path . 'js/frontend/quiz' . $suffix . '.js', $deps, $ver, 1 );
216
- $scripts->add( 'learn-press-course-lesson', $default_path . 'js/frontend/lesson' . $suffix . '.js', $deps, $ver, 1 );
217
- $scripts->add( 'learn-press-enroll', $default_path . 'js/frontend/enroll' . $suffix . '.js', $deps, $ver, 1 );
218
- $scripts->add( 'learn-press-timer', $default_path . 'js/jquery.timer' . $suffix . '.js', $deps, $ver, 1 );
219
- $scripts->add( 'learn-press-checkout', $default_path . 'js/frontend/checkout' . $suffix . '.js', $deps, $ver, 1 );
220
- $scripts->add( 'learn-press-become-teacher', $default_path . 'js/frontend/become-teacher' . $suffix . '.js', $deps, $ver, 1 );
221
- $scripts->add( 'learn-press-profile', $default_path . 'js/frontend/profile' . $suffix . '.js', array( 'jquery', 'backbone', 'utils', 'plupload', 'jquery-ui-slider', 'jquery-ui-draggable' ), $ver, 1 );
222
 
223
  // admin
224
- $scripts->add( 'learn-press-admin', $default_path . 'js/admin/admin' . $suffix . '.js', $deps, $ver, 1 );
225
- $scripts->add( 'learn-press-admin-settings', $default_path . 'js/admin/settings' . $suffix . '.js', $deps, $ver, 1 );
226
- $scripts->add( 'learn-press-mb-question', $default_path . 'js/admin/meta-box-question' . $suffix . '.js', $deps, $ver, 1 );
227
- $scripts->add( 'learn-press-mb-course', $default_path . 'js/admin/meta-box-course' . $suffix . '.js', $deps, $ver, 1 );
228
- $scripts->add( 'learn-press-mb-quiz', $default_path . 'js/admin/meta-box-quiz' . $suffix . '.js', $deps, $ver, 1 );
229
- $scripts->add( 'learn-press-mb-order', $default_path . 'js/admin/meta-box-order' . $suffix . '.js', $deps, $ver, 1 );
230
- $scripts->add( 'learn-press-modal-search-items', $default_path . 'js/admin/modal-search-items' . $suffix . '.js', array( 'learn-press-global' ), $ver, 1 );
231
- $scripts->add( 'learn-press-order', $default_path . 'js/admin/meta-box-order' . $suffix . '.js', $deps, $ver, 1 );
232
  //$scripts->add( 'learn-press-statistics-select2', '/' . LP_WP_CONTENT . '/plugins/learnpress/inc/libraries/meta-box/js/select2/select2.min.js', $deps, false, 1 );
233
 
234
- $scripts->add( 'learn-press-select2', '/' . LP_WP_CONTENT . '/plugins/learnpress/inc/libraries/meta-box/js/select2/select2.min.js', $deps, $ver, 1 );
235
 
236
  // upgrade
237
- $scripts->add( 'learn-press-upgrade', '/' . LP_WP_CONTENT . '/plugins/learnpress/inc/updates/09/script' . $suffix . '.js', $deps, $ver, 1 );
238
 
239
  do_action_ref_array( 'learn_press_add_default_scripts', array( $scripts, $default_path, $suffix, $deps ) );
240
  }
@@ -274,26 +273,25 @@ class LP_Assets {
274
  $default_path = plugins_url( 'learnpress/assets/' );
275
  $suffix = '';
276
  $deps = array( 'dashicons' );
277
- $ver = LEARNPRESS_VERSION;
278
  // global
279
- $styles->add( 'learn-press-global', $default_path . 'css/global' . $suffix . '.css', $deps, $ver );
280
 
281
  // admin
282
- $styles->add( 'learn-press-admin', $default_path . 'css/admin/admin' . $suffix . '.css', null, $ver );
283
- $styles->add( 'learn-press-jquery.ui.datepicker', $default_path . 'css/admin/jquery.ui.datepicker' . $suffix . '.css', null, $ver );
284
- $styles->add( 'learn-press-jquery.ui.theme', $default_path . 'css/admin/jquery.ui.theme' . $suffix . '.css', null, $ver );
285
- $styles->add( 'learn-press-jquery.ui.core', $default_path . 'css/admin/jquery.ui.core' . $suffix . '.css', null, $ver );
286
- $styles->add( 'learn-press-jquery.ui.slider', $default_path . 'css/admin/jquery.ui.slider' . $suffix . '.css', null, $ver );
287
- $styles->add( 'learn-press-mb-course', $default_path . 'css/admin/meta-box-course' . $suffix . '.css', null, $ver );
288
- //$styles->add( 'learn-press-mb-question', $default_path . 'css/admin/meta-box-question' . $suffix . '.css', null, $ver );
289
- $styles->add( 'learn-press-mb-order', $default_path . 'css/admin/meta-box-order' . $suffix . '.css', null, $ver );
290
- $styles->add( 'learn-press-jalerts', $default_path . 'css/jalert' . $suffix . '.css', null, $ver );
291
  //$styles->add( 'learn-press-statistics-select2', '/' . LP_WP_CONTENT . '/plugins/learnpress/inc/libraries/meta-box/css/select2/select2.css' );
292
  $styles->add( 'learn-press-select2', '/' . LP_WP_CONTENT . '/plugins/learnpress/inc/libraries/meta-box/css/select2/select2.css' );
293
 
294
 
295
  // frontend
296
- $styles->add( 'learn-press-style', $default_path . 'css/learnpress.css', $deps, $ver );
297
  do_action_ref_array( 'learn_press_add_default_styles', array( $styles, $default_path, $suffix ) );
298
 
299
  }
@@ -807,10 +805,6 @@ class LP_Assets {
807
  }
808
  do_action( 'learn_press_load_scripts' );
809
  }
810
-
811
- public static function url( $file = '' ) {
812
- return LP_PLUGIN_URL . "assets/{$file}";
813
- }
814
  }
815
 
816
  // Call class
203
  $default_path = plugins_url( 'learnpress/assets/' );
204
  $suffix = '';
205
  $deps = array( 'jquery', 'backbone', 'utils' );
 
206
 
207
  // global
208
+ $scripts->add( 'learn-press-global', $default_path . 'js/global' . $suffix . '.js', $deps, false, 1 );
209
+ $scripts->add( 'learn-press-jalerts', $default_path . 'js/jquery.alert' . $suffix . '.js', $deps, false, 1 );
210
 
211
  // frontend
212
+ $scripts->add( 'learn-press-js', $default_path . 'js/frontend/learnpress' . $suffix . '.js', $deps, false, 1 );
213
+ $scripts->add( 'learn-press-single-course', $default_path . 'js/frontend/single-course' . $suffix . '.js', $deps, false, 1 );
214
+ $scripts->add( 'learn-press-course-quiz', $default_path . 'js/frontend/quiz' . $suffix . '.js', $deps, false, 1 );
215
+ $scripts->add( 'learn-press-course-lesson', $default_path . 'js/frontend/lesson' . $suffix . '.js', $deps, false, 1 );
216
+ $scripts->add( 'learn-press-enroll', $default_path . 'js/frontend/enroll' . $suffix . '.js', $deps, false, 1 );
217
+ $scripts->add( 'learn-press-timer', $default_path . 'js/jquery.timer' . $suffix . '.js', $deps, false, 1 );
218
+ $scripts->add( 'learn-press-checkout', $default_path . 'js/frontend/checkout' . $suffix . '.js', $deps, false, 1 );
219
+ $scripts->add( 'learn-press-become-teacher', $default_path . 'js/frontend/become-teacher' . $suffix . '.js', $deps, false, 1 );
220
+ $scripts->add( 'learn-press-profile', $default_path . 'js/frontend/profile' . $suffix . '.js', array( 'jquery', 'backbone', 'utils', 'plupload', 'jquery-ui-slider', 'jquery-ui-draggable' ), false, 1 );
221
 
222
  // admin
223
+ $scripts->add( 'learn-press-admin', $default_path . 'js/admin/admin' . $suffix . '.js', $deps, false, 1 );
224
+ $scripts->add( 'learn-press-admin-settings', $default_path . 'js/admin/settings' . $suffix . '.js', $deps, false, 1 );
225
+ $scripts->add( 'learn-press-mb-question', $default_path . 'js/admin/meta-box-question' . $suffix . '.js', $deps, false, 1 );
226
+ $scripts->add( 'learn-press-mb-course', $default_path . 'js/admin/meta-box-course' . $suffix . '.js', $deps, false, 1 );
227
+ $scripts->add( 'learn-press-mb-quiz', $default_path . 'js/admin/meta-box-quiz' . $suffix . '.js', $deps, false, 1 );
228
+ $scripts->add( 'learn-press-mb-order', $default_path . 'js/admin/meta-box-order' . $suffix . '.js', $deps, false, 1 );
229
+ $scripts->add( 'learn-press-modal-search-items', $default_path . 'js/admin/modal-search-items' . $suffix . '.js', array( 'learn-press-global' ), false, 1 );
230
+ $scripts->add( 'learn-press-order', $default_path . 'js/admin/meta-box-order' . $suffix . '.js', $deps, false, 1 );
231
  //$scripts->add( 'learn-press-statistics-select2', '/' . LP_WP_CONTENT . '/plugins/learnpress/inc/libraries/meta-box/js/select2/select2.min.js', $deps, false, 1 );
232
 
233
+ $scripts->add( 'learn-press-select2', '/' . LP_WP_CONTENT . '/plugins/learnpress/inc/libraries/meta-box/js/select2/select2.min.js', $deps, false, 1 );
234
 
235
  // upgrade
236
+ $scripts->add( 'learn-press-upgrade', '/' . LP_WP_CONTENT . '/plugins/learnpress/inc/updates/09/script' . $suffix . '.js', $deps, false, 1 );
237
 
238
  do_action_ref_array( 'learn_press_add_default_scripts', array( $scripts, $default_path, $suffix, $deps ) );
239
  }
273
  $default_path = plugins_url( 'learnpress/assets/' );
274
  $suffix = '';
275
  $deps = array( 'dashicons' );
 
276
  // global
277
+ $styles->add( 'learn-press-global', $default_path . 'css/global' . $suffix . '.css', $deps );
278
 
279
  // admin
280
+ $styles->add( 'learn-press-admin', $default_path . 'css/admin/admin' . $suffix . '.css' );
281
+ $styles->add( 'learn-press-jquery.ui.datepicker', $default_path . 'css/admin/jquery.ui.datepicker' . $suffix . '.css' );
282
+ $styles->add( 'learn-press-jquery.ui.theme', $default_path . 'css/admin/jquery.ui.theme' . $suffix . '.css' );
283
+ $styles->add( 'learn-press-jquery.ui.core', $default_path . 'css/admin/jquery.ui.core' . $suffix . '.css' );
284
+ $styles->add( 'learn-press-jquery.ui.slider', $default_path . 'css/admin/jquery.ui.slider' . $suffix . '.css' );
285
+ $styles->add( 'learn-press-mb-course', $default_path . 'css/admin/meta-box-course' . $suffix . '.css' );
286
+ $styles->add( 'learn-press-mb-question', $default_path . 'css/admin/meta-box-question' . $suffix . '.css' );
287
+ $styles->add( 'learn-press-mb-order', $default_path . 'css/admin/meta-box-order' . $suffix . '.css' );
288
+ $styles->add( 'learn-press-jalerts', $default_path . 'css/jalert' . $suffix . '.css' );
289
  //$styles->add( 'learn-press-statistics-select2', '/' . LP_WP_CONTENT . '/plugins/learnpress/inc/libraries/meta-box/css/select2/select2.css' );
290
  $styles->add( 'learn-press-select2', '/' . LP_WP_CONTENT . '/plugins/learnpress/inc/libraries/meta-box/css/select2/select2.css' );
291
 
292
 
293
  // frontend
294
+ $styles->add( 'learn-press-style', $default_path . 'css/learnpress.css', $deps );
295
  do_action_ref_array( 'learn_press_add_default_styles', array( $styles, $default_path, $suffix ) );
296
 
297
  }
805
  }
806
  do_action( 'learn_press_load_scripts' );
807
  }
 
 
 
 
808
  }
809
 
810
  // Call class
inc/class-lp-cache.php CHANGED
@@ -16,7 +16,7 @@ class LP_Cache {
16
  /**
17
  * @var array
18
  */
19
- //protected static $_data = array();
20
 
21
  /**
22
  * @var string
@@ -48,81 +48,11 @@ class LP_Cache {
48
  */
49
  protected static $_evaluate_course_by_lesson = 'user-evaluate-course-by-lesson';
50
 
51
- /**
52
- * @var string
53
- */
54
- protected static $_user_completed_items = 'user-completed-items';
55
-
56
- /**
57
- * @var string
58
- */
59
- protected static $_user_enrolled_courses = 'user-enrolled-courses';
60
-
61
- /**
62
- * @var string
63
- */
64
- protected static $_user_finished_courses = 'user-finished-courses';
65
-
66
- /**
67
- * @var string
68
- */
69
- protected static $_user_course_info = 'user-course-info';
70
-
71
- /**
72
- * @var string
73
- */
74
- protected static $_course_curriculum = 'course-curriculum';
75
-
76
- /**
77
- * @var string
78
- */
79
- protected static $_course_item_statuses = 'course-item-statuses';
80
-
81
- /**
82
- * @var string
83
- */
84
- protected static $_quiz_questions = 'quiz-questions';
85
-
86
- /**
87
- * @var string
88
- */
89
- protected static $_quiz_results = 'quiz-results';
90
-
91
- /**
92
- * @var string
93
- */
94
- protected static $_quiz_params = 'quiz-params';
95
-
96
- /**
97
- * @var string
98
- */
99
- protected static $_post_names = 'post-names';
100
-
101
- /**
102
- * @var string
103
- */
104
- protected static $_user_course_order = 'user-course-order';
105
-
106
- /**
107
- * @var string
108
- */
109
- protected static $_user_profile_orders = 'user-profile-orders';
110
-
111
- /**
112
- * @var string
113
- */
114
- protected static $_user_item_id = 'user-item-id';
115
-
116
  /**
117
  * @var string
118
  */
119
  protected static $_quiz_history = 'user-quiz-history';
120
 
121
- /**
122
- * @var string
123
- */
124
- protected static $_quiz_grade = 'quiz-grade';
125
-
126
  /**
127
  * Set data to cache
128
  *
@@ -314,10 +244,10 @@ class LP_Cache {
314
  public static function set_completed_items( $key_or_value, $value = false ) {
315
  //return self::_set_cache( 'user-completed-items', $key, $value );
316
  if ( func_num_args() == 1 ) {
317
- wp_cache_set( self::$_user_completed_items, $key_or_value, self::$_group );
318
  return $key_or_value;
319
  }
320
- return self::_set_cache( self::$_user_completed_items, $key_or_value, $value );
321
  }
322
 
323
  /**
@@ -329,7 +259,7 @@ class LP_Cache {
329
  * @return array|bool|mixed
330
  */
331
  public static function get_completed_items( $key = false, $def = false ) {
332
- return self::_get_cache( self::$_user_completed_items, $key, $def );
333
  }
334
 
335
  /**
@@ -338,12 +268,12 @@ class LP_Cache {
338
  *
339
  * @return array|bool|mixed
340
  */
341
- public static function set_enrolled_courses( $key_or_value, $value = false ) {
342
  if ( func_num_args() == 1 ) {
343
- wp_cache_set( self::$_user_enrolled_courses, $key_or_value, self::$_group );
344
  return $key_or_value;
345
  }
346
- return self::_set_cache( self::$_user_enrolled_courses, $key_or_value, $value );
347
  }
348
 
349
  /**
@@ -353,7 +283,7 @@ class LP_Cache {
353
  * @return array|bool|mixed
354
  */
355
  public static function get_enrolled_courses( $key = false, $def = false ) {
356
- return self::_get_cache( self::$_user_enrolled_courses, $key, $def );
357
  }
358
 
359
  /**
@@ -366,10 +296,10 @@ class LP_Cache {
366
  */
367
  public static function set_finished_courses( $key_or_value, $value = false ) {
368
  if ( func_num_args() == 1 ) {
369
- wp_cache_set( self::$_user_finished_courses, $key_or_value, self::$_group );
370
  return $key_or_value;
371
  }
372
- return self::_set_cache( self::$_user_finished_courses, $key_or_value, $value );
373
  }
374
 
375
  /**
@@ -379,7 +309,7 @@ class LP_Cache {
379
  * @return array|bool|mixed
380
  */
381
  public static function get_finished_courses( $key = false, $def = false ) {
382
- return self::_get_cache( self::$_user_finished_courses, $key, $def );
383
  }
384
 
385
  /**
@@ -390,10 +320,10 @@ class LP_Cache {
390
  */
391
  public static function set_course_info( $key_or_value, $value = false ) {
392
  if ( func_num_args() == 1 ) {
393
- wp_cache_set( self::$_user_course_info, $key_or_value, self::$_group );
394
  return $key_or_value;
395
  }
396
- return self::_set_cache( self::$_user_course_info, $key_or_value, $value );
397
  }
398
 
399
  /**
@@ -403,7 +333,7 @@ class LP_Cache {
403
  * @return array|bool|mixed
404
  */
405
  public static function get_course_info( $key = false, $def = false ) {
406
- return self::_get_cache( self::$_user_course_info, $key, $def );
407
  }
408
 
409
  /**
@@ -414,10 +344,10 @@ class LP_Cache {
414
  */
415
  public static function set_course_curriculum( $key_or_value, $value = false ) {
416
  if ( func_num_args() == 1 ) {
417
- wp_cache_set( self::$_course_curriculum, $key_or_value, self::$_group );
418
  return $key_or_value;
419
  }
420
- return self::_set_cache( self::$_course_curriculum, $key_or_value, $value );
421
  }
422
 
423
  /**
@@ -427,7 +357,7 @@ class LP_Cache {
427
  * @return array|bool|mixed
428
  */
429
  public static function get_course_curriculum( $key = false, $def = false ) {
430
- return self::_get_cache( self::$_course_curriculum, $key, $def );
431
  }
432
 
433
  /**
@@ -438,10 +368,10 @@ class LP_Cache {
438
  */
439
  public static function set_item_statuses( $key_or_value, $value = false ) {
440
  if ( func_num_args() == 1 ) {
441
- wp_cache_set( self::$_course_item_statuses, $key_or_value, self::$_group );
442
  return $key_or_value;
443
  }
444
- return self::_set_cache( self::$_course_item_statuses, $key_or_value, $value );
445
  }
446
 
447
  /**
@@ -451,7 +381,7 @@ class LP_Cache {
451
  * @return array|bool|mixed
452
  */
453
  public static function get_item_statuses( $key = false, $def = false ) {
454
- return self::_get_cache( self::$_course_item_statuses, $key, $def );
455
  }
456
 
457
  /**
@@ -462,10 +392,10 @@ class LP_Cache {
462
  */
463
  public static function set_quiz_questions( $key_or_value, $value = false ) {
464
  if ( func_num_args() == 1 ) {
465
- wp_cache_set( self::$_quiz_questions, $key_or_value, self::$_group );
466
  return $key_or_value;
467
  }
468
- return self::_set_cache( self::$_quiz_questions, $key_or_value, $value );
469
  }
470
 
471
  /**
@@ -475,7 +405,7 @@ class LP_Cache {
475
  * @return array|bool|mixed
476
  */
477
  public static function get_quiz_questions( $key = false, $def = false ) {
478
- return self::_get_cache( self::$_quiz_questions, $key, $def );
479
  }
480
 
481
  /**
@@ -486,13 +416,12 @@ class LP_Cache {
486
  */
487
  public static function set_quiz_results( $key_or_value, $value = false ) {
488
  if ( func_num_args() == 1 ) {
489
- wp_cache_set( self::$_quiz_results, $key_or_value, self::$_group );
490
  return $key_or_value;
491
  }
492
- return self::_set_cache( self::$_quiz_results, $key_or_value, $value );
493
  }
494
 
495
-
496
  /**
497
  * @param bool $key
498
  * @param bool $def
@@ -500,7 +429,7 @@ class LP_Cache {
500
  * @return array|bool|mixed
501
  */
502
  public static function get_quiz_results( $key = false, $def = false ) {
503
- return self::_get_cache( self::$_quiz_results, $key, $def );
504
  }
505
 
506
  /**
@@ -511,10 +440,10 @@ class LP_Cache {
511
  */
512
  public static function set_quiz_params( $key_or_value, $value = false ) {
513
  if ( func_num_args() == 1 ) {
514
- wp_cache_set( self::$_quiz_params, $key_or_value, self::$_group );
515
  return $key_or_value;
516
  }
517
- return self::_set_cache( self::$_quiz_params, $key_or_value, $value );
518
  }
519
 
520
  /**
@@ -524,7 +453,7 @@ class LP_Cache {
524
  * @return array|bool|mixed
525
  */
526
  public static function get_quiz_params( $key = false, $def = false ) {
527
- return self::_get_cache( self::$_quiz_params, $key, $def );
528
  }
529
 
530
  /**
@@ -535,10 +464,10 @@ class LP_Cache {
535
  */
536
  public static function set_post_names( $key_or_value, $value = false ) {
537
  if ( func_num_args() == 1 ) {
538
- wp_cache_set( self::$_post_names, $key_or_value, self::$_group );
539
  return $key_or_value;
540
  }
541
- return self::_set_cache( self::$_post_names, $key_or_value, $value );
542
  }
543
 
544
  /**
@@ -548,7 +477,7 @@ class LP_Cache {
548
  * @return array|bool|mixed
549
  */
550
  public static function get_post_names( $key = false, $def = false ) {
551
- return self::_get_cache( self::$_post_names, $key, $def );
552
  }
553
 
554
  /**
@@ -559,10 +488,10 @@ class LP_Cache {
559
  */
560
  public static function set_user_course_order( $key_or_value, $value = false ) {
561
  if ( func_num_args() == 1 ) {
562
- wp_cache_set( self::$_user_course_order, $key_or_value, self::$_group );
563
  return $key_or_value;
564
  }
565
- return self::_set_cache( self::$_user_course_order, $key_or_value, $value );
566
  }
567
 
568
  /**
@@ -572,10 +501,9 @@ class LP_Cache {
572
  * @return array|bool|mixed
573
  */
574
  public static function get_user_course_order( $key = false, $def = false ) {
575
- return self::_get_cache( self::$_user_course_order, $key, $def );
576
  }
577
 
578
-
579
  /**
580
  * @param $key_or_value
581
  * @param bool $value
@@ -584,10 +512,10 @@ class LP_Cache {
584
  */
585
  public static function set_user_profile_orders( $key_or_value, $value = false ) {
586
  if ( func_num_args() == 1 ) {
587
- wp_cache_set( self::$_user_profile_orders, $key_or_value, self::$_group );
588
  return $key_or_value;
589
  }
590
- return self::_set_cache( self::$_user_profile_orders, $key_or_value, $value );
591
  }
592
 
593
  /**
@@ -597,7 +525,7 @@ class LP_Cache {
597
  * @return array|bool|mixed
598
  */
599
  public static function get_user_profile_orders( $key = false, $def = false ) {
600
- return self::_get_cache( self::$_user_profile_orders, $key, $def );
601
  }
602
 
603
  /**
@@ -608,10 +536,10 @@ class LP_Cache {
608
  */
609
  public static function set_user_item_id( $key_or_value, $value = false ) {
610
  if ( func_num_args() == 1 ) {
611
- wp_cache_set( self::$_user_item_id, $key_or_value, self::$_group );
612
  return $key_or_value;
613
  }
614
- return self::_set_cache( self::$_user_item_id, $key_or_value, $value );
615
  }
616
 
617
  /**
@@ -621,31 +549,7 @@ class LP_Cache {
621
  * @return array|bool|mixed
622
  */
623
  public static function get_user_item_id( $key = false, $def = false ) {
624
- return self::_get_cache( self::$_user_item_id, $key, $def );
625
- }
626
-
627
- /**
628
- * @param bool $key
629
- * @param bool $def
630
- *
631
- * @return array|bool|mixed
632
- */
633
- public static function get_quiz_grade( $key = false, $def = false ) {
634
- return self::_get_cache( self::$_quiz_grade, $key, $def );
635
- }
636
-
637
- /**
638
- * @param $key_or_value
639
- * @param bool $value
640
- *
641
- * @return array|bool|mixed
642
- */
643
- public static function set_quiz_grade( $key_or_value, $value = false ) {
644
- if ( func_num_args() == 1 ) {
645
- wp_cache_set( self::$_quiz_grade, $key_or_value, self::$_group );
646
- return $key_or_value;
647
- }
648
- return self::_set_cache( self::$_quiz_grade, $key_or_value, $value );
649
  }
650
 
651
  /**
@@ -670,24 +574,30 @@ class LP_Cache {
670
  }
671
  }
672
  } else {
673
- try {
674
- $reflection = new ReflectionClass( "LP_Cache" );
675
- $staticProperties = $reflection->getStaticProperties();
676
- foreach ( $staticProperties as $key => $value ) {
677
- if ( in_array( $key, array( '_group' ) ) ) {
678
- continue;
 
 
 
 
 
 
 
 
 
 
 
 
679
  }
680
- wp_cache_delete( $value, self::$_group );
681
  }
682
- } catch ( Exception $ex ) {
683
  }
684
  }
685
  }
686
 
687
- public static function cache_flush( $url ) {
688
- return add_query_arg( 'cache-flush', microtime( true ), $url );
689
- }
690
-
691
  /**
692
  * @param int|string $key
693
  * @param int|string $field
@@ -715,26 +625,10 @@ class LP_Cache {
715
  private static function _get_cache( $key, $field = false, $def = false ) {
716
  $cached = wp_cache_get( $key, self::$_group );
717
  if ( is_array( $cached ) && $field ) {
718
- $return = array_key_exists( $field, $cached ) ? $cached[$field] : false;
719
  } else {
720
  $return = $cached;
721
  }
722
- return ( $return || $def === false ) ? $return : $def;
723
- }
724
-
725
- public static function init() {
726
- /*try {
727
- self::flush();
728
- } catch ( Exception $ex ) {
729
-
730
- }
731
- add_action( 'init', array( __CLASS__, 'redirect' ) );*/
732
  }
733
-
734
- public static function redirect() {
735
- if ( !empty( $_REQUEST['cache-flush'] ) ) {
736
- }
737
- }
738
- }
739
-
740
- LP_Cache::init();
16
  /**
17
  * @var array
18
  */
19
+ protected static $_data = array();
20
 
21
  /**
22
  * @var string
48
  */
49
  protected static $_evaluate_course_by_lesson = 'user-evaluate-course-by-lesson';
50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  /**
52
  * @var string
53
  */
54
  protected static $_quiz_history = 'user-quiz-history';
55
 
 
 
 
 
 
56
  /**
57
  * Set data to cache
58
  *
244
  public static function set_completed_items( $key_or_value, $value = false ) {
245
  //return self::_set_cache( 'user-completed-items', $key, $value );
246
  if ( func_num_args() == 1 ) {
247
+ wp_cache_set( 'user-completed-items', $key_or_value, self::$_group );
248
  return $key_or_value;
249
  }
250
+ return self::_set_cache( 'user-completed-items', $key_or_value, $value );
251
  }
252
 
253
  /**
259
  * @return array|bool|mixed
260
  */
261
  public static function get_completed_items( $key = false, $def = false ) {
262
+ return self::_get_cache( 'user-completed-items', $key, $def );
263
  }
264
 
265
  /**
268
  *
269
  * @return array|bool|mixed
270
  */
271
+ public static function set_enrolled_courses( $key_or_value, $value ) {
272
  if ( func_num_args() == 1 ) {
273
+ wp_cache_set( 'user-enrolled-courses', $key_or_value, self::$_group );
274
  return $key_or_value;
275
  }
276
+ return self::_set_cache( 'user-enrolled-courses', $key_or_value, $value );
277
  }
278
 
279
  /**
283
  * @return array|bool|mixed
284
  */
285
  public static function get_enrolled_courses( $key = false, $def = false ) {
286
+ return self::_get_cache( 'user-enrolled-courses', $key, $def );
287
  }
288
 
289
  /**
296
  */
297
  public static function set_finished_courses( $key_or_value, $value = false ) {
298
  if ( func_num_args() == 1 ) {
299
+ wp_cache_set( 'user-finished-courses', $key_or_value, self::$_group );
300
  return $key_or_value;
301
  }
302
+ return self::_set_cache( 'user-finished-courses', $key_or_value, $value );
303
  }
304
 
305
  /**
309
  * @return array|bool|mixed
310
  */
311
  public static function get_finished_courses( $key = false, $def = false ) {
312
+ return self::_get_cache( 'user-finished-courses', $key, $def );
313
  }
314
 
315
  /**
320
  */
321
  public static function set_course_info( $key_or_value, $value = false ) {
322
  if ( func_num_args() == 1 ) {
323
+ wp_cache_set( 'user-course-info', $key_or_value, self::$_group );
324
  return $key_or_value;
325
  }
326
+ return self::_set_cache( 'user-course-info', $key_or_value, $value );
327
  }
328
 
329
  /**
333
  * @return array|bool|mixed
334
  */
335
  public static function get_course_info( $key = false, $def = false ) {
336
+ return self::_get_cache( 'user-course-info', $key, $def );
337
  }
338
 
339
  /**
344
  */
345
  public static function set_course_curriculum( $key_or_value, $value = false ) {
346
  if ( func_num_args() == 1 ) {
347
+ wp_cache_set( 'course-curriculum', $key_or_value, self::$_group );
348
  return $key_or_value;
349
  }
350
+ return self::_set_cache( 'course-curriculum', $key_or_value, $value );
351
  }
352
 
353
  /**
357
  * @return array|bool|mixed
358
  */
359
  public static function get_course_curriculum( $key = false, $def = false ) {
360
+ return self::_get_cache( 'course-curriculum', $key, $def );
361
  }
362
 
363
  /**
368
  */
369
  public static function set_item_statuses( $key_or_value, $value = false ) {
370
  if ( func_num_args() == 1 ) {
371
+ wp_cache_set( 'course-item-statuses', $key_or_value, self::$_group );
372
  return $key_or_value;
373
  }
374
+ return self::_set_cache( 'course-item-statuses', $key_or_value, $value );
375
  }
376
 
377
  /**
381
  * @return array|bool|mixed
382
  */
383
  public static function get_item_statuses( $key = false, $def = false ) {
384
+ return self::_get_cache( 'course-item-statuses', $key, $def );
385
  }
386
 
387
  /**
392
  */
393
  public static function set_quiz_questions( $key_or_value, $value = false ) {
394
  if ( func_num_args() == 1 ) {
395
+ wp_cache_set( 'quiz-questions', $key_or_value, self::$_group );
396
  return $key_or_value;
397
  }
398
+ return self::_set_cache( 'quiz-questions', $key_or_value, $value );
399
  }
400
 
401
  /**
405
  * @return array|bool|mixed
406
  */
407
  public static function get_quiz_questions( $key = false, $def = false ) {
408
+ return self::_get_cache( 'quiz-questions', $key, $def );
409
  }
410
 
411
  /**
416
  */
417
  public static function set_quiz_results( $key_or_value, $value = false ) {
418
  if ( func_num_args() == 1 ) {
419
+ wp_cache_set( 'quiz-results', $key_or_value, self::$_group );
420
  return $key_or_value;
421
  }
422
+ return self::_set_cache( 'quiz-results', $key_or_value, $value );
423
  }
424
 
 
425
  /**
426
  * @param bool $key
427
  * @param bool $def
429
  * @return array|bool|mixed
430
  */
431
  public static function get_quiz_results( $key = false, $def = false ) {
432
+ return self::_get_cache( 'quiz-results', $key, $def );
433
  }
434
 
435
  /**
440
  */
441
  public static function set_quiz_params( $key_or_value, $value = false ) {
442
  if ( func_num_args() == 1 ) {
443
+ wp_cache_set( 'quiz-params', $key_or_value, self::$_group );
444
  return $key_or_value;
445
  }
446
+ return self::_set_cache( 'quiz-params', $key_or_value, $value );
447
  }
448
 
449
  /**
453
  * @return array|bool|mixed
454
  */
455
  public static function get_quiz_params( $key = false, $def = false ) {
456
+ return self::_get_cache( 'quiz-params', $key, $def );
457
  }
458
 
459
  /**
464
  */
465
  public static function set_post_names( $key_or_value, $value = false ) {
466
  if ( func_num_args() == 1 ) {
467
+ wp_cache_set( 'post-names', $key_or_value, self::$_group );
468
  return $key_or_value;
469
  }
470
+ return self::_set_cache( 'post-names', $key_or_value, $value );
471
  }
472
 
473
  /**
477
  * @return array|bool|mixed
478
  */
479
  public static function get_post_names( $key = false, $def = false ) {
480
+ return self::_get_cache( 'post-names', $key, $def );
481
  }
482
 
483
  /**
488
  */
489
  public static function set_user_course_order( $key_or_value, $value = false ) {
490
  if ( func_num_args() == 1 ) {
491
+ wp_cache_set( 'user-course-order', $key_or_value, self::$_group );
492
  return $key_or_value;
493
  }
494
+ return self::_set_cache( 'user-course-order', $key_or_value, $value );
495
  }
496
 
497
  /**
501
  * @return array|bool|mixed
502
  */
503
  public static function get_user_course_order( $key = false, $def = false ) {
504
+ return self::_get_cache( 'user-course-order', $key, $def );
505
  }
506
 
 
507
  /**
508
  * @param $key_or_value
509
  * @param bool $value
512
  */
513
  public static function set_user_profile_orders( $key_or_value, $value = false ) {
514
  if ( func_num_args() == 1 ) {
515
+ wp_cache_set( 'user-profile-orders', $key_or_value, self::$_group );
516
  return $key_or_value;
517
  }
518
+ return self::_set_cache( 'user-profile-orders', $key_or_value, $value );
519
  }
520
 
521
  /**
525
  * @return array|bool|mixed
526
  */
527
  public static function get_user_profile_orders( $key = false, $def = false ) {
528
+ return self::_get_cache( 'user-profile-orders', $key, $def );
529
  }
530
 
531
  /**
536
  */
537
  public static function set_user_item_id( $key_or_value, $value = false ) {
538
  if ( func_num_args() == 1 ) {
539
+ wp_cache_set( 'user-item-id', $key_or_value, self::$_group );
540
  return $key_or_value;
541
  }
542
+ return self::_set_cache( 'user-item-id', $key_or_value, $value );
543
  }
544
 
545
  /**
549
  * @return array|bool|mixed
550
  */
551
  public static function get_user_item_id( $key = false, $def = false ) {
552
+ return self::_get_cache( 'user-item-id', $key, $def );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
553
  }
554
 
555
  /**
574
  }
575
  }
576
  } else {
577
+ global $wp_object_cache;
578
+
579
+
580
+ if ( @$cache = $wp_object_cache->cache ) {
581
+ if ( !empty( $cache[self::$_group] ) ) {
582
+ unset( $cache[self::$_group] );
583
+ $wp_object_cache->cache = $cache;
584
+ }
585
+ if ( is_callable( array( $wp_object_cache, 'get_mc' ) ) ) {
586
+ $group = self::$_group;
587
+ foreach ( $wp_object_cache->mc as $bucket => $mc ) {
588
+ if ( $bucket !== $group ) {
589
+ continue;
590
+ }
591
+ if ( $wp_object_cache->reset_generation( $bucket ) === false ) {
592
+ $mc->flush();
593
+ $wp_object_cache->reset_generation( $bucket );
594
+ }
595
  }
 
596
  }
 
597
  }
598
  }
599
  }
600
 
 
 
 
 
601
  /**
602
  * @param int|string $key
603
  * @param int|string $field
625
  private static function _get_cache( $key, $field = false, $def = false ) {
626
  $cached = wp_cache_get( $key, self::$_group );
627
  if ( is_array( $cached ) && $field ) {
628
+ $return = !array_key_exists( $field, $cached ) ? $cached[$field] : false;
629
  } else {
630
  $return = $cached;
631
  }
632
+ return $return ? $return : $def;
 
 
 
 
 
 
 
 
 
633
  }
634
+ }
 
 
 
 
 
 
 
inc/class-lp-emails.php CHANGED
@@ -7,7 +7,7 @@
7
  * @package LearnPress/Classes
8
  * @version 1.0
9
  */
10
- if ( ! defined( 'ABSPATH' ) ) {
11
  exit;
12
  }
13
 
@@ -27,46 +27,42 @@ class LP_Emails {
27
  * @static
28
  * @return LP_Emails instance
29
  */
30
- public static function instance () {
31
  if ( is_null( self::$_instance ) ) {
32
  self::$_instance = new self();
33
  self::init_email_notifications();
34
  }
35
-
36
  return self::$_instance;
37
  }
38
 
39
  /**
40
  * @version 1.0
41
  */
42
- public function __clone () {
43
  _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'learnpress' ), '1.0' );
44
  }
45
 
46
  /**
47
  * @version 1.0
48
  */
49
- public function __wakeup () {
50
  _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'learnpress' ), '1.0' );
51
  }
52
 
53
- public function __construct () {
54
  if ( did_action( 'learn_press_emails_init' ) ) {
55
  return;
56
  }
57
  LP()->_include( 'emails/class-lp-email.php' );
58
- $this->emails['LP_Email_New_Order'] = include( 'emails/class-lp-email-new-order.php' );
59
- $this->emails['LP_Email_New_Order_Customer'] = include( 'emails/class-lp-email-new-order-customer.php' );
60
- $this->emails['LP_Email_User_Order_Completed'] = include( 'emails/class-lp-email-user-order-completed.php' );
61
- $this->emails['LP_Email_User_Order_Changed_Status'] = include( 'emails/class-lp-email-user-order-changed-status.php' );
62
- $this->emails['LP_Email_New_Course'] = include( 'emails/class-lp-email-new-course.php' );
63
- $this->emails['LP_Email_Rejected_Course'] = include( 'emails/class-lp-email-rejected-course.php' );
64
- $this->emails['LP_Email_Published_Course'] = include( 'emails/class-lp-email-published-course.php' );
65
- $this->emails['LP_Email_Enrolled_Course'] = include( 'emails/class-lp-email-enrolled-course.php' );
66
- $this->emails['LP_Email_Enrolled_Course_Admin'] = include( 'emails/class-lp-email-enrolled-course-admin.php' );
67
- $this->emails['LP_Email_Finished_Course'] = include( 'emails/class-lp-email-finished-course.php' );
68
- $this->emails['LP_Email_Update_Course'] = include( 'emails/class-lp-email-update-course.php' );
69
- $this->emails['LP_Email_Become_An_Instructor'] = include( 'emails/class-lp-email-become-an-instructor.php' );
70
 
71
  add_action( 'learn_press_course_submit_for_reviewer_notification', array( $this, 'review_course' ), 10, 2 );
72
  add_action( 'learn_press_course_submit_rejected_notification', array( $this, 'course_rejected' ), 10, 2 );
@@ -82,33 +78,32 @@ class LP_Emails {
82
  do_action( 'learn_press_emails_init', $this );
83
  }
84
 
85
- public function email_header ( $heading, $return = false ) {
86
  ob_start();
87
  learn_press_get_template( 'emails/email-header.php', array( 'email_heading' => $heading ) );
88
  $header = ob_get_clean();
89
- if ( ! $return ) {
90
  echo $header;
91
  } else {
92
  return $header;
93
  }
94
  }
95
 
96
- public function email_footer ( $footer_text, $return = false ) {
97
  ob_start();
98
  learn_press_get_template( 'emails/email-footer.php', array( 'footer_text' => $footer_text ) );
99
  $footer = ob_get_clean();
100
- if ( ! $return ) {
101
  echo $footer;
102
  } else {
103
  return $footer;
104
  }
105
  }
106
 
107
- public static function send_email () {
108
  self::instance();
109
  $args = func_get_args();
110
  do_action_ref_array( current_filter() . '_notification', $args );
111
-
112
  return isset( $args[0] ) ? $args[0] : null;
113
  }
114
 
@@ -118,29 +113,29 @@ class LP_Emails {
118
  * @param $course_id
119
  * @param $user
120
  */
121
- public function review_course ( $course_id, $user ) {
122
  $mail = $this->emails['LP_Email_New_Course'];
123
  $mail->trigger( $course_id, $user );
124
  }
125
 
126
- public function course_rejected ( $course_id ) {
127
  $course_user = learn_press_get_user( get_post_field( 'post_author', $course_id ) );
128
- if ( ! $course_user->is_admin() ) {
129
  $mail = $this->emails['LP_Email_Rejected_Course'];
130
  $mail->trigger( $course_id );
131
  }
132
  }
133
 
134
- public function course_approved ( $course_id, $user ) {
135
  $course_user = learn_press_get_user( get_post_field( 'post_author', $course_id ) );
136
- if ( ! $course_user->is_admin() ) {
137
  $mail = $this->emails['LP_Email_Published_Course'];
138
  $mail->trigger( $course_id, $user );
139
  }
140
  }
141
 
142
- public function finish_course ( $course_id, $user_id, $result ) {
143
- if ( ! $user = learn_press_get_user( $user_id ) ) {
144
  return;
145
  }
146
  $mail = $this->emails['LP_Email_Finished_Course'];
@@ -155,21 +150,20 @@ class LP_Emails {
155
  *
156
  * @return array
157
  */
158
- public function customer_new_order ( $result, $order_id ) {
159
  $mail = $this->emails['LP_Email_New_Order_Customer'];
160
  $mail->trigger( $order_id );
161
-
162
  return $result;
163
  }
164
 
165
- public function become_an_teacher ( $user_id, $role, $old_role ) {
166
  if ( $role === LP_TEACHER_ROLE ) {
167
  $mail = $this->emails['LP_Email_Become_An_Instructor'];
168
  $mail->trigger( $user_id );
169
  }
170
  }
171
 
172
- public static function init_email_notifications () {
173
  $actions = apply_filters(
174
  'learn_press_email_actions',
175
  array(
7
  * @package LearnPress/Classes
8
  * @version 1.0
9
  */
10
+ if ( !defined( 'ABSPATH' ) ) {
11
  exit;
12
  }
13
 
27
  * @static
28
  * @return LP_Emails instance
29
  */
30
+ public static function instance() {
31
  if ( is_null( self::$_instance ) ) {
32
  self::$_instance = new self();
33
  self::init_email_notifications();
34
  }
 
35
  return self::$_instance;
36
  }
37
 
38
  /**
39
  * @version 1.0
40
  */
41
+ public function __clone() {
42
  _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'learnpress' ), '1.0' );
43
  }
44
 
45
  /**
46
  * @version 1.0
47
  */
48
+ public function __wakeup() {
49
  _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'learnpress' ), '1.0' );
50
  }
51
 
52
+ public function __construct() {
53
  if ( did_action( 'learn_press_emails_init' ) ) {
54
  return;
55
  }
56
  LP()->_include( 'emails/class-lp-email.php' );
57
+ $this->emails['LP_Email_New_Order'] = include( 'emails/class-lp-email-new-order.php' );
58
+ $this->emails['LP_Email_New_Order_Customer'] = include( 'emails/class-lp-email-new-order-customer.php' );
59
+ $this->emails['LP_Email_User_Order_Completed'] = include( 'emails/class-lp-email-user-order-completed.php' );
60
+ $this->emails['LP_Email_New_Course'] = include( 'emails/class-lp-email-new-course.php' );
61
+ $this->emails['LP_Email_Rejected_Course'] = include( 'emails/class-lp-email-rejected-course.php' );
62
+ $this->emails['LP_Email_Published_Course'] = include( 'emails/class-lp-email-published-course.php' );
63
+ $this->emails['LP_Email_Enrolled_Course'] = include( 'emails/class-lp-email-enrolled-course.php' );
64
+ $this->emails['LP_Email_Finished_Course'] = include( 'emails/class-lp-email-finished-course.php' );
65
+ $this->emails['LP_Email_Become_An_Instructor'] = include( 'emails/class-lp-email-become-an-instructor.php' );
 
 
 
66
 
67
  add_action( 'learn_press_course_submit_for_reviewer_notification', array( $this, 'review_course' ), 10, 2 );
68
  add_action( 'learn_press_course_submit_rejected_notification', array( $this, 'course_rejected' ), 10, 2 );
78
  do_action( 'learn_press_emails_init', $this );
79
  }
80
 
81
+ public function email_header( $heading, $return = false ) {
82
  ob_start();
83
  learn_press_get_template( 'emails/email-header.php', array( 'email_heading' => $heading ) );
84
  $header = ob_get_clean();
85
+ if ( !$return ) {
86
  echo $header;
87
  } else {
88
  return $header;
89
  }
90
  }
91
 
92
+ public function email_footer( $footer_text, $return = false ) {
93
  ob_start();
94
  learn_press_get_template( 'emails/email-footer.php', array( 'footer_text' => $footer_text ) );
95
  $footer = ob_get_clean();
96
+ if ( !$return ) {
97
  echo $footer;
98
  } else {
99
  return $footer;
100
  }
101
  }
102
 
103
+ public static function send_email() {
104
  self::instance();
105
  $args = func_get_args();
106
  do_action_ref_array( current_filter() . '_notification', $args );
 
107
  return isset( $args[0] ) ? $args[0] : null;
108
  }
109
 
113
  * @param $course_id
114
  * @param $user
115
  */
116
+ public function review_course( $course_id, $user ) {
117
  $mail = $this->emails['LP_Email_New_Course'];
118
  $mail->trigger( $course_id, $user );
119
  }
120
 
121
+ public function course_rejected( $course_id ) {
122
  $course_user = learn_press_get_user( get_post_field( 'post_author', $course_id ) );
123
+ if ( !$course_user->is_admin() ) {
124
  $mail = $this->emails['LP_Email_Rejected_Course'];
125
  $mail->trigger( $course_id );
126
  }
127
  }
128
 
129
+ public function course_approved( $course_id, $user ) {
130
  $course_user = learn_press_get_user( get_post_field( 'post_author', $course_id ) );
131
+ if ( !$course_user->is_admin() ) {
132
  $mail = $this->emails['LP_Email_Published_Course'];
133
  $mail->trigger( $course_id, $user );
134
  }
135
  }
136
 
137
+ public function finish_course( $course_id, $user_id, $result ) {
138
+ if ( !$user = learn_press_get_user( $user_id ) ) {
139
  return;
140
  }
141
  $mail = $this->emails['LP_Email_Finished_Course'];
150
  *
151
  * @return array
152
  */
153
+ public function customer_new_order( $result, $order_id ) {
154
  $mail = $this->emails['LP_Email_New_Order_Customer'];
155
  $mail->trigger( $order_id );
 
156
  return $result;
157
  }
158
 
159
+ public function become_an_teacher( $user_id, $role, $old_role ) {
160
  if ( $role === LP_TEACHER_ROLE ) {
161
  $mail = $this->emails['LP_Email_Become_An_Instructor'];
162
  $mail->trigger( $user_id );
163
  }
164
  }
165
 
166
+ public static function init_email_notifications() {
167
  $actions = apply_filters(
168
  'learn_press_email_actions',
169
  array(
inc/class-lp-page-controller.php CHANGED
@@ -89,7 +89,7 @@ class LP_Page_Controller {
89
 
90
  if ( !empty( $wp_query->query['paged'] ) ) {
91
  if ( $wp_rewrite->using_permalinks() ) {
92
- $redirect = $redirect . 'page/' . $wp_query->query['paged'] . '/';
93
  } else {
94
  $redirect = add_query_arg( 'paged', $wp_query->query['paged'], $redirect );
95
  }
@@ -205,12 +205,20 @@ class LP_Page_Controller {
205
  if ( LEARNPRESS_IS_COURSES || LEARNPRESS_IS_TAG || LEARNPRESS_IS_CATEGORY || LEARNPRESS_IS_SEARCH || LEARNPRESS_IS_TAX ) {
206
 
207
  global $wp_query, $post, $wp;
208
- if(is_callable('clone')) {
209
- LP()->wp_query = clone( $wp_query );
210
- }else{
211
- // PHP 7
212
- LP()->wp_query = clone $wp_query;
 
 
 
 
 
 
213
  }
 
 
214
 
215
  $template = get_page_template();
216
  /**
@@ -328,6 +336,7 @@ class LP_Page_Controller {
328
 
329
  global $course;
330
 
 
331
 
332
  // We only want to affect the main query and not in admin
333
  if ( !$q->is_main_query() || is_admin() ) {
89
 
90
  if ( !empty( $wp_query->query['paged'] ) ) {
91
  if ( $wp_rewrite->using_permalinks() ) {
92
+ $redirect = $redirect . 'page/' . $wp_query->query['paged'];
93
  } else {
94
  $redirect = add_query_arg( 'paged', $wp_query->query['paged'], $redirect );
95
  }
205
  if ( LEARNPRESS_IS_COURSES || LEARNPRESS_IS_TAG || LEARNPRESS_IS_CATEGORY || LEARNPRESS_IS_SEARCH || LEARNPRESS_IS_TAX ) {
206
 
207
  global $wp_query, $post, $wp;
208
+
209
+ if ( !empty( $wp_query->posts ) ) {
210
+ $ids = array();
211
+ foreach ( $wp_query->posts as $_post ) {
212
+ $ids[] = $_post->ID;
213
+ $_post = sanitize_post( $_post, 'raw' );
214
+ wp_cache_add( $_post->ID, $_post, 'posts' );
215
+ }
216
+ _learn_press_get_courses_curriculum( $ids );
217
+ _learn_press_get_users_enrolled_courses( $ids );
218
+ update_meta_cache( 'post', $ids );
219
  }
220
+ LP()->wp_query = clone( $wp_query );
221
+
222
 
223
  $template = get_page_template();
224
  /**
336
 
337
  global $course;
338
 
339
+ LP_Debug::instance()->add( $q, 'wp_query' );
340
 
341
  // We only want to affect the main query and not in admin
342
  if ( !$q->is_main_query() || is_admin() ) {
inc/class-lp-query.php CHANGED
@@ -91,6 +91,75 @@ class LP_Query {
91
  }
92
  $this->query_vars['course_id'] = $course_id;
93
  do_action_ref_array( 'learn_press_parse_query', array( &$this ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  }
95
 
96
  /**
@@ -166,22 +235,9 @@ class LP_Query {
166
  $slug = preg_replace( '!(%?course_category%?)!', '(.+?)/([^/]+)', $slug );
167
  $has_category = true;
168
  }
169
- $current_url = learn_press_get_current_url();
170
- $query_string = str_replace( trailingslashit( get_site_url() ), '', $current_url );
171
- $custom_slug_lesson = sanitize_title_with_dashes( LP()->settings->get( 'lesson_slug' ) );
172
- $custom_slug_quiz = sanitize_title_with_dashes( LP()->settings->get( 'quiz_slug' ) );
173
 
174
- /**
175
- * Use urldecode to convert an encoded string to normal.
176
- * This fixed the issue with custom slug of lesson/quiz in some languages
177
- * Eg: урока
178
- */
179
- if ( !empty( $custom_slug_lesson ) ) {
180
- $post_types['lp_lesson']->rewrite['slug'] = urldecode( $custom_slug_lesson );
181
- }
182
- if ( !empty( $custom_slug_quiz ) ) {
183
- $post_types['lp_quiz']->rewrite['slug'] = urldecode( $custom_slug_quiz );
184
- }
185
  if ( $has_category ) {
186
  add_rewrite_rule(
187
  '^' . $slug . '(?:/' . $post_types['lp_lesson']->rewrite['slug'] . '/([^/]+))/?$',
@@ -195,6 +251,16 @@ class LP_Query {
195
  );
196
  } else {
197
 
 
 
 
 
 
 
 
 
 
 
198
  add_rewrite_rule(
199
  '^' . $slug . '/([^/]+)(?:/' . $post_types['lp_lesson']->rewrite['slug'] . '/([^/]+))/?$',
200
  'index.php?' . $course_type . '=$matches[1]&lesson=$matches[2]',
@@ -221,8 +287,51 @@ class LP_Query {
221
  'index.php?pagename=' . get_post_field( 'post_name', $course_page_id ) . '&page=$matches[1]',
222
  'top'
223
  );
 
 
 
 
 
 
224
  }
225
  do_action( 'learn_press_add_rewrite_rules' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
226
  }
227
 
228
  /**
91
  }
92
  $this->query_vars['course_id'] = $course_id;
93
  do_action_ref_array( 'learn_press_parse_query', array( &$this ) );
94
+
95
+ return $q;
96
+ /************************/
97
+ $slug = preg_replace( '!^/!', '', $post_types[$course_type]->rewrite['slug'] );
98
+
99
+ $match = '^' . $slug . '/([^/]*)/(' . $post_types['lp_quiz']->rewrite['slug'] . ')?/([^/]*)?/?([^/]*)?';
100
+
101
+ $request_match = $request;
102
+ $course_id = 0;
103
+ if ( !empty( $q->query_vars['post_type'] ) && $q->query_vars['post_type'] == LP_COURSE_CPT ) {
104
+ if ( !empty( $q->query_vars[LP_COURSE_CPT] ) ) {
105
+ $this->query_vars['course'] = $q->query_vars[LP_COURSE_CPT];
106
+ $course_id = learn_press_setup_course_data( $this->query_vars['course'] );
107
+ }
108
+ if ( !empty( $q->query_vars['quiz'] ) ) {
109
+ $this->query_vars['quiz'] = $q->query_vars['quiz'];
110
+ $this->query_vars['item_type'] = LP_QUIZ_CPT;
111
+ } elseif ( !empty( $q->query_vars['lesson'] ) ) {
112
+ $this->query_vars['lesson'] = $q->query_vars['lesson'];
113
+ $this->query_vars['item_type'] = LP_LESSON_CPT;
114
+ }
115
+ }
116
+
117
+ /**
118
+ * Match request URI with quiz permalink
119
+ */
120
+ if ( preg_match( "#^$match#", $request_match, $matches ) || preg_match( "#^$match#", urldecode( $request_match ), $matches ) ) {
121
+
122
+ // If request URI is a quiz permalink
123
+ if ( !empty( $matches[3] ) ) {
124
+ if ( !$post = learn_press_get_post_by_name( $matches[3], 'lp_quiz', true ) ) {
125
+ return $q;
126
+ }
127
+ // If request URI does not contains a question
128
+ // Try to get current question of current user and put it into URI
129
+ if ( empty( $matches[4] ) ) {
130
+ if ( $user->has_quiz_status( 'started', $post->ID, $course_id ) && $question_id = $user->get_current_quiz_question( $post->ID, $course_id ) ) {
131
+ $this->query_vars['question'] = $q->query_vars['question'] = get_post_field( 'post_name', $question_id );
132
+ }
133
+ } else {
134
+ // If user is viewing a question then update current question for user
135
+ $question = learn_press_get_post_by_name( $matches[4], 'lp_question' );
136
+ /**
137
+ * If user has completed a quiz but they are accessing to a question inside quiz,
138
+ * redirect them back to quiz to show results of that quiz instead
139
+ */
140
+ if ( $user->has_quiz_status( 'completed', $post->ID, $course_id ) ) {
141
+ //remove question name from uri
142
+ $redirect = get_site_url() . '/' . dirname( $request_match );
143
+ wp_redirect( $redirect );
144
+ exit();
145
+ }
146
+ if ( $question ) {
147
+ global $wpdb;
148
+ $query = $wpdb->prepare( "
149
+ SELECT MAX(user_item_id)
150
+ FROM {$wpdb->prefix}learnpress_user_items
151
+ WHERE user_id = %d AND item_id = %d AND item_type = %s and status <> %s
152
+ ", learn_press_get_current_user_id(), $post->ID, 'lp_quiz', 'completed' );
153
+ if ( $history_id = $wpdb->get_var( $query ) ) {
154
+ learn_press_update_user_item_meta( $history_id, 'current_question', $question->ID );
155
+ }
156
+ }
157
+ }
158
+ }
159
+ }
160
+ $this->query_vars['course_id'] = $course_id;
161
+ do_action_ref_array( 'learn_press_parse_query', array( &$this ) );
162
+ return $q;
163
  }
164
 
165
  /**
235
  $slug = preg_replace( '!(%?course_category%?)!', '(.+?)/([^/]+)', $slug );
236
  $has_category = true;
237
  }
238
+ $current_url = learn_press_get_current_url();
239
+ $query_string = str_replace( trailingslashit( get_site_url() ), '', $current_url );
 
 
240
 
 
 
 
 
 
 
 
 
 
 
 
241
  if ( $has_category ) {
242
  add_rewrite_rule(
243
  '^' . $slug . '(?:/' . $post_types['lp_lesson']->rewrite['slug'] . '/([^/]+))/?$',
251
  );
252
  } else {
253
 
254
+ $custom_slug_lesson = sanitize_title_with_dashes( LP()->settings->get( 'lesson_slug' ) );
255
+ $custom_slug_quiz = sanitize_title_with_dashes( LP()->settings->get( 'quiz_slug' ) );
256
+
257
+ if ( !empty( $custom_slug_lesson ) ) {
258
+ $post_types['lp_lesson']->rewrite['slug'] = $custom_slug_lesson;
259
+ }
260
+ if ( !empty( $custom_slug_quiz ) ) {
261
+ $post_types['lp_quiz']->rewrite['slug'] = $custom_slug_quiz;
262
+ }
263
+
264
  add_rewrite_rule(
265
  '^' . $slug . '/([^/]+)(?:/' . $post_types['lp_lesson']->rewrite['slug'] . '/([^/]+))/?$',
266
  'index.php?' . $course_type . '=$matches[1]&lesson=$matches[2]',
287
  'index.php?pagename=' . get_post_field( 'post_name', $course_page_id ) . '&page=$matches[1]',
288
  'top'
289
  );
290
+ /**
291
+ * add_rewrite_rule(
292
+ * '^' . $rewrite_prefix . get_post_field( 'post_name', $course_page_id ) . '/page/([0-9]{1,})/?$',
293
+ * 'index.php?page_id=' . $course_page_id . '&paged=$matches[1]',
294
+ * 'top'
295
+ * );*/
296
  }
297
  do_action( 'learn_press_add_rewrite_rules' );
298
+ return;
299
+
300
+ /**
301
+ * Lesson permalink without category
302
+ */
303
+ /*add_rewrite_rule(
304
+ '^' . $slug . '/([^/]*)/(' . $post_types['lp_lesson']->rewrite['slug'] . ')/([^/]+)/?$',
305
+ 'index.php?' . $course_type . '=$matches[1]&lesson=$matches[3]',
306
+ 'top'
307
+ );*/
308
+
309
+ /**
310
+ * Quiz permalink with category inside
311
+ */
312
+ add_rewrite_rule(
313
+ '^course/(.+?)/([^/]+)(?:/' . $post_types['lp_quiz']->rewrite['slug'] . '/([^/]+))/?$',
314
+ 'index.php?' . $course_type . '=$matches[2]&course_category=$matches[1]&quiz=$matches[3]',
315
+ 'top'
316
+ );
317
+
318
+ /**
319
+ * Lesson permalink without category
320
+ */
321
+ add_rewrite_rule(
322
+ '^' . $slug . '/([^/]*)/(' . $post_types['lp_quiz']->rewrite['slug'] . ')/([^/]+)/?$',
323
+ 'index.php?' . $course_type . '=$matches[1]&quiz=$matches[3]',
324
+ 'top'
325
+ );
326
+
327
+
328
+ /*add_rewrite_rule(
329
+ '^' . $slug . '/([^/]*)/(' . $post_types['lp_quiz']->rewrite['slug'] . ')?/([^/]*)?/?([^/]*)?',
330
+ 'index.php?' . $course_type . '=$matches[1]&quiz=$matches[3]&question=$matches[4]',
331
+ 'top'
332
+ );*/
333
+
334
+
335
  }
336
 
337
  /**
inc/class-lp-request-handler.php CHANGED
@@ -28,31 +28,17 @@ class LP_Request_Handler {
28
  * Constructor
29
  */
30
  public static function init() {
31
- if ( is_admin() ) {
32
- add_action( 'init', array( __CLASS__, 'process_request' ), 50 );
33
- } else {
34
- add_action( 'wp', array( __CLASS__, 'process_request' ), 50 );
35
- }
36
 
37
- add_action( 'get_header', array( __CLASS__, 'clean_cache' ), 1000000 );
38
- add_action( 'save_post', array( __CLASS__, 'clean_cache' ), 1000000 );
39
 
 
 
 
40
  LP_Request_Handler::register( 'purchase-course', 'learn_press_purchase_course_handler', 20 );
41
  LP_Request_Handler::register( 'enroll-course', 'learn_press_purchase_course_handler', 20 );
42
  }
43
 
44
- public static function clean_cache() {
45
- if ( strtolower( $_SERVER['REQUEST_METHOD'] ) == 'post' ) {
46
- add_filter( 'wp_redirect', array( __CLASS__, 'redirect' ) );
47
- LP_Cache::flush();
48
- }
49
- }
50
-
51
- public static function redirect( $url ) {
52
- remove_filter( 'wp_redirect', array( __CLASS__, 'redirect' ) );
53
- return add_query_arg( 'lp-reload', 'yes', $url );
54
- }
55
-
56
  public static function get_header() {
57
  ob_start();
58
  }
@@ -61,35 +47,22 @@ class LP_Request_Handler {
61
  * Process actions
62
  */
63
  public static function process_request() {
64
- if ( !empty( $_REQUEST['lp-reload'] ) ) {
65
- wp_redirect( remove_query_arg( 'lp-reload' ) );
66
- exit();
67
- }
68
  if ( !empty( $_REQUEST ) ) foreach ( $_REQUEST as $key => $value ) {
69
  do_action( 'learn_press_request_handler_' . $key, $value, $_REQUEST );
70
  }
 
71
  }
72
 
73
  /**
74
  * Register new request
75
  *
76
- * @param string|array $action
77
- * @param mixed $function
78
- * @param int $priority
79
  */
80
- public static function register( $action, $function = '', $priority = 5 ) {
81
- if ( is_array( $action ) ) {
82
- foreach ( $action as $item ) {
83
- $item = wp_parse_args( $item, array( 'action' => '', 'callback' => '', 'priority' => 5 ) );
84
- if ( !$item['action'] || !$item['callback'] ) {
85
- continue;
86
- }
87
- list( $action, $callback, $priority ) = array_values( $item );
88
- add_action( 'learn_press_request_handler_' . $action, $callback, $priority );
89
- }
90
- } else {
91
- add_action( 'learn_press_request_handler_' . $action, $function, $priority );
92
- }
93
  }
94
 
95
  public static function register_ajax( $action, $function, $priority = 5 ) {
28
  * Constructor
29
  */
30
  public static function init() {
 
 
 
 
 
31
 
32
+ //add_action( 'wp_loaded', array( __CLASS__, 'get_header' ), - 1000 );
33
+ //add_action( 'wp_head', array( __CLASS__, 'process_request' ), 1000 );
34
 
35
+ //add_action( 'wp_loaded', array( __CLASS__, 'get_header' ), - 1000 );
36
+ //add_action( 'admin_head', array( __CLASS__, 'process_request' ), 1000 );
37
+ add_action( 'wp', array( __CLASS__, 'process_request' ), 50 );
38
  LP_Request_Handler::register( 'purchase-course', 'learn_press_purchase_course_handler', 20 );
39
  LP_Request_Handler::register( 'enroll-course', 'learn_press_purchase_course_handler', 20 );
40
  }
41
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  public static function get_header() {
43
  ob_start();
44
  }
47
  * Process actions
48
  */
49
  public static function process_request() {
50
+ //self::$_head = ob_get_clean();
 
 
 
51
  if ( !empty( $_REQUEST ) ) foreach ( $_REQUEST as $key => $value ) {
52
  do_action( 'learn_press_request_handler_' . $key, $value, $_REQUEST );
53
  }
54
+ //echo self::$_head;
55
  }
56
 
57
  /**
58
  * Register new request
59
  *
60
+ * @param $action
61
+ * @param $function
62
+ * @param int $priority
63
  */
64
+ public static function register( $action, $function, $priority = 5 ) {
65
+ add_action( 'learn_press_request_handler_' . $action, $function, $priority );
 
 
 
 
 
 
 
 
 
 
 
66
  }
67
 
68
  public static function register_ajax( $action, $function, $priority = 5 ) {
inc/class-lp-schedules.php CHANGED
@@ -11,29 +11,14 @@ class LP_Schedules {
11
  */
12
  public function __construct() {
13
  if ( learn_press_get_request( 'action' ) == 'heartbeat' || !is_admin() ) {
14
- //$this->_update_user_course_expired();
15
  }
16
- add_filter( 'cron_schedules', array( $this, 'add_custom_cron_intervals' ), 10, 1 );
17
-
18
- if ( !wp_next_scheduled( 'learn_press_schedule_update_user_items' ) ) {
19
- wp_schedule_event( time(), 'ten_minutes', 'learn_press_schedule_update_user_items' );
20
- }
21
- add_action( 'learn_press_schedule_update_user_items', array( $this, 'schedule_update_user_items' ) );
22
-
23
  if ( !wp_next_scheduled( 'learn_press_delete_user_guest_transient' ) ) {
24
  wp_schedule_event( time(), 'daily', 'learn_press_delete_user_guest_transient' );
25
  }
26
  add_action( 'learn_press_delete_user_guest_transient', array( $this, 'delete_user_guest_transient' ) );
27
  }
28
 
29
- function add_custom_cron_intervals( $schedules ) {
30
- $schedules['ten_minutes'] = array(
31
- 'interval' => 600,
32
- 'display' => 'Once Every 10 Minutes'
33
- );
34
- return (array) $schedules;
35
- }
36
-
37
  public function delete_user_guest_transient() {
38
  global $wpdb;
39
  $time = time();
@@ -71,11 +56,6 @@ class LP_Schedules {
71
  }
72
  }
73
 
74
- public function schedule_update_user_items() {
75
- $this->_update_user_course_expired();
76
- LP_Debug::instance()->add( __FUNCTION__ );
77
- }
78
-
79
  /**
80
  * Auto finished course when time is expired for users
81
  */
@@ -87,43 +67,20 @@ class LP_Schedules {
87
  if ( empty( $wpdb->learnpress_user_items ) ) {
88
  return;
89
  }
90
- /* $query = $wpdb->prepare( "
91
- SELECT *
92
- FROM {$wpdb->prefix}learnpress_user_items
93
- WHERE user_item_id IN(
94
- SELECT user_item_id FROM(
95
- SELECT user_item_id
96
- FROM {$wpdb->prefix}learnpress_user_items
97
- WHERE end_time = %s
98
- AND item_type = %s
99
- GROUP BY item_id
100
- ORDER BY user_item_id DESC
101
- ) AS X
102
- )
103
- LIMIT 0, 10
104
- ", '0000-00-00 00:00:00', 'lp_course' );*/
105
-
106
  $query = $wpdb->prepare( "
107
  SELECT *
108
  FROM {$wpdb->prefix}learnpress_user_items
109
- WHERE user_item_id IN(
110
- SELECT max(user_item_id)
111
- FROM {$wpdb->prefix}learnpress_user_items
112
- WHERE end_time = %s
113
- AND item_type = %s
114
- AND status <> %s
115
- GROUP BY item_id, user_id
116
- )
117
  LIMIT 0, 10
118
- ", '0000-00-00 00:00:00', 'lp_course', 'finished' );
119
-
120
  if ( $results = $wpdb->get_results( $query ) ) {
121
  $ids = array();
122
  foreach ( $results as $row ) {
123
  $ids[] = $row->item_id;
124
  }
125
  _learn_press_get_courses_curriculum( $ids );
126
- _learn_press_count_users_enrolled_courses( $ids );
127
  foreach ( $results as $row ) {
128
  $course = learn_press_get_course( $row->item_id );
129
  if ( !$course ) continue;
11
  */
12
  public function __construct() {
13
  if ( learn_press_get_request( 'action' ) == 'heartbeat' || !is_admin() ) {
14
+ $this->_update_user_course_expired();
15
  }
 
 
 
 
 
 
 
16
  if ( !wp_next_scheduled( 'learn_press_delete_user_guest_transient' ) ) {
17
  wp_schedule_event( time(), 'daily', 'learn_press_delete_user_guest_transient' );
18
  }
19
  add_action( 'learn_press_delete_user_guest_transient', array( $this, 'delete_user_guest_transient' ) );
20
  }
21
 
 
 
 
 
 
 
 
 
22
  public function delete_user_guest_transient() {
23
  global $wpdb;
24
  $time = time();
56
  }
57
  }
58
 
 
 
 
 
 
59
  /**
60
  * Auto finished course when time is expired for users
61
  */
67
  if ( empty( $wpdb->learnpress_user_items ) ) {
68
  return;
69
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  $query = $wpdb->prepare( "
71
  SELECT *
72
  FROM {$wpdb->prefix}learnpress_user_items
73
+ WHERE end_time = %s
74
+ AND item_type = %s
 
 
 
 
 
 
75
  LIMIT 0, 10
76
+ ", '0000-00-00 00:00:00', 'lp_course' );
 
77
  if ( $results = $wpdb->get_results( $query ) ) {
78
  $ids = array();
79
  foreach ( $results as $row ) {
80
  $ids[] = $row->item_id;
81
  }
82
  _learn_press_get_courses_curriculum( $ids );
83
+ _learn_press_get_users_enrolled_courses( $ids );
84
  foreach ( $results as $row ) {
85
  $course = learn_press_get_course( $row->item_id );
86
  if ( !$course ) continue;
inc/class-lp-settings.php CHANGED
@@ -40,12 +40,6 @@ class LP_Settings {
40
  wp_cache_add( $option->option_name, $this->_options[$option->option_name], 'options' );
41
  }
42
  }
43
- foreach ( array( 'learn_press_permalink_structure', 'learn_press_install' ) as $option ) {
44
- if ( empty( $this->_options[$option] ) ) {
45
- $this->_options[$option] = '';
46
- wp_cache_add( $option, '', 'options' );
47
- }
48
- }
49
  }
50
 
51
  /**
@@ -96,7 +90,7 @@ class LP_Settings {
96
  if ( strpos( $var, 'learn_press_' ) === false ) {
97
  $var = 'learn_press_' . $var;
98
  }
99
- $segs = explode( '.', $var );
100
  $return = $this->_get_option( $this->_options, $var, $default );
101
  if ( $return == '' || is_null( $return ) ) {
102
  $return = $default;
40
  wp_cache_add( $option->option_name, $this->_options[$option->option_name], 'options' );
41
  }
42
  }
 
 
 
 
 
 
43
  }
44
 
45
  /**
90
  if ( strpos( $var, 'learn_press_' ) === false ) {
91
  $var = 'learn_press_' . $var;
92
  }
93
+ $segs = explode( '.', $var );
94
  $return = $this->_get_option( $this->_options, $var, $default );
95
  if ( $return == '' || is_null( $return ) ) {
96
  $return = $default;
inc/class-lp-shortcodes.php CHANGED
@@ -5,7 +5,7 @@
5
  * @version 1.0
6
  */
7
 
8
- if ( ! defined( 'ABSPATH' ) ) {
9
  exit;
10
  }
11
 
@@ -16,16 +16,13 @@ class LP_Shortcodes {
16
  /**
17
  * Init shortcodes
18
  */
19
- public static function init () {
20
  $shortcodes = array(
21
  'learn_press_confirm_order' => __CLASS__ . '::confirm_order',
22
  'learn_press_profile' => __CLASS__ . '::profile',
23
  'learn_press_become_teacher_form' => __CLASS__ . '::become_teacher_form',
24
  'learn_press_login_form' => __CLASS__ . '::login_form',
25
  'learn_press_checkout' => __CLASS__ . '::checkout',
26
- 'learn_press_recent_courses' => __CLASS__ . '::recent_courses',
27
- 'learn_press_featured_courses' => __CLASS__ . '::featured_courses',
28
- 'learn_press_popular_courses' => __CLASS__ . '::popular_courses'
29
  );
30
 
31
  foreach ( $shortcodes as $shortcode => $function ) {
@@ -33,31 +30,30 @@ class LP_Shortcodes {
33
  }
34
 
35
  add_action( 'template_redirect', array( __CLASS__, 'auto_shortcode' ) );
36
-
37
  }
38
 
39
- public static function auto_shortcode ( $template ) {
40
  if ( is_page() ) {
41
  global $post, $wp_query, $wp;
42
- $page_id = ! empty( $wp_query->queried_object_id ) ?
43
  $wp_query->queried_object_id :
44
- ( ! empty( $wp_query->query_vars['page_id'] ) ? $wp_query->query_vars['page_id'] : - 1 );
45
  if ( $page_id == learn_press_get_page_id( 'checkout' ) ) {
46
- if ( ! preg_match( '/\[learn_press_checkout\s?(.*)\]/', $post->post_content ) ) {
47
  $post->post_content .= '[learn_press_checkout]';
48
  }
49
  } elseif ( $page_id == learn_press_get_page_id( 'profile' ) ) {
50
  if ( empty( $wp->query_vars['user'] ) ) {
51
  $current_user = wp_get_current_user();
52
- if ( ! empty( $current_user->user_login ) ) {
53
  $redirect = learn_press_get_endpoint_url( '', $current_user->user_login, learn_press_get_page_link( 'profile' ) );
54
- if ( $redirect && ! learn_press_is_current_url( $redirect ) ) {
55
  wp_redirect( $redirect );
56
  die();
57
  }
58
  } else {
59
- if ( ! preg_match( '/\[learn_press_login_form\s?(.*)\]/', $post->post_content ) ) {
60
- if ( ! empty( $_REQUEST['redirect_to'] ) ) {
61
  $redirect = $_REQUEST['redirect_to'];
62
  } else {
63
  $redirect = '';
@@ -70,58 +66,57 @@ class LP_Shortcodes {
70
  parse_str( $wp->matched_query, $query );
71
  if ( empty( $query['view'] ) ) {
72
  $redirect = learn_press_user_profile_link( $wp->query_vars['user'] );
73
- if ( ! empty( $redirect ) ) {
 
74
  wp_redirect( $redirect );
75
  die();
76
  }
77
 
78
  }
79
  if ( $query ) {
80
- $profile_endpoints = (array)LP()->settings->get( 'profile_endpoints' );
81
  $endpoints = array_keys( $profile_endpoints );
82
  foreach ( $query as $k => $v ) {
83
  if ( ( $k == 'view' ) ) {
84
- if ( ! $v ) {
85
  $v = reset( $profile_endpoints );
86
  }
87
- if ( ! in_array( $v, apply_filters( 'learn_press_profile_tab_endpoints', $profile_endpoints ) ) ) {
88
  learn_press_is_404();
89
  }
90
  }
91
- if ( ! empty( $v ) ) {
92
- $wp->query_vars[ $k ] = $v;
93
  }
94
  }
95
  }
96
- if ( ! preg_match( '/\[learn_press_profile\s?(.*)\]/', $post->post_content ) ) {
97
  $post->post_content .= '[learn_press_profile]';
98
  }
99
 
100
  }
101
 
102
  } elseif ( $page_id == learn_press_get_page_id( 'become_a_teacher' ) ) {
103
- if ( ! preg_match( '/\[learn_press_become_teacher_form\s?(.*)\]/', $post->post_content ) ) {
104
  $post->post_content .= '[learn_press_become_teacher_form]';
105
  }
106
  }
107
 
108
  do_action( 'learn_press_auto_shortcode', $post, $template );
109
  }
110
-
111
  return $template;
112
  }
113
 
114
- public static function _login_form_bottom ( $content, $args ) {
115
- if ( ! ( ! empty( $args['context'] ) && $args['context'] == 'learn-press-login' ) ) {
116
  return;
117
  }
118
  }
119
 
120
- public static function wrapper_shortcode ( $content ) {
121
  ob_start();
122
  learn_press_print_messages();
123
  $html = ob_get_clean();
124
-
125
  return '<div class="learnpress">' . $html . $content . '</div>';
126
  }
127
 
@@ -132,7 +127,7 @@ class LP_Shortcodes {
132
  *
133
  * @return string
134
  */
135
- public static function checkout ( $atts ) {
136
  global $wp;
137
  ob_start();
138
 
@@ -149,202 +144,10 @@ class LP_Shortcodes {
149
  learn_press_get_template( 'checkout/form.php', array( 'checkout' => LP()->checkout() ) );
150
  }
151
  }
152
-
153
  return self::wrapper_shortcode( ob_get_clean() );
154
  }
155
 
156
- public static function recent_courses ( $atts ) {
157
-
158
- $limit = $order_by = $order = '';
159
-
160
- $atts = shortcode_atts( array(
161
- 'limit' => 10,
162
- 'order_by' => 'date', // select one of [date, title, status, comment_count]
163
- 'order' => 'DESC' // select on of [DESC, ASC]
164
- ), $atts );
165
-
166
- extract( $atts );
167
-
168
- // Validation date
169
- $arr_orders_by = array('post_date', 'post_title', 'post_status', 'comment_count');
170
- $arr_orders = array('DESC', 'ASC');
171
- $order = strtoupper($order);
172
-
173
- if ( !in_array($order_by, $arr_orders_by) || !in_array('post_'.$order_by, $arr_orders_by)) {
174
- $order_by = 'post_date';
175
- }
176
- else {
177
- if ($order_by !== 'comment_count') {
178
- $order_by = 'post_' .$order_by;
179
- }
180
- }
181
-
182
- if (!in_array($order, $arr_orders)) {
183
- $order = 'DESC';
184
- }
185
- if (!absint($limit)) {
186
- $limit = 10;
187
- }
188
-
189
- global $wpdb;
190
-
191
- $posts = $wpdb->get_results(
192
- $wpdb->prepare(
193
- "SELECT DISTINCT p.*
194
- FROM $wpdb->posts AS p
195
- WHERE p.post_type = %s
196
- AND p.post_status = %s
197
- ORDER BY p.{$order_by} {$order}
198
- LIMIT %d
199
- ",
200
- LP_COURSE_CPT,
201
- 'publish',
202
- (int) absint( $limit )
203
- )
204
- );
205
-
206
- ob_start();
207
-
208
- self::render_shortcode_archive( $posts );
209
-
210
- return self::wrapper_shortcode( ob_get_clean() );
211
-
212
- }
213
-
214
- public static function featured_courses ( $atts ) {
215
-
216
- $limit = $order_by = $order = '';
217
-
218
- $atts = shortcode_atts( array(
219
- 'limit' => 10,
220
- 'order_by' => 'date', // select one of [date, title, status, comment_count]
221
- 'order' => 'DESC' // select on of [DESC, ASC]
222
- ), $atts );
223
-
224
- extract( $atts );
225
-
226
- // Validation date
227
- $arr_orders_by = array('post_date', 'post_title', 'post_status', 'comment_count');
228
- $arr_orders = array('DESC', 'ASC');
229
- $order = strtoupper($order);
230
-
231
- if ( !in_array($order_by, $arr_orders_by) || !in_array('post_'.$order_by, $arr_orders_by)) {
232
- $order_by = 'post_date';
233
- }
234
- else {
235
- if ($order_by !== 'comment_count') {
236
- $order_by = 'post_' .$order_by;
237
- }
238
- }
239
-
240
- if (!in_array($order, $arr_orders)) {
241
- $order = 'DESC';
242
- }
243
- if (!absint($limit)) {
244
- $limit = 10;
245
- }
246
-
247
- global $wpdb;
248
-
249
- $posts = $wpdb->get_results(
250
- $wpdb->prepare( "
251
- SELECT DISTINCT *
252
- FROM {$wpdb->posts} p
253
- LEFT JOIN {$wpdb->postmeta} as pmeta ON p.ID=pmeta.post_id AND pmeta.meta_key = %s
254
- WHERE p.post_type = %s
255
- AND p.post_status = %s
256
- AND meta_value = %s
257
- ORDER BY p.{$order_by} {$order}
258
- LIMIT %d
259
- ", '_lp_featured', LP_COURSE_CPT, 'publish', 'yes', absint($limit)
260
- )
261
- );
262
-
263
- ob_start();
264
-
265
- self::render_shortcode_archive( $posts );
266
-
267
- return self::wrapper_shortcode( ob_get_clean() );
268
-
269
- }
270
-
271
- public static function popular_courses ( $atts ) {
272
-
273
- $limit = $order_by = $order = '';
274
-
275
- $atts = shortcode_atts( array(
276
- 'limit' => 10,
277
- 'order' => 'DESC' // select on of [DESC, ASC]
278
- ), $atts );
279
-
280
- extract( $atts );
281
-
282
- // Validation date
283
- $arr_orders = array('DESC', 'ASC');
284
- $order = strtoupper($order);
285
-
286
- if (!in_array($order, $arr_orders)) {
287
- $order = 'DESC';
288
- }
289
- if (!absint($limit)) {
290
- $limit = 10;
291
- }
292
-
293
- global $wpdb;
294
-
295
- $query = $wpdb->prepare(
296
- "SELECT po.*, count(*) as number_enrolled
297
- FROM {$wpdb->prefix}learnpress_user_items ui
298
- INNER JOIN {$wpdb->posts} po ON po.ID = ui.item_id
299
- WHERE ui.item_type = %s
300
- AND ( ui.status = %s OR ui.status = %s )
301
- AND po.post_status = %s
302
- GROUP BY ui.item_id
303
- ORDER BY ui.item_id {$order}
304
- LIMIT %d
305
- ",
306
- LP_COURSE_CPT,
307
- 'enrolled',
308
- 'finished',
309
- 'publish',
310
- absint($limit)
311
- );
312
-
313
- $posts = $wpdb->get_results(
314
- $query
315
- );
316
-
317
- ob_start();
318
-
319
- self::render_shortcode_archive( $posts );
320
-
321
- return self::wrapper_shortcode( ob_get_clean() );
322
-
323
- }
324
-
325
- public static function render_shortcode_archive ( $lp_posts = array() ) {
326
- global $post;
327
- if ( !empty( $lp_posts ) ) {
328
- do_action( 'learn_press_before_courses_loop' );
329
-
330
- learn_press_begin_courses_loop();
331
-
332
- foreach ( $lp_posts as $post ) {
333
- setup_postdata($post);
334
- learn_press_get_template_part( 'content', 'course' );
335
- }
336
-
337
- learn_press_end_courses_loop();
338
- }
339
- else {
340
- learn_press_display_message( __( 'No course found.', 'learnpress' ), 'error' );
341
-
342
- }
343
-
344
- wp_reset_postdata();
345
- }
346
-
347
- private static function order_received ( $order_id = 0 ) {
348
 
349
  learn_press_print_notices();
350
 
@@ -352,15 +155,13 @@ class LP_Shortcodes {
352
 
353
  // Get the order
354
  $order_id = absint( $order_id );
355
- $order_key = ! empty( $_GET['key'] ) ? $_GET['key'] : '';
356
 
357
  if ( $order_id > 0 && ( $order = learn_press_get_order( $order_id ) ) && $order->post->post_status != 'trash' ) {
358
- if ( $order->order_key != $order_key ) {
359
  unset( $order );
360
- }
361
  } else {
362
  learn_press_display_message( __( 'Invalid order!', 'learnpress' ), 'error' );
363
-
364
  return;
365
  }
366
 
@@ -376,10 +177,10 @@ class LP_Shortcodes {
376
  *
377
  * @return string
378
  */
379
- public static function confirm_order ( $atts = null ) {
380
  $atts = shortcode_atts(
381
  array(
382
- 'order_id' => ! empty( $_REQUEST['order_id'] ) ? intval( $_REQUEST['order_id'] ) : 0
383
  ),
384
  $atts
385
  );
@@ -405,12 +206,12 @@ class LP_Shortcodes {
405
  *
406
  * @return string
407
  */
408
- public static function become_teacher_form ( $atts ) {
409
  $user = learn_press_get_current_user();
410
  $message = '';
411
  $code = 0;
412
 
413
- if ( ! is_user_logged_in() ) {
414
  $message = __( "Please login to fill in this form.", 'learnpress' );
415
  $code = 1;
416
  } elseif ( in_array( LP_TEACHER_ROLE, $user->user->roles ) ) {
@@ -424,7 +225,7 @@ class LP_Shortcodes {
424
  $code = 4;
425
  }
426
 
427
- if ( ! apply_filters( 'learn_press_become_a_teacher_display_form', true, $code, $message ) ) {
428
  return;
429
  }
430
 
@@ -439,7 +240,26 @@ class LP_Shortcodes {
439
  ),
440
  $atts
441
  );
442
- $fields = learn_press_get_become_a_teacher_form_fields();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
443
  ob_start();
444
  $args = array_merge(
445
  array(
@@ -449,7 +269,6 @@ class LP_Shortcodes {
449
  ),
450
  $atts
451
  );
452
-
453
  learn_press_get_template( 'global/become-teacher-form.php', $args );
454
 
455
  $html = ob_get_clean();
@@ -459,7 +278,7 @@ class LP_Shortcodes {
459
  return self::wrapper_shortcode( $html );
460
  }
461
 
462
- public static function profile () {
463
  global $wp_query, $wp;
464
  if ( isset( $wp_query->query['user'] ) ) {
465
  $user = get_user_by( 'login', urldecode( $wp_query->query['user'] ) );
@@ -469,7 +288,7 @@ class LP_Shortcodes {
469
  $output = '';
470
 
471
  ob_start();
472
- if ( ! $user ) {
473
  if ( empty( $wp_query->query['user'] ) ) {
474
 
475
  } else {
@@ -479,22 +298,22 @@ class LP_Shortcodes {
479
  } else {
480
  $user = LP_User_Factory::get_user( $user->ID );
481
  $tabs = learn_press_user_profile_tabs( $user );
482
- if ( ! empty( $wp->query_vars['view'] ) ) {
483
  $current = $wp->query_vars['view'];
484
  } else {
485
  $current = '';
486
  }
487
- if ( empty( $tabs[ $current ] ) && empty( $wp->query_vars['view'] ) ) {
488
  $tab_keys = array_keys( $tabs );
489
  $current = reset( $tab_keys );
490
  }
491
  $_REQUEST['tab'] = $current;
492
  $_POST['tab'] = $current;
493
  $_GET['tab'] = $current;
494
- if ( ! learn_press_current_user_can_view_profile_section( $current, $user ) ) {
495
  learn_press_get_template( 'profile/private-area.php' );
496
  } else {
497
- if ( ! empty( $tabs ) && ! empty( $tabs[ $current ] ) ) :
498
  learn_press_get_template( 'profile/index.php',
499
  array(
500
  'user' => $user,
@@ -505,11 +324,11 @@ class LP_Shortcodes {
505
  else:
506
  if ( $wp->query_vars['view'] == LP()->settings->get( 'profile_endpoints.profile-order-details' ) ) {
507
  $order_id = 0;
508
- if ( ! empty( $wp->query_vars['id'] ) ) {
509
  $order_id = $wp->query_vars['id'];
510
  }
511
  $order = learn_press_get_order( $order_id );
512
- if ( ! $order ) {
513
  learn_press_display_message( __( 'Invalid order!', 'learnpress' ), 'error' );
514
  } else {
515
  learn_press_get_template( 'profile/order-details.php',
@@ -528,7 +347,7 @@ class LP_Shortcodes {
528
  return self::wrapper_shortcode( $output );
529
  }
530
 
531
- static function login_form ( $atts, $content = '' ) {
532
  $atts = shortcode_atts(
533
  array(
534
  'redirect' => ''
@@ -536,14 +355,11 @@ class LP_Shortcodes {
536
  $atts
537
  );
538
  add_filter( 'login_form_bottom', array( __CLASS__, 'login_form_bottom' ), 10, 2 );
539
-
540
  return self::wrapper_shortcode( learn_press_get_template_content( 'profile/login-form.php', $atts ) );
541
  }
542
 
543
  public
544
- static function login_form_bottom (
545
- $html, $args
546
- ) {
547
  ob_start();
548
  ?>
549
  <p>
@@ -552,9 +368,8 @@ class LP_Shortcodes {
552
  <a href="<?php echo wp_registration_url(); ?>"><?php _e( 'Create new account', 'learnpress' ); ?></a>
553
  </p>
554
  <?php $html .= ob_get_clean();
555
-
556
  return $html;
557
  }
558
  }
559
 
560
- LP_Shortcodes::init();
5
  * @version 1.0
6
  */
7
 
8
+ if ( !defined( 'ABSPATH' ) ) {
9
  exit;
10
  }
11
 
16
  /**
17
  * Init shortcodes
18
  */
19
+ public static function init() {
20
  $shortcodes = array(
21
  'learn_press_confirm_order' => __CLASS__ . '::confirm_order',
22
  'learn_press_profile' => __CLASS__ . '::profile',
23
  'learn_press_become_teacher_form' => __CLASS__ . '::become_teacher_form',
24
  'learn_press_login_form' => __CLASS__ . '::login_form',
25
  'learn_press_checkout' => __CLASS__ . '::checkout',
 
 
 
26
  );
27
 
28
  foreach ( $shortcodes as $shortcode => $function ) {
30
  }
31
 
32
  add_action( 'template_redirect', array( __CLASS__, 'auto_shortcode' ) );
 
33
  }
34
 
35
+ public static function auto_shortcode( $template ) {
36
  if ( is_page() ) {
37
  global $post, $wp_query, $wp;
38
+ $page_id = !empty( $wp_query->queried_object_id ) ?
39
  $wp_query->queried_object_id :
40
+ ( !empty( $wp_query->query_vars['page_id'] ) ? $wp_query->query_vars['page_id'] : - 1 );
41
  if ( $page_id == learn_press_get_page_id( 'checkout' ) ) {
42
+ if ( !preg_match( '/\[learn_press_checkout\s?(.*)\]/', $post->post_content ) ) {
43
  $post->post_content .= '[learn_press_checkout]';
44
  }
45
  } elseif ( $page_id == learn_press_get_page_id( 'profile' ) ) {
46
  if ( empty( $wp->query_vars['user'] ) ) {
47
  $current_user = wp_get_current_user();
48
+ if ( !empty( $current_user->user_login ) ) {
49
  $redirect = learn_press_get_endpoint_url( '', $current_user->user_login, learn_press_get_page_link( 'profile' ) );
50
+ if ( $redirect && !learn_press_is_current_url( $redirect ) ) {
51
  wp_redirect( $redirect );
52
  die();
53
  }
54
  } else {
55
+ if ( !preg_match( '/\[learn_press_login_form\s?(.*)\]/', $post->post_content ) ) {
56
+ if ( !empty( $_REQUEST['redirect_to'] ) ) {
57
  $redirect = $_REQUEST['redirect_to'];
58
  } else {
59
  $redirect = '';
66
  parse_str( $wp->matched_query, $query );
67
  if ( empty( $query['view'] ) ) {
68
  $redirect = learn_press_user_profile_link( $wp->query_vars['user'] );
69
+
70
+ if ( !empty( $redirect ) ) {
71
  wp_redirect( $redirect );
72
  die();
73
  }
74
 
75
  }
76
  if ( $query ) {
77
+ $profile_endpoints = (array) LP()->settings->get( 'profile_endpoints' );
78
  $endpoints = array_keys( $profile_endpoints );
79
  foreach ( $query as $k => $v ) {
80
  if ( ( $k == 'view' ) ) {
81
+ if ( !$v ) {
82
  $v = reset( $profile_endpoints );
83
  }
84
+ if ( !in_array( $v, apply_filters( 'learn_press_profile_tab_endpoints', $profile_endpoints ) ) ) {
85
  learn_press_is_404();
86
  }
87
  }
88
+ if ( !empty( $v ) ) {
89
+ $wp->query_vars[$k] = $v;
90
  }
91
  }
92
  }
93
+ if ( !preg_match( '/\[learn_press_profile\s?(.*)\]/', $post->post_content ) ) {
94
  $post->post_content .= '[learn_press_profile]';
95
  }
96
 
97
  }
98
 
99
  } elseif ( $page_id == learn_press_get_page_id( 'become_a_teacher' ) ) {
100
+ if ( !preg_match( '/\[learn_press_become_teacher_form\s?(.*)\]/', $post->post_content ) ) {
101
  $post->post_content .= '[learn_press_become_teacher_form]';
102
  }
103
  }
104
 
105
  do_action( 'learn_press_auto_shortcode', $post, $template );
106
  }
 
107
  return $template;
108
  }
109
 
110
+ public static function _login_form_bottom( $content, $args ) {
111
+ if ( !( !empty( $args['context'] ) && $args['context'] == 'learn-press-login' ) ) {
112
  return;
113
  }
114
  }
115
 
116
+ public static function wrapper_shortcode( $content ) {
117
  ob_start();
118
  learn_press_print_messages();
119
  $html = ob_get_clean();
 
120
  return '<div class="learnpress">' . $html . $content . '</div>';
121
  }
122
 
127
  *
128
  * @return string
129
  */
130
+ public static function checkout( $atts ) {
131
  global $wp;
132
  ob_start();
133
 
144
  learn_press_get_template( 'checkout/form.php', array( 'checkout' => LP()->checkout() ) );
145
  }
146
  }
 
147
  return self::wrapper_shortcode( ob_get_clean() );
148
  }
149
 
150
+ private static function order_received( $order_id = 0 ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
 
152
  learn_press_print_notices();
153
 
155
 
156
  // Get the order
157
  $order_id = absint( $order_id );
158
+ $order_key = !empty( $_GET['key'] ) ? $_GET['key'] : '';
159
 
160
  if ( $order_id > 0 && ( $order = learn_press_get_order( $order_id ) ) && $order->post->post_status != 'trash' ) {
161
+ if ( $order->order_key != $order_key )
162
  unset( $order );
 
163
  } else {
164
  learn_press_display_message( __( 'Invalid order!', 'learnpress' ), 'error' );
 
165
  return;
166
  }
167
 
177
  *
178
  * @return string
179
  */
180
+ public static function confirm_order( $atts = null ) {
181
  $atts = shortcode_atts(
182
  array(
183
+ 'order_id' => !empty( $_REQUEST['order_id'] ) ? intval( $_REQUEST['order_id'] ) : 0
184
  ),
185
  $atts
186
  );
206
  *
207
  * @return string
208
  */
209
+ public static function become_teacher_form( $atts ) {
210
  $user = learn_press_get_current_user();
211
  $message = '';
212
  $code = 0;
213
 
214
+ if ( !is_user_logged_in() ) {
215
  $message = __( "Please login to fill in this form.", 'learnpress' );
216
  $code = 1;
217
  } elseif ( in_array( LP_TEACHER_ROLE, $user->user->roles ) ) {
225
  $code = 4;
226
  }
227
 
228
+ if ( !apply_filters( 'learn_press_become_a_teacher_display_form', true, $code, $message ) ) {
229
  return;
230
  }
231
 
240
  ),
241
  $atts
242
  );
243
+ $fields = array(
244
+ 'bat_name' => array(
245
+ 'title' => __( 'Name', 'learnpress' ),
246
+ 'type' => 'text',
247
+ 'placeholder' => __( 'Your name', 'learnpress' ),
248
+ 'def' => $user->display_name
249
+ ),
250
+ 'bat_email' => array(
251
+ 'title' => __( 'Email', 'learnpress' ),
252
+ 'type' => 'email',
253
+ 'placeholder' => __( 'Your email address', 'learnpress' ),
254
+ 'def' => $user->user_email
255
+ ),
256
+ 'bat_phone' => array(
257
+ 'title' => __( 'Phone', 'learnpress' ),
258
+ 'type' => 'text',
259
+ 'placeholder' => __( 'Your phone number', 'learnpress' )
260
+ )
261
+ );
262
+ $fields = apply_filters( 'learn_press_become_teacher_form_fields', $fields );
263
  ob_start();
264
  $args = array_merge(
265
  array(
269
  ),
270
  $atts
271
  );
 
272
  learn_press_get_template( 'global/become-teacher-form.php', $args );
273
 
274
  $html = ob_get_clean();
278
  return self::wrapper_shortcode( $html );
279
  }
280
 
281
+ public static function profile() {
282
  global $wp_query, $wp;
283
  if ( isset( $wp_query->query['user'] ) ) {
284
  $user = get_user_by( 'login', urldecode( $wp_query->query['user'] ) );
288
  $output = '';
289
 
290
  ob_start();
291
+ if ( !$user ) {
292
  if ( empty( $wp_query->query['user'] ) ) {
293
 
294
  } else {
298
  } else {
299
  $user = LP_User_Factory::get_user( $user->ID );
300
  $tabs = learn_press_user_profile_tabs( $user );
301
+ if ( !empty( $wp->query_vars['view'] ) ) {
302
  $current = $wp->query_vars['view'];
303
  } else {
304
  $current = '';
305
  }
306
+ if ( empty( $tabs[$current] ) && empty( $wp->query_vars['view'] ) ) {
307
  $tab_keys = array_keys( $tabs );
308
  $current = reset( $tab_keys );
309
  }
310
  $_REQUEST['tab'] = $current;
311
  $_POST['tab'] = $current;
312
  $_GET['tab'] = $current;
313
+ if ( !learn_press_current_user_can_view_profile_section( $current, $user ) ) {
314
  learn_press_get_template( 'profile/private-area.php' );
315
  } else {
316
+ if ( !empty( $tabs ) && !empty( $tabs[$current] ) ) :
317
  learn_press_get_template( 'profile/index.php',
318
  array(
319
  'user' => $user,
324
  else:
325
  if ( $wp->query_vars['view'] == LP()->settings->get( 'profile_endpoints.profile-order-details' ) ) {
326
  $order_id = 0;
327
+ if ( !empty( $wp->query_vars['id'] ) ) {
328
  $order_id = $wp->query_vars['id'];
329
  }
330
  $order = learn_press_get_order( $order_id );
331
+ if ( !$order ) {
332
  learn_press_display_message( __( 'Invalid order!', 'learnpress' ), 'error' );
333
  } else {
334
  learn_press_get_template( 'profile/order-details.php',
347
  return self::wrapper_shortcode( $output );
348
  }
349
 
350
+ static function login_form( $atts, $content = '' ) {
351
  $atts = shortcode_atts(
352
  array(
353
  'redirect' => ''
355
  $atts
356
  );
357
  add_filter( 'login_form_bottom', array( __CLASS__, 'login_form_bottom' ), 10, 2 );
 
358
  return self::wrapper_shortcode( learn_press_get_template_content( 'profile/login-form.php', $atts ) );
359
  }
360
 
361
  public
362
+ static function login_form_bottom( $html, $args ) {
 
 
363
  ob_start();
364
  ?>
365
  <p>
368
  <a href="<?php echo wp_registration_url(); ?>"><?php _e( 'Create new account', 'learnpress' ); ?></a>
369
  </p>
370
  <?php $html .= ob_get_clean();
 
371
  return $html;
372
  }
373
  }
374
 
375
+ LP_Shortcodes::init();
inc/class-lp-widget.php DELETED
@@ -1,395 +0,0 @@
1
- <?php
2
- /**
3
- * Define base class of LearnPress widgets and helper functions
4
- */
5
-
6
- if ( !class_exists( 'LP_Widget' ) ) {
7
- /**
8
- * Class LP_Widget
9
- *
10
- * @extend WP_Widget
11
- */
12
- class LP_Widget extends WP_Widget {
13
-
14
- /**
15
- * @var array
16
- */
17
- private static $_widgets = array();
18
-
19
- /**
20
- * @var bool
21
- */
22
- private static $_has_widget = false;
23
-
24
- /**
25
- * @var bool
26
- */
27
- private static $_has_registered = false;
28
-
29
- /**
30
- * Widget prefix
31
- *
32
- * @var string
33
- */
34
- private $_id_prefix = 'lp-widget-';
35
-
36
- /**
37
- * Widget name prefix
38
- *
39
- * @var string
40
- */
41
- private $_name_prefix = 'LearnPress - ';
42
-
43
- /**
44
- * @var array
45
- */
46
- private $map_fields = array();
47
-
48
- /**
49
- * Widget file name
50
- *
51
- * @var string
52
- */
53
- public $file = '';
54
-
55
- /**
56
- * Widget template path
57
- *
58
- * @var string
59
- */
60
- public $template_path = '';
61
-
62
- /**
63
- * Widget arguments
64
- *
65
- * @var array
66
- */
67
- public $args = array();
68
-
69
- /**
70
- * Widget options
71
- *
72
- * @var array
73
- */
74
- public $instance = array();
75
-
76
- /**
77
- *
78
- * @var array
79
- */
80
- private $defaults = array();
81
-
82
- /**
83
- * @var bool
84
- */
85
- public $options = array();
86
-
87
- /**
88
- * LP_Widget constructor.
89
- *
90
- * @param array
91
- */
92
- public function __construct( $args = array() ) {
93
- $defaults = array( 'id_base' => '', 'name' => '', 'widget_options' => '', 'control_options' => '' );
94
- $args = wp_parse_args( $args, $defaults );
95
- $args = $this->_parse_widget_args(
96
- $args,
97
- strtolower( str_replace( array( 'LP_Widget_', '_' ), array( '', '-' ), get_class( $this ) ) )
98
- );
99
- list( $id_base, $name, $widget_options, $control_options ) = $args;
100
-
101
- if ( $this->options ) {
102
- foreach ( $this->options as $id => $field ) {
103
- if ( is_array( $field ) && array_key_exists( 'std', $field ) ) {
104
- $this->defaults[$id] = $field['std'];
105
- } else {
106
- $this->defaults[$id] = null;
107
- }
108
- }
109
- }
110
- parent::__construct( $id_base, $this->_name_prefix . $name, $widget_options, $control_options );
111
- }
112
-
113
- public function before_checkbox_html( $begin, $field, $meta ) {
114
- $begin .= sprintf(
115
- '<input type="hidden" name="%s" value="0">',
116
- $field['field_name']
117
- );
118
- return $begin;
119
- }
120
-
121
- public function field_data( $data, $object_id, $meta_key, $single ) {
122
- global $post;
123
- if ( $post->post_type == 'lp-post-widget' ) {
124
- $key = !empty( $this->map_fields[$meta_key] ) ? $this->map_fields[$meta_key] : $meta_key;
125
- $data = array_key_exists( $key, $this->instance ) ? $this->instance[$key] : '';
126
- }
127
-
128
- return $data;
129
- }
130
-
131
- public function update( $new_instance = array(), $old_instance = array() ) {
132
- $new_instance = $this->sanitize_instance( $new_instance );
133
- return $new_instance;
134
- }
135
-
136
- /**
137
- * Display widget content
138
- *
139
- * @param array $args
140
- * @param array $instance
141
- */
142
- public function widget( $args, $instance ) {
143
- $this->args = $args;
144
- $this->instance = $this->sanitize_instance( $instance );
145
-
146
- if ( !apply_filters( 'learn_press_widget_display_content', true, $this ) ) {
147
- return;
148
- }
149
-
150
- if ( !apply_filters( 'learn_press_widget_display_content-' . $this->id_base, true, $this ) ) {
151
- return;
152
- }
153
- $this->before_widget();
154
- $this->show();
155
- $this->after_widget();
156
- }
157
-
158
- public function before_widget() {
159
- echo $this->args['before_widget'];
160
- if ( !empty( $this->instance['title'] ) ) {
161
- echo $this->args['before_title'];
162
- echo $this->instance['title'];
163
- echo $this->args['after_title'];
164
- }
165
- }
166
-
167
- public function after_widget() {
168
- echo $this->args['after_widget'];
169
- }
170
-
171
- public function show() {
172
- printf( __( 'Function %s should be overwritten in child class', 'learnpress' ), __FUNCTION__ );
173
- }
174
-
175
- /**
176
- * Display widget settings with meta-box fields
177
- *
178
- * @param mixed $instance
179
- *
180
- * @return mixed
181
- */
182
- public function form( $instance ) {
183
- $this->instance = $this->sanitize_instance( $instance );
184
- if ( !$this->options ) {
185
- return;
186
- }
187
- global $post;
188
- add_filter( 'get_post_metadata', array( $this, 'field_data' ), 10, 4 );
189
- add_filter( 'rwmb_checkbox_begin_html', array( $this, 'before_checkbox_html' ), 10, 3 );
190
- //
191
-
192
- $post = (object) array( 'ID' => 1, 'post_type' => 'lp-post-widget' );
193
- setup_postdata( $post );
194
- if ( !class_exists( 'RW_Meta_Box' ) ) {
195
- require_once LP_PLUGIN_PATH . 'inc/libraries/meta-box/meta-box.php';
196
- }
197
-
198
- $this->options = RW_Meta_Box::normalize_fields( $this->options );
199
-
200
- $this->options = $this->normalize_options();
201
-
202
- foreach ( $this->options as $field ) {
203
- $origin_id = $field['id'];
204
- $field['field_name'] = $this->get_field_name( $field['id'] );
205
- $field['id'] = $this->get_field_id( $field['id'] );
206
- $field['value'] = md5( $field['std'] );
207
- //learn_press_debug( $field );
208
- $this->map_fields[$field['id']] = $origin_id;
209
- $this->_show_field( $field );
210
- }
211
- wp_reset_postdata();
212
- remove_filter( 'get_post_metadata', array( $this, 'field_data' ) );
213
- remove_filter( 'rwmb_checkbox_begin_html', array( $this, 'before_checkbox_html' ), 10, 3 );
214
- }
215
-
216
- /**
217
- * Find RMMB field and display it
218
- *
219
- * @param $field
220
- */
221
- private function _show_field( $field ) {
222
- $callable = array( 'RW_Meta_Box', 'get_class_name' );
223
- if ( !is_callable( $callable ) ) {
224
- $callable = array( 'RWMB_Field', 'get_class_name' );
225
- }
226
- if ( is_callable( $callable ) ) {
227
- $field_class = call_user_func( $callable, $field );
228
- } else {
229
- $field_class = false;
230
- }
231
- if ( $field_class ) {
232
- call_user_func( array( $field_class, 'show' ), $field, true );
233
- }
234
- }
235
-
236
- /**
237
- * @return array|bool
238
- */
239
- public function normalize_options() {
240
- return !is_array( $this->options ) ? array() : $this->options;
241
- }
242
-
243
- /**
244
- * Find template and display it
245
- */
246
- public function get_template() {
247
- learn_press_get_widget_template( $this->get_slug(), 'default.php' );
248
- }
249
-
250
- /**
251
- * Get path to template files inside widget
252
- *
253
- * @return string
254
- */
255
- public function get_template_path() {
256
- if ( file_exists( $this->file ) ) {
257
- $this->template_path = dirname( $this->file ) . '/tmpl/';
258
- }
259
-
260
- return $this->template_path;
261
- }
262
-
263
- /**
264
- * Get slug of this widget from file
265
- *
266
- * @return mixed
267
- */
268
- public function get_slug() {
269
- $class = get_class( $this );
270
-
271
- return str_replace( '_', '-', strtolower( str_replace( 'LP_Widget_', '', $class ) ) );
272
- }
273
-
274
- /**
275
- * Register new widget
276
- *
277
- * @param string|array
278
- * @param mixed
279
- */
280
- public static function register( $type, $args = '' ) {
281
- if ( is_array( $type ) ) {
282
- foreach ( $type as $k => $t ) {
283
- if ( is_array( $t ) ) {
284
- self::register( $k, $t );
285
- } else {
286
- self::register( $t );
287
- }
288
- }
289
- } else {
290
- self::$_widgets[$type] = $args;
291
- if ( !self::$_has_registered ) {
292
- add_action( 'widgets_init', array( __CLASS__, 'do_register' ) );
293
- self::$_has_registered = true;
294
- }
295
- }
296
- }
297
-
298
- /**
299
- * Tell WP register our widgets
300
- */
301
- public static function do_register() {
302
- if ( !self::$_widgets ) {
303
- return;
304
- }
305
- foreach ( self::$_widgets as $type => $args ) {
306
- $widget_file = LP_PLUGIN_PATH . "inc/widgets/{$type}/{$type}.php";
307
- if ( !file_exists( $widget_file ) ) {
308
- continue;
309
- }
310
- include_once $widget_file;
311
- $widget_class = self::get_widget_class( $type );
312
- if ( class_exists( $widget_class ) ) {
313
- $widget = new $widget_class();
314
- $widget->file = $widget_file;
315
- register_widget( $widget );
316
- }
317
- }
318
- }
319
-
320
- /**
321
- * Get class name of widget without LP_Widget prefix
322
- *
323
- * @param $slug
324
- *
325
- * @return string
326
- */
327
- private static function get_widget_class( $slug ) {
328
- return 'LP_Widget_' . preg_replace( '~\s+~', '_', ucwords( str_replace( '-', ' ', $slug ) ) );
329
- }
330
-
331
- /**
332
- * Parse some default options
333
- *
334
- * @param $args
335
- * @param $type
336
- *
337
- * @return array
338
- */
339
- private function _parse_widget_args( $args, $type ) {
340
- $id_base = !empty( $args['id_base'] ) ? $args['id_base'] : $this->_id_prefix . $type;
341
- $name = !empty( $args['name'] ) ? $args['name'] : ucwords( str_replace( '-', ' ', $type ) );
342
- $widget_options = !empty( $args['widget_options'] ) ? $args['widget_options'] : array();
343
- $control_options = !empty( $args['control_options'] ) ? $args['control_options'] : array();
344
-
345
- return array( $id_base, $name, $widget_options, $control_options );
346
- }
347
-
348
- private function sanitize_instance( $instance ) {
349
- return wp_parse_args( $instance, $this->defaults );
350
- }
351
- }
352
- }
353
-
354
- /**
355
- * Get template path of a widget
356
- *
357
- * @param $slug
358
- *
359
- * @return string
360
- */
361
- function learn_press_get_widget_template_path( $slug ) {
362
- return LP_WIDGET_PATH . "/{$slug}/tmpl/";
363
- }
364
-
365
- function learn_press_get_widget_theme_template_path( $slug ) {
366
-
367
- }
368
-
369
- /**
370
- * Display a template of a widget
371
- *
372
- * @param $slug
373
- * @param $template_name
374
- * @param array $args
375
- */
376
- function learn_press_get_widget_template( $slug, $template_name = 'default.php', $args = array() ) {
377
- //$template_path = learn_press_get_widget_template_path( $slug );
378
- $template = "widgets/{$slug}/" . ( $template_name ? $template_name : 'default.php' );
379
- die();
380
- learn_press_get_template( $template );// $template_name ? $template_name : 'default.php', $args, learn_press_template_path() . "/widgets/{$slug}", LP_PLUGIN_PATH . "/widgets/{$slug}" );
381
- }
382
-
383
- /**
384
- * Display a template of a widget
385
- *
386
- * @param string $slug
387
- * @param string $template_name
388
- *
389
- * @return string
390
- */
391
- function learn_press_locate_widget_template( $slug, $template_name = 'default.php' ) {
392
- //$template_path = learn_press_get_widget_template_path( $slug );
393
- $template = "widgets/{$slug}/" . ( $template_name ? $template_name : 'default.php' );
394
- return learn_press_locate_template( $template );
395
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/course/abstract-lp-course.php CHANGED
@@ -302,14 +302,85 @@ abstract class LP_Abstract_Course {
302
  if ( !$this->id ) {
303
  return false;
304
  }
305
- $curriculum = _learn_press_get_course_curriculum( $this->id, $force );
306
- $return = false;
307
- if ( $section_id ) {
308
- if ( !empty( $curriculum[$section_id] ) ) {
309
- $return = $curriculum[$section_id];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
310
  }
311
- } else {
312
- $return = $curriculum;
313
  }
314
  return apply_filters( 'learn_press_course_curriculum', $return, $this->id, $section_id );
315
  }
@@ -348,18 +419,27 @@ abstract class LP_Abstract_Course {
348
  * @return int
349
  */
350
  public function get_users_enrolled( $force = false ) {
351
- $this->_count_users = LP_Cache::get_enrolled_courses( $this->id );
352
- return $this->_count_users;
353
- /*
354
  if ( ( $this->_count_users === null && !array_key_exists( $this->id, self::$course_users ) ) || $force ) {
355
- self::$course_users = _learn_press_count_users_enrolled_courses( array( $this->id ) );
 
 
 
 
 
 
 
 
 
 
356
  }
357
  if ( !array_key_exists( $this->id, self::$course_users ) ) {
358
  $this->_count_users = 0;
359
  } else {
360
  $this->_count_users = absint( self::$course_users[$this->id] );
361
  }
362
- return $this->_count_users;*/
363
  }
364
 
365
  /**
@@ -530,6 +610,7 @@ abstract class LP_Abstract_Course {
530
 
531
  global $wpdb;
532
  if ( $limit < 0 ) $limit = PHP_INT_MAX;
 
533
  if ( $this->_students_list === null || $force ) {
534
  $query = $wpdb->prepare( "
535
  SELECT DISTINCT u.*
@@ -542,6 +623,7 @@ abstract class LP_Abstract_Course {
542
  $this->_students_list = $wpdb->get_results( $query );
543
  }
544
  return $this->_students_list;
 
545
  }
546
 
547
 
@@ -657,9 +739,6 @@ abstract class LP_Abstract_Course {
657
  if ( $curriculum ) foreach ( $curriculum as $section ) {
658
  if ( empty( $section->items ) ) continue;
659
  foreach ( $section->items as $loop_item ) {
660
- if ( empty( $section->section_id ) ) {
661
- continue;
662
- }
663
  $loop_item->section_id = $section->section_id;
664
  if ( $field ) {
665
  $item = array();
@@ -812,30 +891,24 @@ abstract class LP_Abstract_Course {
812
 
813
  public function count_in_order( $statuses = 'completed' ) {
814
  global $wpdb;
815
- static $data = array();
816
  settype( $statuses, 'array' );
817
  foreach ( $statuses as $k => $v ) {
818
  if ( !preg_match( '/^lp-/', $v ) ) {
819
  $statuses[$k] = 'lp-' . $v;
820
  }
821
  }
822
- sort( $statuses );
823
- $key = md5( serialize( $statuses ) );
824
- if ( !array_key_exists( $key, $data ) ) {
825
- $in_clause = join( ',', array_fill( 0, sizeof( $statuses ), '%s' ) );
826
- $query = $wpdb->prepare( "
827
- SELECT count(oim.meta_id)
828
- FROM {$wpdb->learnpress_order_itemmeta} oim
829
- INNER JOIN {$wpdb->learnpress_order_items} oi ON oi.order_item_id = oim.learnpress_order_item_id
830
- AND oim.meta_key = %s
831
- AND oim.meta_value = %d
832
- INNER JOIN {$wpdb->posts} o ON o.ID = oi.order_id
833
- WHERE o.post_type = %s
834
- AND o.post_status IN ($in_clause)
835
- ", array_merge( array( '_course_id', $this->id, 'lp_order' ), $statuses ) );
836
- $data[$key] = $wpdb->get_var( $query );
837
- }
838
- return $data[$key];
839
  }
840
 
841
  public function need_payment() {
@@ -1058,26 +1131,16 @@ abstract class LP_Abstract_Course {
1058
  return apply_filters( 'learn_press_course_result_html', $html, $this->id, $user_id );
1059
  }
1060
 
1061
- protected function _evaluate_course_by_items( $user_id = 0, $force = false, $type = '' ) {
1062
  $items = $this->get_curriculum_items();
1063
  $result = 0;
1064
  if ( $items ) {
1065
- $completed_items = $this->count_completed_items( $user_id, $force, $type );
1066
  $result = round( $completed_items / sizeof( $items ) * 100 );
1067
  }
1068
  return apply_filters( 'learn_press_course_results_by_items', $result, $this->id, $user_id );
1069
  }
1070
 
1071
- protected function _evaluate_course_by_lessons( $user_id = 0, $force = false, $type = '' ) {
1072
- $lessons = $this->get_lessons();
1073
- $result = 0;
1074
- if ( $lessons ) {
1075
- $completed_items = $this->count_completed_items( $user_id, $force, 'lp_lesson' );
1076
- $result = round( $completed_items / sizeof( $lessons ) * 100 );
1077
- }
1078
- return apply_filters( 'learn_press_course_results_by_items', $result, $this->id, $user_id );
1079
- }
1080
-
1081
  /**
1082
  * Calculate course results for user by course results settings
1083
  *
@@ -1093,113 +1156,17 @@ abstract class LP_Abstract_Course {
1093
 
1094
  $quizzes = $this->get_quizzes();
1095
 
1096
- if ( ( 'evaluate_lesson' === $this->course_result ) || !$quizzes ) {
1097
  //$results = $this->_evaluate_course_by_items( $user_id, $force );
1098
  $results = $this->_evaluate_course_by_lesson( $user_id, $force );
1099
- } elseif ( 'evaluate_final_quiz' === $this->course_result ) {
1100
- $results = $this->_evaluate_course_by_quiz( $user_id, $force );
1101
- } elseif ( 'evaluate_quiz' === $this->course_result ) {
1102
- $results = $this->_evaluate_course_by_quizzes( $user_id, $force );
1103
- } elseif ( 'evaluate_quizzes' === $this->course_result ) {
1104
- $results = $this->_evaluate_course_by_quizzes_results( $user_id, $force );
1105
- } elseif ( 'evaluate_passed_quizzes' === $this->course_result ) {
1106
- $results = $this->_evaluate_course_by_passed_quizzes_results( $user_id, $force );
1107
- }
1108
-
1109
- return apply_filters( 'learn_press_evaluation_course_results', $results );
1110
- }
1111
-
1112
- /**
1113
- * Get achieved point of all quizzes per total points of all quizzes
1114
- *
1115
- * @param $user_id
1116
- * @param bool $force
1117
- *
1118
- * @return mixed|void
1119
- */
1120
- public function _evaluate_course_by_quizzes_results( $user_id, $force = false ) {
1121
- $quizzes = $this->get_quizzes();
1122
- $user = learn_press_get_user( $user_id );
1123
- $results = array();
1124
- $achieved_point = 0;
1125
- $total_point = 0;
1126
- $quizzes_ids = array();
1127
- foreach ( $quizzes as $quiz ) {
1128
- if ( !$this->enable_evaluate_item( $quiz->ID, $user_id ) ) {
1129
- continue;
1130
- }
1131
- $quizzes_ids[] = $quiz->ID;
1132
- $results[$quiz->ID] = $user->get_quiz_results( $quiz->ID, $this->id, true );
1133
- if ( $quiz = wp_cache_get( $quiz->ID, 'posts' ) ) {
1134
- $total_point += isset( $quiz->mark ) ? absint( $quiz->mark ) : 0;
1135
- }
1136
- $achieved_point += is_object( $results[$quiz->ID] ) ? $results[$quiz->ID]->mark : 0;
1137
- }
1138
- $result = ( $achieved_point / $total_point ) * 100;
1139
- return apply_filters( 'learn_press_evaluate_course_by_quizzes_results', $result, $this->id, $user_id );
1140
- }
1141
-
1142
- public function enable_evaluate_item( $item_id, $user_id = 0 ) {
1143
- if ( !$user_id ) {
1144
- $user_id = get_current_user_id();
1145
- }
1146
- return apply_filters( 'learn_press_enable_evaluate_course_item', true, $item_id, $user_id, $this->id );
1147
- }
1148
-
1149
- public function _evaluate_course_by_passed_quizzes_results( $user_id, $force = false ) {
1150
- $quizzes = $this->get_quizzes();
1151
- $user = learn_press_get_user( $user_id );
1152
- $results = array();
1153
- $achieved_point = 0;
1154
- $total_point = 0;
1155
- foreach ( $quizzes as $_quiz ) {
1156
- if ( !$this->enable_evaluate_item( $_quiz->ID, $user_id ) ) {
1157
- continue;
1158
- }
1159
- $quiz = LP_Quiz::get_quiz( $_quiz->ID );
1160
- if ( $_quiz = wp_cache_get( $quiz->id, 'posts' ) ) {
1161
- $total_point += isset( $_quiz->mark ) ? absint( $_quiz->mark ) : 0;
1162
- }
1163
- $grade = $user->get_quiz_graduation( $quiz->id, $this->id );
1164
- /*$passing_grade = get_post_meta( $quiz->ID, '_lp_passing_grade', true );
1165
- $results[$quiz->ID] = $user->get_quiz_results( $quiz->ID, $this->id, true );
1166
- $quiz_passed = false;
1167
- $passing_grade_type = get_post_meta( $quiz->ID, '_lp_passing_grade_type', true );
1168
- $passing_grade = get_post_meta( $quiz->ID, '_lp_passing_grade', true );
1169
- if ( $passing_grade_type = 'percentage' ) {
1170
- $quiz_passed = ( $results[$quiz->ID]->correct_percent >= intval( $passing_grade ) );
1171
- } elseif ( $passing_grade_type = 'point' ) {
1172
- $quiz_passed = ( $results[$quiz->ID]->mark >= intval( $passing_grade ) );
1173
  } else {
1174
- $quiz_passed = true;
1175
- }*/
1176
- if ( $grade == 'passed' ) {
1177
- $quiz_results = $user->get_quiz_results( $quiz->ID, $this->id, true );
1178
- $achieved_point += is_object( $quiz_results ) ? $quiz_results->mark : 0;
1179
  }
1180
  }
1181
- $result = ( $achieved_point / $total_point ) * 100;
1182
- return apply_filters( 'learn_press_evaluate_course_by_passed_quizzes_results', $result, $this->id, $user_id );
1183
- }
1184
-
1185
- public function _get_total_question( $quizzes_ids = array() ) {
1186
- global $wpdb;
1187
- if ( !empty( $quizzes_ids ) ) {
1188
- $format = array_fill( 0, sizeof( $quizzes_ids ), '%d' );
1189
- $args = array_merge( $quizzes_ids, array( 'publish', LP_QUESTION_CPT ) );
1190
- echo $sql = $wpdb->prepare( "
1191
- SELECT COUNT(*)
1192
- FROM {$wpdb->prefix}learnpress_quiz_questions lqq
1193
- INNER JOIN {$wpdb->posts} p ON lqq.question_id = p.ID
1194
- WHERE
1195
- quiz_id IN (" . join( ',', $format ) . ")
1196
- AND p.post_status = %s
1197
- AND p.post_type = %s",
1198
- $args
1199
- );
1200
- return $wpdb->get_var( $sql );
1201
- }
1202
- return 0;
1203
  }
1204
 
1205
  public function is_evaluation( $thing ) {
@@ -1268,13 +1235,13 @@ abstract class LP_Abstract_Course {
1268
  /**
1269
  * Get number of lessons user has completed
1270
  *
1271
- * @param $user_id
1272
- * @param bool $force
1273
- * @param string $type
1274
  *
1275
  * @return int|mixed|null|void
1276
  */
1277
- public function get_completed_items( $user_id = 0, $force = false, $type = '' ) {
1278
  if ( !$user_id ) {
1279
  $user_id = get_current_user_id();
1280
  }
@@ -1285,14 +1252,9 @@ abstract class LP_Abstract_Course {
1285
  if ( $curriculum_items = $this->post->curriculum_items ) {
1286
  $curriculum_items = maybe_unserialize( $curriculum_items );
1287
  foreach ( $curriculum_items as $item_id ) {
1288
- if ( $type && $type !== get_post_type( $item_id ) ) {
1289
- continue;
1290
- }
1291
  $k = sprintf( '%d-%d-%d', $user_id, $this->id, $item_id );
1292
  if ( !empty( $item_statuses[$k] ) && $item_statuses[$k] == 'completed' ) {
1293
- if ( $this->enable_evaluate_item( $item_id, $user_id ) ) {
1294
- $completed_items[] = $item_id;
1295
- }
1296
  }
1297
  }
1298
  }
@@ -1306,8 +1268,8 @@ abstract class LP_Abstract_Course {
1306
  *
1307
  * @return mixed|void
1308
  */
1309
- public function count_completed_items( $user_id = 0, $force = false, $type = '' ) {
1310
- $items = $this->get_completed_items( $user_id, $force, $type );
1311
  $count = 0;
1312
  if ( $items ) {
1313
  $count = sizeof( $items );
@@ -1315,17 +1277,6 @@ abstract class LP_Abstract_Course {
1315
  return apply_filters( 'learn_press_count_user_completed_items', $count, $this->id, $user_id );
1316
  }
1317
 
1318
- /**
1319
- * Check a quiz is a final quiz in this course
1320
- *
1321
- * @param $quiz_id
1322
- *
1323
- * @return mixed|void
1324
- */
1325
- public function is_final_quiz( $quiz_id ) {
1326
- return apply_filters( 'learn_press_is_final_quiz', $this->final_quiz == $quiz_id, $quiz_id, $this->id );
1327
- }
1328
-
1329
  /**
1330
  * Calculate results of course by final quiz
1331
  *
@@ -1342,6 +1293,7 @@ abstract class LP_Abstract_Course {
1342
 
1343
  public function evaluate_quiz( $quiz_id, $user_id, $force = false ) {
1344
  $user = learn_press_get_user( $user_id );
 
1345
  $results = $user->get_quiz_results( $quiz_id, $this->id );
1346
  if ( !$results ) {
1347
  $result = 0;
@@ -1368,17 +1320,10 @@ abstract class LP_Abstract_Course {
1368
  $quizzes = $this->get_quizzes();
1369
  $result = 0;
1370
  if ( $quizzes ) {
1371
- $count = 0;
1372
  foreach ( $quizzes as $quiz ) {
1373
- if ( !$this->enable_evaluate_item( $quiz->ID, $user_id ) ) {
1374
- continue;
1375
- }
1376
  $result += $this->evaluate_quiz( $quiz->ID, $user_id, $force );
1377
- $count ++;
1378
- }
1379
- if ( $count ) {
1380
- $result = round( $result / $count );
1381
  }
 
1382
  }
1383
  return apply_filters( 'learn_press_evaluation_course_quizzes', $result, $this->id, $user_id );
1384
  }
@@ -1494,20 +1439,15 @@ abstract class LP_Abstract_Course {
1494
  * @return mixed
1495
  */
1496
  public function output_args( $args = null ) {
1497
- $args = wp_parse_args( $args, array( 'echo' => true, 'user_id' => get_current_user_id() ) );
1498
- $user = learn_press_get_user( $args['user_id'] );
1499
- $course_info = $user->get_course_info( $this->id );
1500
- $course_grade = $user->get_course_grade( $this->id );
1501
- if ( array_key_exists( 'items', $course_info ) ) {
1502
- unset( $course_info['items'] );
1503
- }
1504
  $output = array(
1505
- 'root_url' => trailingslashit( get_site_url() ),
1506
  'id' => $this->id,
1507
  'url' => $this->get_permalink(),
1508
- 'results' => $this->evaluate_course_results( $user->id ),// $this->get_course_info( $args['user_id'] ),
1509
- 'grade' => $course_grade,
1510
- 'grade_html' => learn_press_course_grade_html( $course_grade, false ),
1511
  'current_item' => $this->is_viewing_item(),
1512
  'items' => $this->get_items_params()
1513
  );
@@ -1523,20 +1463,18 @@ abstract class LP_Abstract_Course {
1523
  */
1524
  public function get_items_params( $user_id = null ) {
1525
  global $wpdb;
1526
- $user = learn_press_get_current_user( $user_id );
1527
- $items = $this->get_curriculum_items(
1528
  array(
1529
  'field' => array( 'item_id', 'item_type', 'post_title', 'section_id' ),
1530
  'field_map' => array( 'id', 'type', 'title' ),
1531
  'field_format' => array( '%d', '%s', '%s', '%d' )
1532
  )
1533
  );
1534
- $root_url = trailingslashit( get_site_url() );
1535
  if ( $items ) foreach ( $items as $k => $item ) {
1536
  if ( ( $view = $user->can( 'view-item', $item['id'], $this->id ) ) !== false ) {
1537
- $status = $user->get_item_status( $item['id'], $this->id );
1538
- $items[$k]['url'] = str_replace( $root_url, '', $this->get_item_link( $item['id'] ) );
1539
- $items[$k]['status'] = ( $status == 'completed' && $item['type'] == LP_QUIZ_CPT ) ? $user->get_quiz_graduation( $item['id'], $this->id ) : $status;
1540
  if ( $view == 'preview' ) {
1541
 
1542
  }
@@ -1549,14 +1487,6 @@ abstract class LP_Abstract_Course {
1549
  return $items;
1550
  }
1551
 
1552
- /**
1553
- * Get external link of "Buy this course" button
1554
- *
1555
- * @return mixed|void
1556
- */
1557
- public function get_external_link() {
1558
- return apply_filters( 'learn_press_external_link_buy_course', $this->external_link_buy_course, $this->id );
1559
- }
1560
 
1561
  public function get_video_embed() {
1562
  $video_id = $this->video_id;
@@ -1584,4 +1514,4 @@ abstract class LP_Abstract_Course {
1584
  return $embed;
1585
  }
1586
 
1587
- }
302
  if ( !$this->id ) {
303
  return false;
304
  }
305
+ if ( false ) {
306
+ $curriculum = LP_Cache::get_course_curriculum( false, array() );
307
+
308
+ if ( !array_key_exists( $this->id, $curriculum ) || $force ) {
309
+ global $wpdb;
310
+
311
+ $curriculum[$this->id] = array();
312
+ $query = $wpdb->prepare( "
313
+ SELECT cc.*
314
+ FROM {$wpdb->posts} p
315
+ INNER JOIN {$wpdb->learnpress_sections} cc ON p.ID = cc.section_course_id
316
+ WHERE p.ID = %d
317
+ ORDER BY `section_order` ASC
318
+ ", $this->id );
319
+ if ( $rows = $wpdb->get_results( $query, OBJECT_K ) ) {
320
+ $section_ids = array_keys( $rows );
321
+ $how_many = count( $section_ids );
322
+ $placeholders = array_fill( 0, $how_many, '%d' );
323
+ $in = implode( ', ', $placeholders );
324
+
325
+ $query = $wpdb->prepare( "
326
+ SELECT si.*, p.*
327
+ FROM {$wpdb->posts} p
328
+ INNER JOIN {$wpdb->prefix}learnpress_section_items si ON si.item_id = p.ID
329
+ INNER JOIN {$wpdb->prefix}learnpress_sections s ON s.section_id = si.section_id
330
+ WHERE s.section_id IN( $in )
331
+ ORDER BY s.section_order, si.item_order ASC
332
+ ", $section_ids );
333
+ $section_items = $wpdb->get_results( $query );
334
+ $post_ids = array();
335
+ foreach ( $rows as $row ) {
336
+ $section = $row;
337
+ $section->items = array();
338
+ if ( $section_items ) {
339
+ $count = 0;
340
+ foreach ( $section_items as $item ) {
341
+ if ( $item->section_id == $row->section_id ) {
342
+ $section->items[] = $item;
343
+ /**
344
+ * Add item to 'posts' cache group
345
+ */
346
+ $item_post = wp_cache_get( $item->ID, 'posts' );
347
+ if ( !$item_post ) {
348
+ wp_cache_add( $item->ID, $item, 'posts' );
349
+ }
350
+ $post_ids[] = $item->ID;
351
+ $count ++;
352
+ } else {
353
+ if ( $count ) break;
354
+ }
355
+ }
356
+ }
357
+ $curriculum[$this->id][$section->section_id] = $section;
358
+ }
359
+ // update all meta data into cache
360
+ update_meta_cache( 'post', $post_ids );
361
+ //SELECT post_id, meta_key, meta_value FROM wp_postmeta WHERE post_id IN
362
+ }
363
+ }
364
+ LP_Cache::set_course_curriculum( $curriculum );
365
+ $return = false;
366
+ if ( $section_id ) {
367
+ if ( !empty( $curriculum[$this->id][$section_id] ) ) {
368
+ $return = $curriculum[$this->id][$section_id];
369
+ }
370
+ } else {
371
+ $return = $curriculum[$this->id];
372
+ }
373
+ } // end if(false)
374
+ else {
375
+ $curriculum = _learn_press_get_course_curriculum( $this->id, $force );
376
+ $return = false;
377
+ if ( $section_id ) {
378
+ if ( !empty( $curriculum[$section_id] ) ) {
379
+ $return = $curriculum[$section_id];
380
+ }
381
+ } else {
382
+ $return = $curriculum;
383
  }
 
 
384
  }
385
  return apply_filters( 'learn_press_course_curriculum', $return, $this->id, $section_id );
386
  }
419
  * @return int
420
  */
421
  public function get_users_enrolled( $force = false ) {
422
+
423
+ global $wpdb;
 
424
  if ( ( $this->_count_users === null && !array_key_exists( $this->id, self::$course_users ) ) || $force ) {
425
+ /*$query = $wpdb->prepare( "
426
+ SELECT count(o.ID)
427
+ FROM {$wpdb->posts} o
428
+ INNER JOIN {$wpdb->learnpress_order_items} oi ON oi.order_id = o.ID
429
+ INNER JOIN {$wpdb->learnpress_order_itemmeta} oim ON oim.learnpress_order_item_id = oi.order_item_id
430
+ AND oim.meta_key = %s AND oim.meta_value = %d
431
+ WHERE o.post_status = %s
432
+ ", '_course_id', $this->id, 'lp-completed' );*/
433
+ self::$course_users = _learn_press_get_users_enrolled_courses( array( $this->id ) );
434
+ /*
435
+ $this->_count_users = $wpdb->get_var( $query );*/
436
  }
437
  if ( !array_key_exists( $this->id, self::$course_users ) ) {
438
  $this->_count_users = 0;
439
  } else {
440
  $this->_count_users = absint( self::$course_users[$this->id] );
441
  }
442
+ return $this->_count_users;
443
  }
444
 
445
  /**
610
 
611
  global $wpdb;
612
  if ( $limit < 0 ) $limit = PHP_INT_MAX;
613
+
614
  if ( $this->_students_list === null || $force ) {
615
  $query = $wpdb->prepare( "
616
  SELECT DISTINCT u.*
623
  $this->_students_list = $wpdb->get_results( $query );
624
  }
625
  return $this->_students_list;
626
+
627
  }
628
 
629
 
739
  if ( $curriculum ) foreach ( $curriculum as $section ) {
740
  if ( empty( $section->items ) ) continue;
741
  foreach ( $section->items as $loop_item ) {
 
 
 
742
  $loop_item->section_id = $section->section_id;
743
  if ( $field ) {
744
  $item = array();
891
 
892
  public function count_in_order( $statuses = 'completed' ) {
893
  global $wpdb;
 
894
  settype( $statuses, 'array' );
895
  foreach ( $statuses as $k => $v ) {
896
  if ( !preg_match( '/^lp-/', $v ) ) {
897
  $statuses[$k] = 'lp-' . $v;
898
  }
899
  }
900
+ $in_clause = join( ',', array_fill( 0, sizeof( $statuses ), '%s' ) );
901
+ $query = $wpdb->prepare( "
902
+ SELECT count(oim.meta_id)
903
+ FROM {$wpdb->learnpress_order_itemmeta} oim
904
+ INNER JOIN {$wpdb->learnpress_order_items} oi ON oi.order_item_id = oim.learnpress_order_item_id
905
+ AND oim.meta_key = %s
906
+ AND oim.meta_value = %d
907
+ INNER JOIN {$wpdb->posts} o ON o.ID = oi.order_id
908
+ WHERE o.post_type = %s
909
+ AND o.post_status IN ($in_clause)
910
+ ", array_merge( array( '_course_id', $this->id, 'lp_order' ), $statuses ) );
911
+ return $wpdb->get_var( $query );
 
 
 
 
 
912
  }
913
 
914
  public function need_payment() {
1131
  return apply_filters( 'learn_press_course_result_html', $html, $this->id, $user_id );
1132
  }
1133
 
1134
+ protected function _evaluate_course_by_items( $user_id = 0, $force = false ) {
1135
  $items = $this->get_curriculum_items();
1136
  $result = 0;
1137
  if ( $items ) {
1138
+ $completed_items = $this->count_completed_items( $user_id, $force );
1139
  $result = round( $completed_items / sizeof( $items ) * 100 );
1140
  }
1141
  return apply_filters( 'learn_press_course_results_by_items', $result, $this->id, $user_id );
1142
  }
1143
 
 
 
 
 
 
 
 
 
 
 
1144
  /**
1145
  * Calculate course results for user by course results settings
1146
  *
1156
 
1157
  $quizzes = $this->get_quizzes();
1158
 
1159
+ if ( ( $this->course_result == 'evaluate_lesson' ) || !$quizzes ) {
1160
  //$results = $this->_evaluate_course_by_items( $user_id, $force );
1161
  $results = $this->_evaluate_course_by_lesson( $user_id, $force );
1162
+ } else {
1163
+ if ( $this->course_result == 'evaluate_final_quiz' ) {
1164
+ $results = $this->_evaluate_course_by_quiz( $user_id, $force );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1165
  } else {
1166
+ $results = $this->_evaluate_course_by_quizzes( $user_id, $force );
 
 
 
 
1167
  }
1168
  }
1169
+ return apply_filters( 'learn_press_evaluation_course_results', $results );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1170
  }
1171
 
1172
  public function is_evaluation( $thing ) {
1235
  /**
1236
  * Get number of lessons user has completed
1237
  *
1238
+ * @param $user_id
1239
+ * @param array $items
1240
+ * @param bool $force
1241
  *
1242
  * @return int|mixed|null|void
1243
  */
1244
+ public function get_completed_items( $user_id = 0, $items = array(), $force = false ) {
1245
  if ( !$user_id ) {
1246
  $user_id = get_current_user_id();
1247
  }
1252
  if ( $curriculum_items = $this->post->curriculum_items ) {
1253
  $curriculum_items = maybe_unserialize( $curriculum_items );
1254
  foreach ( $curriculum_items as $item_id ) {
 
 
 
1255
  $k = sprintf( '%d-%d-%d', $user_id, $this->id, $item_id );
1256
  if ( !empty( $item_statuses[$k] ) && $item_statuses[$k] == 'completed' ) {
1257
+ $completed_items[] = $item_id;
 
 
1258
  }
1259
  }
1260
  }
1268
  *
1269
  * @return mixed|void
1270
  */
1271
+ public function count_completed_items( $user_id = 0, $force = false ) {
1272
+ $items = $this->get_completed_items( $user_id, $force );
1273
  $count = 0;
1274
  if ( $items ) {
1275
  $count = sizeof( $items );
1277
  return apply_filters( 'learn_press_count_user_completed_items', $count, $this->id, $user_id );
1278
  }
1279
 
 
 
 
 
 
 
 
 
 
 
 
1280
  /**
1281
  * Calculate results of course by final quiz
1282
  *
1293
 
1294
  public function evaluate_quiz( $quiz_id, $user_id, $force = false ) {
1295
  $user = learn_press_get_user( $user_id );
1296
+ $quiz = LP_Quiz::get_quiz( $quiz_id );
1297
  $results = $user->get_quiz_results( $quiz_id, $this->id );
1298
  if ( !$results ) {
1299
  $result = 0;
1320
  $quizzes = $this->get_quizzes();
1321
  $result = 0;
1322
  if ( $quizzes ) {
 
1323
  foreach ( $quizzes as $quiz ) {
 
 
 
1324
  $result += $this->evaluate_quiz( $quiz->ID, $user_id, $force );
 
 
 
 
1325
  }
1326
+ $result = round( $result / sizeof( $quizzes ) );
1327
  }
1328
  return apply_filters( 'learn_press_evaluation_course_quizzes', $result, $this->id, $user_id );
1329
  }
1439
  * @return mixed
1440
  */
1441
  public function output_args( $args = null ) {
1442
+
1443
+ $args = wp_parse_args( $args, array( 'echo' => true, 'user_id' => get_current_user_id() ) );
1444
+
1445
+ $user = learn_press_get_user( $args['user_id'] );
1446
+
 
 
1447
  $output = array(
 
1448
  'id' => $this->id,
1449
  'url' => $this->get_permalink(),
1450
+ 'results' => $user->get_course_info( $this->id ),// $this->get_course_info( $args['user_id'] ),
 
 
1451
  'current_item' => $this->is_viewing_item(),
1452
  'items' => $this->get_items_params()
1453
  );
1463
  */
1464
  public function get_items_params( $user_id = null ) {
1465
  global $wpdb;
1466
+ $user = learn_press_get_current_user( $user_id );
1467
+ $items = $this->get_curriculum_items(
1468
  array(
1469
  'field' => array( 'item_id', 'item_type', 'post_title', 'section_id' ),
1470
  'field_map' => array( 'id', 'type', 'title' ),
1471
  'field_format' => array( '%d', '%s', '%s', '%d' )
1472
  )
1473
  );
 
1474
  if ( $items ) foreach ( $items as $k => $item ) {
1475
  if ( ( $view = $user->can( 'view-item', $item['id'], $this->id ) ) !== false ) {
1476
+ $items[$k]['url'] = $this->get_item_link( $item['id'] );
1477
+ $items[$k]['status'] = $user->get_item_status( $item['id'], $this->id );
 
1478
  if ( $view == 'preview' ) {
1479
 
1480
  }
1487
  return $items;
1488
  }
1489
 
 
 
 
 
 
 
 
 
1490
 
1491
  public function get_video_embed() {
1492
  $video_id = $this->video_id;
1514
  return $embed;
1515
  }
1516
 
1517
+ }
inc/course/lp-course-functions.php CHANGED
@@ -102,10 +102,10 @@ function learn_press_get_question_quizzes( $question_id ) {
102
  }
103
 
104
  function _learn_press_usort_terms_by_ID( $terms ) {
105
- $version = get_bloginfo( 'version' );
106
- if ( version_compare( $version, '4.7', '>=' ) ) {
107
- $terms = wp_list_sort( $terms, 'term_id' );
108
- } else {
109
  usort( $terms, '_usort_terms_by_ID' );
110
  }
111
  return $terms;
@@ -125,7 +125,7 @@ function learn_press_course_post_type_link( $permalink, $post ) {
125
  $terms = get_the_terms( $post->ID, 'course_category' );
126
 
127
  if ( !empty( $terms ) ) {
128
- $terms = _learn_press_usort_terms_by_ID( $terms ); // order by ID
129
  $category_object = apply_filters( 'learn_press_course_post_type_link_course_category', $terms[0], $terms, $post );
130
  $category_object = get_term( $category_object, 'course_category' );
131
  $course_category = $category_object->slug;
@@ -581,25 +581,26 @@ if ( !function_exists( 'learn_press_get_course_item_url' ) ) {
581
 
582
  if ( !function_exists( 'learn_press_get_sample_link_course_item_url' ) ) {
583
 
584
- function learn_press_get_sample_link_course_item_url( $item_id = null ) {
585
 
586
- if ( !$item_id ) {
587
- return;
588
- }
589
 
590
 
591
- $permalink = get_the_permalink( $item_id );
592
- $post_name = get_post_field( 'post_name', $item_id );
593
 
594
- if ( '' != get_option( 'permalink_structure' ) ) {
595
- $permalink = $post_name;
596
- } else {
597
- $key = preg_replace( '!lp_!', '', get_post_type( $item_id ) );
598
- $permalink = add_query_arg( array( $key => $post_name ), $permalink );
599
- }
600
- return $permalink;
 
601
 
602
- }
603
  }
604
 
605
  if ( !function_exists( 'learn_press_get_nav_course_item_url' ) ) {
@@ -636,16 +637,35 @@ if ( !function_exists( 'learn_press_get_nav_course_item_url' ) ) {
636
  }
637
  }
638
 
639
- if ( !function_exists( 'learn_press_course_nav_items' ) ) {
640
- /**
641
- * Displaying course items navigation
642
- *
643
- * @param null $item_id
644
- * @param null $course_id
645
- * @param bool $content_only
646
- */
647
- function learn_press_course_nav_items( $item_id = null, $course_id = null, $content_only = false ) {
648
- learn_press_get_template( 'single-course/nav-items.php', array( 'course_id' => $course_id, 'item_id' => $item_id, 'content_only' => $content_only ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
649
  }
650
  }
651
  /**
@@ -654,75 +674,75 @@ if ( !function_exists( 'learn_press_course_nav_items' ) ) {
654
 
655
  if ( !function_exists( 'learn_press_get_item_course_id' ) ) {
656
 
657
- function learn_press_get_item_course_id( $post_id, $post_type ) {
658
-
659
- global $wpdb;
660
-
661
- /**
662
- * Get Course id by Quiz post_id
663
- *
664
- * @global type $wpdb
665
- *
666
- * @param type $post_id
667
- *
668
- * @return $course_id
669
- */
670
- if ( $post_type == LP_QUIZ_CPT ) {
671
- $query = $wpdb->prepare( "SELECT section.section_course_id FROM {$wpdb->learnpress_sections} AS section"
672
- . " INNER JOIN {$wpdb->learnpress_section_items} AS item ON item.section_id = section.section_id"
673
- . " INNER JOIN {$wpdb->posts} AS course ON course.ID = section.section_course_id"
674
- . " WHERE course.post_type = %s"
675
- . " AND course.post_status = %s"
676
- . " AND item.item_type = %s"
677
- . " AND item.item_id = %d"
678
- . " LIMIT 1", LP_COURSE_CPT, 'publish', LP_QUIZ_CPT, $post_id );
679
-
680
- return apply_filters( 'learn_press_get_quiz_course_id', absint( $wpdb->get_var( $query ) ), $post_id );
681
- }
682
-
683
- /**
684
- * Get Course id by Lesson post_id
685
- *
686
- * @global type $wpdb
687
- *
688
- * @param type $post_id
689
- *
690
- * @return $course_id
691
- */
692
-
693
- if ( $post_type == LP_LESSON_CPT ) {
694
-
695
- $query = $wpdb->prepare( "SELECT section.section_course_id FROM {$wpdb->learnpress_sections} AS section"
696
- . " INNER JOIN {$wpdb->learnpress_section_items} AS item ON item.section_id = section.section_id"
697
- . " INNER JOIN {$wpdb->posts} AS course ON course.ID = section.section_course_id"
698
- . " WHERE course.post_type = %s"
699
- . " AND course.post_status = %s"
700
- . " AND item.item_type = %s"
701
- . " AND item.item_id = %d"
702
- . " LIMIT 1", LP_COURSE_CPT, 'publish', LP_LESSON_CPT, $post_id );
703
-
704
- return apply_filters( 'learn_press_get_lesson_course_id', absint( $wpdb->get_var( $query ) ), $post_id );
705
-
706
- }
707
-
708
- }
709
- }
710
-
711
- add_filter( 'get_sample_permalink', 'learn_press_item_sample_permalink', 10, 5 );
712
 
713
  if ( !function_exists( 'learn_press_item_sample_permalink' ) ) {
714
 
715
- function learn_press_item_sample_permalink( $permalink, $post_id, $title, $name, $post ) {
716
 
717
- if ( $post->post_type !== LP_QUIZ_CPT && $post->post_type !== LP_LESSON_CPT ) {
718
- return $permalink;
719
- }
720
 
721
  // $permalink = str_replace( $post->post_name, '%pagename%' , $permalink );
722
- $permalink[0] = str_replace( $post->post_name, '%pagename%', $permalink[0] );
723
 
724
- return $permalink;
725
- }
726
 
727
  }
728
 
@@ -730,77 +750,28 @@ add_filter( 'post_type_link', 'learn_press_quiz_permalink', 10, 2 );
730
 
731
  if ( !function_exists( 'learn_press_quiz_permalink' ) ) {
732
 
733
- function learn_press_quiz_permalink( $permalink, $post ) {
734
 
735
- if ( !empty( LP()->global['item_permalinks'][$post->ID] ) ) {
736
- return LP()->global['item_permalinks'][$post->ID];
737
- }
738
- remove_filter( 'post_type_link', 'learn_press_quiz_permalink', 10 );
739
 
740
- if ( $post->post_type !== LP_QUIZ_CPT && $post->post_type !== LP_LESSON_CPT ) {
741
- return $permalink;
742
- }
743
 
744
- $course_id = learn_press_get_item_course_id( $post->ID, $post->post_type );
745
- if ( $course_id ) {
746
- $permalink = learn_press_get_course_item_url( $course_id, $post->ID );
747
- } else {
 
748
 
749
- $permalink = learn_press_get_sample_link_course_item_url( $post->ID );
750
- }
751
- LP()->global['item_permalinks'][$post->ID] = $permalink;
752
- add_filter( 'post_type_link', 'learn_press_quiz_permalink', 10, 2 );
753
- return $permalink;
754
- }
755
  }
756
 
757
- add_filter( 'template_include', 'learn_press_prepare_archive_courses' );
758
- function learn_press_prepare_archive_courses( $template ) {
759
- global $wp_query;
760
- $query = !empty( LP()->wp_query ) ? LP()->wp_query : $wp_query;
761
- if ( !$query || !$query->is_main_query() ) {
762
- return $template;
763
- }
764
- if ( !empty( $query->posts ) ) {
765
- $ids = array();
766
- foreach ( $query->posts as $_post ) {
767
- $ids[] = $_post->ID;
768
- $_post = sanitize_post( $_post, 'raw' );
769
- wp_cache_add( $_post->ID, $_post, 'posts' );
770
- }
771
- _learn_press_get_courses_curriculum( $ids, false, false );
772
- _learn_press_count_users_enrolled_courses( $ids );
773
- }
774
- return $template;
775
- }
776
-
777
- function learn_press_course_grade_html( $grade, $echo = true ) {
778
- $html = '';
779
- switch ( $grade ) {
780
- case 'passed':
781
- $html = __( 'Passed', 'learnpress' );
782
- break;
783
- case 'failed':
784
- $html = __( 'Failed', 'learnpress' );
785
- break;
786
- case 'in-progress':
787
- $html = __( 'In Progress', 'learnpress' );
788
- break;
789
- }
790
- $html = apply_filters( 'learn_press_course_grade_html', $html, $grade );
791
- if ( $echo ) echo $html;
792
- return $html;
793
- }
794
-
795
- function learn_press_get_course_results_tooltip( $course_id ) {
796
- $metabox = LP_Course_Post_Type::assessment_meta_box();
797
- $options = $metabox['fields'][0]['options'];
798
- $cr = get_post_meta( $course_id, '_lp_course_result', true );
799
- $tooltip = !empty( $options[$cr] ) ? $options[$cr] : false;
800
- if ( $tooltip ) {
801
- if ( preg_match_all( '~<p.*>(.*)<\/p>~im', $tooltip, $matches ) ) {
802
- $tooltip = $matches[1][0];
803
- }
804
- }
805
- return $tooltip;
806
- }
102
  }
103
 
104
  function _learn_press_usort_terms_by_ID( $terms ) {
105
+ $version = get_bloginfo('version');
106
+ if( version_compare ($version, '4.7', '>=') ){
107
+ $terms = wp_list_sort($terms, 'term_id');
108
+ }else{
109
  usort( $terms, '_usort_terms_by_ID' );
110
  }
111
  return $terms;
125
  $terms = get_the_terms( $post->ID, 'course_category' );
126
 
127
  if ( !empty( $terms ) ) {
128
+ $terms = _learn_press_usort_terms_by_ID( $terms ); // order by ID
129
  $category_object = apply_filters( 'learn_press_course_post_type_link_course_category', $terms[0], $terms, $post );
130
  $category_object = get_term( $category_object, 'course_category' );
131
  $course_category = $category_object->slug;
581
 
582
  if ( !function_exists( 'learn_press_get_sample_link_course_item_url' ) ) {
583
 
584
+ function learn_press_get_sample_link_course_item_url( $item_id = null) {
585
 
586
+ if ( !$item_id ) {
587
+ return;
588
+ }
589
 
590
 
591
+ $permalink = get_the_permalink( $item_id );
592
+ $post_name = get_post_field( 'post_name', $item_id );
593
 
594
+ if ( '' != get_option( 'permalink_structure' ) ) {
595
+ $permalink = $post_name;
596
+ }
597
+ else {
598
+ $key = preg_replace( '!lp_!', '', get_post_type( $item_id ) );
599
+ $permalink = add_query_arg( array( $key => $post_name ), $permalink );
600
+ }
601
+ return $permalink;
602
 
603
+ }
604
  }
605
 
606
  if ( !function_exists( 'learn_press_get_nav_course_item_url' ) ) {
637
  }
638
  }
639
 
640
+ if ( !function_exists( 'learn_press_get_nav_course_item' ) ) {
641
+ function learn_press_get_nav_course_item( $course_id = null, $item_id = null, $content_only = false ) {
642
+ $nav = learn_press_get_nav_course_item_url( $course_id, $item_id, $content_only );
643
+ $nav_html = '
644
+ <nav id="lp-navigation" class="navigation post-navigation" role="navigation">
645
+ <h2 class="screen-reader-text">' . __( 'Course item navigation', 'learnpress' ) . '</h2>
646
+ <div class="nav-links">';
647
+ if ( isset( $nav['back']['link'] ) ) {
648
+ $nav_html .=
649
+ '<div class="nav-previous nav-link">
650
+ <a class="course-item-title button-load-item js-action" data-id="' . esc_attr( $nav['back']['id'] ) . '" '
651
+ . 'href="' . esc_attr( $nav['back']['link'] ) . '" rel="prev">'
652
+ . '<span class="meta-nav" aria-hidden="true">' . __( 'Previous', 'learnpress' ) . '</span> <span class="screen-reader-text">' . __( 'Previous post:', 'learnpress' ) . '</span> <span class="post-title">' . $nav['back']['title'] . '</span></a>
653
+ </div>';
654
+ }
655
+ if ( isset( $nav['next']['link'] ) ) {
656
+ $nav_html .=
657
+ '<div class="nav-next nav-link">
658
+ <a class="course-item-title button-load-item js-action" data-id="' . esc_attr( $nav['next']['id'] ) . '" '
659
+ . 'href="' . esc_attr( $nav['next']['link'] ) . '" rel="next">'
660
+ . '<span class="meta-nav" aria-hidden="true">' . __( 'Next', 'learnpress' ) . '</span> <span class="screen-reader-text">' . __( 'Next post:', 'learnpress' ) . '</span> <span class="post-title">' . $nav['next']['title'] . '</span></a>
661
+ </div>
662
+ ';
663
+ }
664
+ $nav_html .= '
665
+ </div>
666
+ </nav>
667
+ ';
668
+ echo $nav_html;
669
  }
670
  }
671
  /**
674
 
675
  if ( !function_exists( 'learn_press_get_item_course_id' ) ) {
676
 
677
+ function learn_press_get_item_course_id( $post_id , $post_type ) {
678
+
679
+ global $wpdb;
680
+
681
+ /**
682
+ * Get Course id by Quiz post_id
683
+ *
684
+ * @global type $wpdb
685
+ *
686
+ * @param type $post_id
687
+ *
688
+ * @return $course_id
689
+ */
690
+ if ( $post_type == LP_QUIZ_CPT ) {
691
+ $query = $wpdb->prepare( "SELECT section.section_course_id FROM {$wpdb->learnpress_sections} AS section"
692
+ . " INNER JOIN {$wpdb->learnpress_section_items} AS item ON item.section_id = section.section_id"
693
+ . " INNER JOIN {$wpdb->posts} AS course ON course.ID = section.section_course_id"
694
+ . " WHERE course.post_type = %s"
695
+ . " AND course.post_status = %s"
696
+ . " AND item.item_type = %s"
697
+ . " AND item.item_id = %d"
698
+ . " LIMIT 1", LP_COURSE_CPT, 'publish', LP_QUIZ_CPT, $post_id );
699
+
700
+ return apply_filters( 'learn_press_get_quiz_course_id', absint( $wpdb->get_var( $query ) ), $post_id );
701
+ }
702
+
703
+ /**
704
+ * Get Course id by Lesson post_id
705
+ *
706
+ * @global type $wpdb
707
+ *
708
+ * @param type $post_id
709
+ *
710
+ * @return $course_id
711
+ */
712
+
713
+ if ( $post_type == LP_LESSON_CPT ) {
714
+
715
+ $query = $wpdb->prepare( "SELECT section.section_course_id FROM {$wpdb->learnpress_sections} AS section"
716
+ . " INNER JOIN {$wpdb->learnpress_section_items} AS item ON item.section_id = section.section_id"
717
+ . " INNER JOIN {$wpdb->posts} AS course ON course.ID = section.section_course_id"
718
+ . " WHERE course.post_type = %s"
719
+ . " AND course.post_status = %s"
720
+ . " AND item.item_type = %s"
721
+ . " AND item.item_id = %d"
722
+ . " LIMIT 1", LP_COURSE_CPT, 'publish', LP_LESSON_CPT, $post_id );
723
+
724
+ return apply_filters( 'learn_press_get_lesson_course_id', absint( $wpdb->get_var( $query ) ), $post_id );
725
+
726
+ }
727
+
728
+ }
729
+ }
730
+
731
+ add_filter('get_sample_permalink', 'learn_press_item_sample_permalink', 10, 5);
732
 
733
  if ( !function_exists( 'learn_press_item_sample_permalink' ) ) {
734
 
735
+ function learn_press_item_sample_permalink( $permalink, $post_id, $title, $name, $post ){
736
 
737
+ if ( $post->post_type !== LP_QUIZ_CPT && $post->post_type !== LP_LESSON_CPT) {
738
+ return $permalink;
739
+ }
740
 
741
  // $permalink = str_replace( $post->post_name, '%pagename%' , $permalink );
742
+ $permalink[0] = str_replace( $post->post_name, '%pagename%' , $permalink[0] );
743
 
744
+ return $permalink;
745
+ }
746
 
747
  }
748
 
750
 
751
  if ( !function_exists( 'learn_press_quiz_permalink' ) ) {
752
 
753
+ function learn_press_quiz_permalink( $permalink, $post ) {
754
 
755
+ if( !empty(LP()->global['item_permalinks'][$post->ID])){
756
+ return LP()->global['item_permalinks'][$post->ID];
757
+ }
758
+ remove_filter( 'post_type_link', 'learn_press_quiz_permalink', 10);
759
 
760
+ if ( $post->post_type !== LP_QUIZ_CPT && $post->post_type !== LP_LESSON_CPT) {
761
+ return $permalink;
762
+ }
763
 
764
+ $course_id = learn_press_get_item_course_id( $post->ID, $post->post_type );
765
+ if ( $course_id ) {
766
+ $permalink = learn_press_get_course_item_url( $course_id, $post->ID );
767
+ }
768
+ else {
769
 
770
+ $permalink = learn_press_get_sample_link_course_item_url( $post->ID );
771
+ }
772
+ LP()->global['item_permalinks'][$post->ID] = $permalink;
773
+ add_filter( 'post_type_link', 'learn_press_quiz_permalink', 10, 2 );
774
+ return $permalink;
775
+ }
776
  }
777
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/custom-post-types/course.php CHANGED
@@ -34,16 +34,20 @@ if ( !class_exists( 'LP_Course_Post_Type' ) ) {
34
  ->add_map_method( 'save', 'before_save_curriculum', false )
35
  ->add_map_method( 'before_delete', 'delete_course_sections' );
36
 
37
- add_action( 'edit_form_after_editor', array( $this, 'curriculum_editor' ), 0 );
 
38
  add_action( 'load-post.php', array( $this, 'post_actions' ) );
39
  add_action( 'init', array( $this, 'register_taxonomy' ) );
 
 
40
  add_filter( 'get_edit_post_link', array( $this, 'add_course_tab_arg' ) );
41
- add_filter( "rwmb__lpr_course_price_html", array( $this, 'currency_symbol' ), 5, 3 );
42
- add_filter( 'learn_press_loop_section_buttons', array( __CLASS__, 'add_section_buttons' ) );
43
  if ( self::$_enable_review ) {
44
  add_action( 'post_submitbox_start', array( $this, 'post_review_message_box' ) );
45
  }
46
 
 
 
 
47
  if ( self::$_VER2 ) {
48
  add_action( 'admin_enqueue_scripts', array( $this, 'admin_script' ) );
49
  add_action( 'admin_print_scripts', array( $this, 'course_editor' ) );
@@ -51,25 +55,6 @@ if ( !class_exists( 'LP_Course_Post_Type' ) ) {
51
 
52
  }
53
 
54
- public static function add_section_buttons( $buttons ) {
55
- $buttons = array_merge(
56
- $buttons,
57
- array(
58
- array(
59
- 'id' => 'add-lesson',
60
- 'text' => __( 'Add Lesson', 'learnpress' ),
61
- 'attr' => 'data-action="add-lesson" data-type="lp_lesson"'
62
- ),
63
- array(
64
- 'id' => 'add-quiz',
65
- 'text' => __( 'Add Quiz', 'learnpress' ),
66
- 'attr' => 'data-action="add-quiz" data-type="lp_quiz"'
67
- )
68
- )
69
- );
70
- return $buttons;
71
- }
72
-
73
  public function add_course_tab_arg( $m ) {
74
  if ( array_key_exists( '_lp_curriculum', $_POST ) && !empty( $_POST['course-tab'] ) ) {
75
  $m = add_query_arg( 'tab', $_POST['course-tab'], $m );
@@ -85,13 +70,98 @@ if ( !class_exists( 'LP_Course_Post_Type' ) ) {
85
  * @since 2.0.9
86
  */
87
  public function curriculum_editor() {
88
- global $post;
89
  if ( get_post_type() != 'lp_course' ) {
90
  return;
91
  }
92
- $course = LP_Course::get_course( $post );
93
- $view = learn_press_get_admin_view( 'meta-boxes/course/curriculum.php' );
94
- include $view;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  }
96
 
97
  public function register_taxonomy() {
@@ -307,7 +377,8 @@ if ( !class_exists( 'LP_Course_Post_Type' ) ) {
307
  * @static
308
  * @return mixed
309
  */
310
- public function admin_params() {
 
311
  global $post;
312
 
313
  return apply_filters( 'learn_press_admin_course_params',
@@ -326,34 +397,19 @@ if ( !class_exists( 'LP_Course_Post_Type' ) ) {
326
  *
327
  * @static
328
  */
329
- public function admin_scripts() {
 
330
  global $post;
331
 
332
  $user = learn_press_get_current_user();
333
-
334
- LP_Assets::enqueue_script( 'learn-press-modal-search-items' );
335
  LP_Assets::add_localize(
336
  array(
337
- 'confirm_remove_section_lesson' => __( 'Do you want to remove this lesson permanently?', 'learnpress' ),
338
- 'confirm_remove_section_quiz' => __( 'Do you want to remove this quiz permanently?', 'learnpress' ),
339
- 'confirm_remove_section' => __( 'Do you want to remove this section permanently?', 'learnpress' ),
340
- 'add_new_quiz' => __( 'New quiz added', 'learnpress' ),
341
- 'add_new_lesson' => __( 'New lesson added', 'learnpress' ),
342
- 'add_new_section' => __( 'New section added', 'learnpress' ),
343
- 'remove_section_lesson' => __( 'The lesson removed', 'learnpress' ),
344
- 'remove_section_quiz' => __( 'The quiz removed', 'learnpress' ),
345
- 'remove_section' => __( 'The section removed', 'learnpress' ),
346
- 'section_ordered' => __( 'The ordering completed', 'learnpress' ),
347
- 'add_lesson_to_section' => __( 'Lesson added to section completed!', 'learnpress' ),
348
- 'add_quiz_to_section' => __( 'Quiz added to section completed!', 'learnpress' ),
349
- 'update_lesson_quiz' => __( '%s updated', 'learnpress' ),
350
- 'quick_edit_name' => __( 'Click to quick edit name', 'learnpress' ),
351
- 'save_course' => __( 'Save Course', 'learnpress' ),
352
- 'submit_course_review' => __( 'Submit for Review', 'learnpress' ),
353
  'notice_remove_section_item' => __( 'Are you sure you want to remove this item?', 'learnpress' ),
354
  'user_warning_course_publish_to_pending' => __( 'You course will become to Pending', 'learnpress' ),
355
  'user_warning_can_not_submit_course' => __( 'Your course is pending for reviewing', 'learnpress' )
356
- ), null, 'learn-press-mb-course'
 
 
357
  );
358
  if ( get_post_type() == LP_COURSE_CPT && self::$_enable_review && !$this->_is_archive() ) {
359
  LP_Assets::add_param( 'required_review', LP()->settings->get( 'required_review' ) == 'yes', 'learn-press-mb-course', 'LP_Settings' );
@@ -374,14 +430,16 @@ if ( !class_exists( 'LP_Course_Post_Type' ) ) {
374
  /**
375
  * Print js template
376
  */
377
- public function print_js_template() {
 
378
  if ( get_post_type() != LP_COURSE_CPT ) {
379
  return;
380
  }
381
  learn_press_admin_view( 'meta-boxes/course/js-template.php' );
382
  }
383
 
384
- public function currency_symbol(
 
385
  $input_html, $field, $sub_meta
386
  ) {
387
  return $input_html . '<span class="lpr-course-price-symbol">' . learn_press_get_currency_symbol() . '</span>';
@@ -390,7 +448,8 @@ if ( !class_exists( 'LP_Course_Post_Type' ) ) {
390
  /**
391
  * Register course post type
392
  */
393
- public function register() {
 
394
  $settings = LP_Settings::instance();
395
  $labels = array(
396
  'name' => _x( 'Courses', 'Post Type General Name', 'learnpress' ),
@@ -463,7 +522,7 @@ if ( !class_exists( 'LP_Course_Post_Type' ) ) {
463
  )
464
  );
465
 
466
- //new RW_Meta_Box( self::curriculum_meta_box() );
467
  /*new RW_Meta_Box( self::settings_meta_box() );
468
  new RW_Meta_Box( self::assessment_meta_box() );
469
  new RW_Meta_Box( self::payment_meta_box() );
@@ -571,17 +630,12 @@ if ( !class_exists( 'LP_Course_Post_Type' ) ) {
571
  *
572
  * @return mixed|null|void
573
  */
574
- public static function assessment_meta_box() {
 
575
  $post_id = learn_press_get_request( 'post' );
576
  $prefix = '_lp_';
577
- $course_results = get_post_meta( $post_id, '_lp_course_result', true );
578
- $course_result_desc = '';
579
- if ( in_array( $course_results, array( '', 'evaluate_lesson', 'evaluate_final_quiz' ) ) ) {
580
- $course_result_desc .= sprintf( '<a href="" data-advanced="%2$s" data-basic="%1$s" data-click="basic">%2$s</a>', __( 'Basic Options', 'learnpress' ), __( 'Advanced Options', 'learnpress' ) );
581
- }
582
- $course_result_desc = "<span id=\"learn-press-toggle-course-results\">{$course_result_desc}</span>";
583
- $course_result_desc .= __( 'The method to assess the result of a student for a course.', 'learnpress' );
584
- if ( $course_results == 'evaluate_final_quiz' && !get_post_meta( $post_id, '_lp_final_quiz', true ) ) {
585
  $course_result_desc .= __( '<br /><strong>Note! </strong>No final quiz in course, please add a final quiz', 'learnpress' );
586
  }
587
  $meta_box = array(
@@ -596,15 +650,11 @@ if ( !class_exists( 'LP_Course_Post_Type' ) ) {
596
  'type' => 'radio',
597
  'desc' => $course_result_desc,
598
  'options' => array(
599
- 'evaluate_lesson' => __( 'Evaluate lessons', 'learnpress' ) . sprintf( '<p class="description option-desc">%s</p>', __( 'Evaluate by lessons user has completed per total lessons in course.', 'learnpress' ) ),
600
- 'evaluate_final_quiz' => __( 'Evaluate results of the final quiz', 'learnpress' ) . sprintf( '<p class="description option-desc">%s</p>', __( 'Evaluate by results of final quiz in course.', 'learnpress' ) ),
601
- // new options
602
- 'evaluate_quizzes' => __( 'Evaluate results of quizzes', 'learnpress' ) . sprintf( '<p class="description option-desc">%s</p>', __( 'Evaluate by achieved points per total point of all quizzes.', 'learnpress' ) ),
603
- 'evaluate_passed_quizzes' => __( 'Evaluate results of quizzes passed', 'learnpress' ) . sprintf( '<p class="description option-desc">%s</p>', __( 'Evaluate by achieved points of passed course per total point of all quizzes.', 'learnpress' ) ),
604
- 'evaluate_quiz' => __( 'Evaluate quizzes', 'learnpress' ) . sprintf( '<p class="description option-desc">%s</p>', __( 'Evaluate by quizzes user has completed per total quizzes.', 'learnpress' ) ),
605
  ),
606
  'std' => 'evaluate_lesson',
607
- 'inline' => false
608
  ),
609
  array(
610
  'name' => __( 'Passing condition value', 'learnpress' ),
@@ -763,8 +813,8 @@ if ( !class_exists( 'LP_Course_Post_Type' ) ) {
763
  public static function author_meta_box() {
764
 
765
  $course_id = !empty( $_GET['post'] ) ? $_GET['post'] : 0;
766
- $post = get_post( $course_id );
767
- $author = $post ? $post->post_author : get_current_user_id();
768
 
769
  $prefix = '_lp_';
770
 
@@ -965,9 +1015,6 @@ if ( !class_exists( 'LP_Course_Post_Type' ) ) {
965
  if ( 'dopreview' == $preview && 'draft' == $post->post_status ) {
966
  learn_press_add_message( __( 'Course Curriculum only appear if course is saved', 'learnpress' ), 'error' );
967
  }
968
-
969
- $this->_reset_sections();
970
-
971
  if ( !empty( $_REQUEST['_lp_curriculum'] ) && 'dopreview' !== $preview ) {
972
  $section_order = 0;
973
  $query_update = array();
@@ -1114,10 +1161,8 @@ if ( !class_exists( 'LP_Course_Post_Type' ) ) {
1114
  $submit_for_review = false;
1115
  }
1116
  if ( ( $submit_for_review || ( $old_status != $new_status ) ) && $post->post_status != 'auto-draft' ) {
1117
- if ( isset( $_POST['learn-press-submit-for-review'] ) && $_POST['learn-press-submit-for-review'] === 'yes' ) {
1118
- $action = 'for_reviewer';
1119
- update_post_meta( $post->ID, '_lp_submit_for_reviewer', 'yes' );
1120
- }
1121
  }
1122
  }
1123
  $message = learn_press_get_request( 'review-message' );
@@ -1228,11 +1273,11 @@ if ( !class_exists( 'LP_Course_Post_Type' ) ) {
1228
  private function _update_price() {
1229
  global $wpdb, $post;
1230
  $request = $_POST;
1231
- $payment = learn_press_get_request( '_lp_payment' ) == 1;
1232
- $price = floatval( $request['_lp_price'] );
1233
- $sale_price = $request['_lp_sale_price'];
1234
- $sale_price_start = $request['_lp_sale_start'];
1235
- $sale_price_end = $request['_lp_sale_end'];
1236
  $keys = array();
1237
  // Delete all meta no need anymore
1238
  if ( !$payment || $price <= 0 ) {
@@ -1306,15 +1351,6 @@ if ( !class_exists( 'LP_Course_Post_Type' ) ) {
1306
 
1307
  $columns['taxonomy-course_category'] = __( 'Categories', 'learnpress' );
1308
 
1309
- global $wp_query;
1310
- if ( $wp_query->is_main_query() ) {
1311
- if ( LP_COURSE_CPT == $wp_query->query['post_type'] && $wp_query->posts ) {
1312
- $post_ids = wp_list_pluck( $wp_query->posts, 'ID' );
1313
- _learn_press_get_courses_curriculum( $post_ids, false, false );
1314
- _learn_press_count_users_enrolled_courses( $post_ids );
1315
- }
1316
- }
1317
-
1318
  return $columns;
1319
  }
1320
 
@@ -1402,7 +1438,8 @@ if ( !class_exists( 'LP_Course_Post_Type' ) ) {
1402
  learn_press_admin_view( 'meta-boxes/course/review-log' );
1403
  }
1404
 
1405
- public function posts_fields(
 
1406
  $fields
1407
  ) {
1408
  if ( !$this->_is_archive() ) {
@@ -1422,7 +1459,8 @@ if ( !class_exists( 'LP_Course_Post_Type' ) ) {
1422
  *
1423
  * @return string
1424
  */
1425
- public function posts_join_paged(
 
1426
  $join
1427
  ) {
1428
  if ( !$this->_is_archive() ) {
@@ -1439,7 +1477,8 @@ if ( !class_exists( 'LP_Course_Post_Type' ) ) {
1439
  *
1440
  * @return mixed|string
1441
  */
1442
- public function posts_where_paged(
 
1443
  $where
1444
  ) {
1445
  if ( !$this->_is_archive() ) {
@@ -1462,7 +1501,8 @@ if ( !class_exists( 'LP_Course_Post_Type' ) ) {
1462
  *
1463
  * @return string
1464
  */
1465
- public function posts_orderby(
 
1466
  $order_by_statement
1467
  ) {
1468
  if ( !$this->_is_archive() ) {
@@ -1481,7 +1521,8 @@ if ( !class_exists( 'LP_Course_Post_Type' ) ) {
1481
  *
1482
  * @return mixed
1483
  */
1484
- public function sortable_columns(
 
1485
  $columns
1486
  ) {
1487
  $columns['author'] = 'author';
@@ -1490,7 +1531,8 @@ if ( !class_exists( 'LP_Course_Post_Type' ) ) {
1490
  return $columns;
1491
  }
1492
 
1493
- private function _is_archive() {
 
1494
  global $pagenow, $post_type;
1495
  if ( !is_admin() || ( $pagenow != 'edit.php' ) || ( LP_COURSE_CPT != $post_type ) ) {
1496
  return false;
@@ -1499,11 +1541,13 @@ if ( !class_exists( 'LP_Course_Post_Type' ) ) {
1499
  return true;
1500
  }
1501
 
1502
- private function _get_orderby() {
 
1503
  return isset( $_REQUEST['orderby'] ) ? $_REQUEST['orderby'] : '';
1504
  }
1505
 
1506
- private function _get_search() {
 
1507
  return isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : false;
1508
  }
1509
 
@@ -1511,7 +1555,8 @@ if ( !class_exists( 'LP_Course_Post_Type' ) ) {
1511
  * Course video
1512
  * @return mixed|null|void
1513
  */
1514
- public static function video_meta_box() {
 
1515
  $prefix = '_lp_';
1516
  $meta_box = array(
1517
  'id' => 'course_video',
@@ -1558,7 +1603,8 @@ if ( !class_exists( 'LP_Course_Post_Type' ) ) {
1558
  }
1559
 
1560
 
1561
- public static function instance() {
 
1562
  if ( !self::$_instance ) {
1563
  self::$_instance = new self( LP_COURSE_CPT );
1564
  }
34
  ->add_map_method( 'save', 'before_save_curriculum', false )
35
  ->add_map_method( 'before_delete', 'delete_course_sections' );
36
 
37
+ add_action( 'edit_form_after_editor', array( $this, 'toggle_editor_button' ), - 10 );
38
+
39
  add_action( 'load-post.php', array( $this, 'post_actions' ) );
40
  add_action( 'init', array( $this, 'register_taxonomy' ) );
41
+ add_action( 'init', array( $this, 'init_course' ) );
42
+
43
  add_filter( 'get_edit_post_link', array( $this, 'add_course_tab_arg' ) );
 
 
44
  if ( self::$_enable_review ) {
45
  add_action( 'post_submitbox_start', array( $this, 'post_review_message_box' ) );
46
  }
47
 
48
+ // filter
49
+ add_filter( "rwmb__lpr_course_price_html", array( $this, 'currency_symbol' ), 5, 3 );
50
+
51
  if ( self::$_VER2 ) {
52
  add_action( 'admin_enqueue_scripts', array( $this, 'admin_script' ) );
53
  add_action( 'admin_print_scripts', array( $this, 'course_editor' ) );
55
 
56
  }
57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  public function add_course_tab_arg( $m ) {
59
  if ( array_key_exists( '_lp_curriculum', $_POST ) && !empty( $_POST['course-tab'] ) ) {
60
  $m = add_query_arg( 'tab', $_POST['course-tab'], $m );
70
  * @since 2.0.9
71
  */
72
  public function curriculum_editor() {
73
+ global $wp_meta_boxes, $post;
74
  if ( get_post_type() != 'lp_course' ) {
75
  return;
76
  }
77
+ if ( empty( $wp_meta_boxes['lp_course'] ) ) {
78
+ return;
79
+ }
80
+ if ( empty( $wp_meta_boxes['lp_course']['normal'] ) ) {
81
+ return;
82
+ }
83
+ if ( empty( $wp_meta_boxes['lp_course']['normal']['high'] ) ) {
84
+ return;
85
+ }
86
+ if ( empty( $wp_meta_boxes['lp_course']['normal']['high']['course_curriculum'] ) ) {
87
+ return;
88
+ }
89
+ if ( empty( $screen ) ) {
90
+ $screen = get_current_screen();
91
+ } elseif ( is_string( $screen ) ) {
92
+ $screen = convert_to_screen( $screen );
93
+ }
94
+
95
+ $page = $screen->id;
96
+ // backup origin metaboxes data
97
+ $wp_meta_boxes_origin = $wp_meta_boxes;
98
+
99
+ $sorted = get_user_option( "meta-box-order_$page" );
100
+ if ( !empty( $sorted ) ) {
101
+ foreach ( $sorted as $context => $ids ) {
102
+ if ( strpos( $ids, 'course_curriculum' ) !== false ) {
103
+ $ids = explode( ',', $ids );
104
+ $pos = array_search( 'course_curriculum', $ids );
105
+ unset( $ids[$pos] );
106
+ $sorted[$context] = join( ',', $ids );
107
+ update_user_option( get_current_user_id(), "meta-box-order_$page", $sorted, true );
108
+ break;
109
+ }
110
+ }
111
+ }
112
+ // keep course curriculum only and call do_meta_boxes to render it content
113
+ $wp_meta_boxes = array(
114
+ 'lp_course' => array(
115
+ 'course_curriculum' => array(
116
+ 'high' => array(
117
+ 'course_curriculum' => $wp_meta_boxes['lp_course']['normal']['high']['course_curriculum']
118
+ )
119
+ )
120
+ )
121
+ );
122
+ do_meta_boxes( null, 'course_curriculum', $post );
123
+
124
+ // restore origin metaboxes registered
125
+ $wp_meta_boxes = $wp_meta_boxes_origin;
126
+
127
+ // but no need course curriculum anymore
128
+ unset( $wp_meta_boxes['lp_course']['normal']['high']['course_curriculum'] );
129
+ //learn_press_debug($wp_meta_boxes['lp_course']);
130
+ if ( $sorted = get_user_option( "meta-box-order_$page" ) ) {
131
+ foreach ( $sorted as $box_context => $ids ) {
132
+ foreach ( explode( ',', $ids ) as $id ) {
133
+ if ( $id && 'dashboard_browser_nag' !== $id ) {
134
+ add_meta_box( $id, null, null, $screen, $box_context, 'sorted' );
135
+ }
136
+ }
137
+ }
138
+ }
139
+ }
140
+
141
+ public function init_course() {
142
+ if ( $toggle = learn_press_get_request( 'switch-course-tabs' ) ) {
143
+ if ( $toggle == 'off' ) {
144
+ learn_press_delete_user_option( 'course-tabs' );
145
+ } elseif ( $toggle == 'on' ) {
146
+ learn_press_update_user_option( 'course-tabs', 'yes' );
147
+ }
148
+
149
+ $link = get_edit_post_link( learn_press_get_request( 'post' ), 'redirect' );
150
+ wp_redirect( $link );
151
+ exit();
152
+ }
153
+
154
+ add_action( 'edit_form_after_editor', array( $this, 'curriculum_editor' ), 10 );
155
+ if ( learn_press_get_user_option( 'course-tabs' ) == 'yes' ) {
156
+ LP_Assets::add_param( 'enable_course_tabs', 'yes', '__all', 'LP_Settings' );
157
+ add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
158
+ }
159
+ }
160
+
161
+ public function admin_body_class( $classes ) {
162
+ $classes .= ' enable-course-tabs';
163
+
164
+ return $classes;
165
  }
166
 
167
  public function register_taxonomy() {
377
  * @static
378
  * @return mixed
379
  */
380
+ public
381
+ function admin_params() {
382
  global $post;
383
 
384
  return apply_filters( 'learn_press_admin_course_params',
397
  *
398
  * @static
399
  */
400
+ public
401
+ function admin_scripts() {
402
  global $post;
403
 
404
  $user = learn_press_get_current_user();
 
 
405
  LP_Assets::add_localize(
406
  array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
407
  'notice_remove_section_item' => __( 'Are you sure you want to remove this item?', 'learnpress' ),
408
  'user_warning_course_publish_to_pending' => __( 'You course will become to Pending', 'learnpress' ),
409
  'user_warning_can_not_submit_course' => __( 'Your course is pending for reviewing', 'learnpress' )
410
+ ),
411
+ null,
412
+ 'learn-press-mb-course'
413
  );
414
  if ( get_post_type() == LP_COURSE_CPT && self::$_enable_review && !$this->_is_archive() ) {
415
  LP_Assets::add_param( 'required_review', LP()->settings->get( 'required_review' ) == 'yes', 'learn-press-mb-course', 'LP_Settings' );
430
  /**
431
  * Print js template
432
  */
433
+ public
434
+ function print_js_template() {
435
  if ( get_post_type() != LP_COURSE_CPT ) {
436
  return;
437
  }
438
  learn_press_admin_view( 'meta-boxes/course/js-template.php' );
439
  }
440
 
441
+ public
442
+ function currency_symbol(
443
  $input_html, $field, $sub_meta
444
  ) {
445
  return $input_html . '<span class="lpr-course-price-symbol">' . learn_press_get_currency_symbol() . '</span>';
448
  /**
449
  * Register course post type
450
  */
451
+ public
452
+ function register() {
453
  $settings = LP_Settings::instance();
454
  $labels = array(
455
  'name' => _x( 'Courses', 'Post Type General Name', 'learnpress' ),
522
  )
523
  );
524
 
525
+ new RW_Meta_Box( self::curriculum_meta_box() );
526
  /*new RW_Meta_Box( self::settings_meta_box() );
527
  new RW_Meta_Box( self::assessment_meta_box() );
528
  new RW_Meta_Box( self::payment_meta_box() );
630
  *
631
  * @return mixed|null|void
632
  */
633
+ public
634
+ static function assessment_meta_box() {
635
  $post_id = learn_press_get_request( 'post' );
636
  $prefix = '_lp_';
637
+ $course_result_desc = __( 'The method to assess the result of a student for a course.', 'learnpress' );
638
+ if ( $post_id && get_post_meta( $post_id, '_lp_course_result', true ) == 'evaluate_final_quiz' && !get_post_meta( $post_id, '_lp_final_quiz', true ) ) {
 
 
 
 
 
 
639
  $course_result_desc .= __( '<br /><strong>Note! </strong>No final quiz in course, please add a final quiz', 'learnpress' );
640
  }
641
  $meta_box = array(
650
  'type' => 'radio',
651
  'desc' => $course_result_desc,
652
  'options' => array(
653
+ 'evaluate_lesson' => __( 'Evaluate lessons', 'learnpress' ),
654
+ 'evaluate_quizzes' => __( 'Evaluate result of quizzes', 'learnpress' ),
655
+ 'evaluate_final_quiz' => __( 'Evaluate the result of the final quiz', 'learnpress' )
 
 
 
656
  ),
657
  'std' => 'evaluate_lesson',
 
658
  ),
659
  array(
660
  'name' => __( 'Passing condition value', 'learnpress' ),
813
  public static function author_meta_box() {
814
 
815
  $course_id = !empty( $_GET['post'] ) ? $_GET['post'] : 0;
816
+
817
+ $author = get_post( $course_id ) ? get_post( $course_id )->post_author : '';
818
 
819
  $prefix = '_lp_';
820
 
1015
  if ( 'dopreview' == $preview && 'draft' == $post->post_status ) {
1016
  learn_press_add_message( __( 'Course Curriculum only appear if course is saved', 'learnpress' ), 'error' );
1017
  }
 
 
 
1018
  if ( !empty( $_REQUEST['_lp_curriculum'] ) && 'dopreview' !== $preview ) {
1019
  $section_order = 0;
1020
  $query_update = array();
1161
  $submit_for_review = false;
1162
  }
1163
  if ( ( $submit_for_review || ( $old_status != $new_status ) ) && $post->post_status != 'auto-draft' ) {
1164
+ $action = 'for_reviewer';
1165
+ update_post_meta( $post->ID, '_lp_submit_for_reviewer', 'yes' );
 
 
1166
  }
1167
  }
1168
  $message = learn_press_get_request( 'review-message' );
1273
  private function _update_price() {
1274
  global $wpdb, $post;
1275
  $request = $_POST;
1276
+ $payment = learn_press_get_request('_lp_payment') == 1;
1277
+ $price = absint( $request['_lp_price'] );
1278
+ $sale_price = learn_press_get_request('_lp_sale_price');
1279
+ $sale_price_start = learn_press_get_request('_lp_sale_start');
1280
+ $sale_price_end = learn_press_get_request('_lp_sale_end');
1281
  $keys = array();
1282
  // Delete all meta no need anymore
1283
  if ( !$payment || $price <= 0 ) {
1351
 
1352
  $columns['taxonomy-course_category'] = __( 'Categories', 'learnpress' );
1353
 
 
 
 
 
 
 
 
 
 
1354
  return $columns;
1355
  }
1356
 
1438
  learn_press_admin_view( 'meta-boxes/course/review-log' );
1439
  }
1440
 
1441
+ public
1442
+ function posts_fields(
1443
  $fields
1444
  ) {
1445
  if ( !$this->_is_archive() ) {
1459
  *
1460
  * @return string
1461
  */
1462
+ public
1463
+ function posts_join_paged(
1464
  $join
1465
  ) {
1466
  if ( !$this->_is_archive() ) {
1477
  *
1478
  * @return mixed|string
1479
  */
1480
+ public
1481
+ function posts_where_paged(
1482
  $where
1483
  ) {
1484
  if ( !$this->_is_archive() ) {
1501
  *
1502
  * @return string
1503
  */
1504
+ public
1505
+ function posts_orderby(
1506
  $order_by_statement
1507
  ) {
1508
  if ( !$this->_is_archive() ) {
1521
  *
1522
  * @return mixed
1523
  */
1524
+ public
1525
+ function sortable_columns(
1526
  $columns
1527
  ) {
1528
  $columns['author'] = 'author';
1531
  return $columns;
1532
  }
1533
 
1534
+ private
1535
+ function _is_archive() {
1536
  global $pagenow, $post_type;
1537
  if ( !is_admin() || ( $pagenow != 'edit.php' ) || ( LP_COURSE_CPT != $post_type ) ) {
1538
  return false;
1541
  return true;
1542
  }
1543
 
1544
+ private
1545
+ function _get_orderby() {
1546
  return isset( $_REQUEST['orderby'] ) ? $_REQUEST['orderby'] : '';
1547
  }
1548
 
1549
+ private
1550
+ function _get_search() {
1551
  return isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : false;
1552
  }
1553
 
1555
  * Course video
1556
  * @return mixed|null|void
1557
  */
1558
+ public
1559
+ static function video_meta_box() {
1560
  $prefix = '_lp_';
1561
  $meta_box = array(
1562
  'id' => 'course_video',
1603
  }
1604
 
1605
 
1606
+ public
1607
+ static function instance() {
1608
  if ( !self::$_instance ) {
1609
  self::$_instance = new self( LP_COURSE_CPT );
1610
  }
inc/custom-post-types/order.php CHANGED
@@ -26,22 +26,14 @@ if ( !class_exists( 'LP_Order_Post_Type' ) ) {
26
  add_action( 'admin_init', array( $this, 'remove_box' ) );
27
  add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
28
  add_filter( 'admin_footer', array( $this, 'admin_footer' ) );
29
- add_action( 'add_meta_boxes', array( $this, 'post_new' ) );
30
 
31
  $this
32
- ->add_map_method( 'before_delete', 'delete_order_data' )
33
  ->add_map_method( 'save', 'save_order' );
34
 
35
  parent::__construct( $post_type );
36
  }
37
 
38
- public function post_new() {
39
- global $post;
40
- if ( $post && $post->post_type == 'lp_order' && $post->post_status == 'auto-draft' && learn_press_get_request( 'multi-users' ) == 'yes' ) {
41
- update_post_meta( $post->ID, '_lp_multi_users', 'yes' );
42
- }
43
- }
44
-
45
  public function enqueue_scripts() {
46
  if ( get_post_type() != 'lp_order' ) {
47
  return;
@@ -54,7 +46,7 @@ if ( !class_exists( 'LP_Order_Post_Type' ) ) {
54
  *
55
  * @param $post_id
56
  */
57
- public function delete_order_data( $post_id ) {
58
  global $wpdb, $post;
59
  if ( get_post_type( $post_id ) != 'lp_order' ) {
60
  return;
@@ -83,36 +75,6 @@ if ( !class_exists( 'LP_Order_Post_Type' ) ) {
83
  ", $post_id );
84
  $wpdb->query( $query );
85
 
86
- $query = $wpdb->prepare( "
87
- SELECT item_id
88
- FROM {$wpdb->prefix}learnpress_user_items
89
- WHERE ref_id = %d AND user_id = %d AND ref_type = %s
90
- ", $post_id, $user_id, LP_ORDER_CPT );
91
- if ( $course_ids = $wpdb->get_col( $query ) ) {
92
- // Delete user course items
93
- $query = $wpdb->prepare( "
94
- DELETE
95
- FROM ui, uim
96
- USING {$wpdb->prefix}learnpress_user_items AS ui
97
- LEFT JOIN {$wpdb->prefix}learnpress_user_itemmeta AS uim ON ui.user_item_id = uim.learnpress_user_item_id
98
- WHERE ref_id = %d AND user_id = %d AND ref_type = %s
99
- ", $post_id, $user_id, LP_ORDER_CPT );
100
- $wpdb->query( $query );
101
-
102
- // Delete other items
103
- $format = array_fill( 0, sizeof( $course_ids ), '%d' );
104
- $args = array_merge( $course_ids, array( $user_id ) );
105
- $query = $wpdb->prepare( "
106
- DELETE
107
- FROM ui, uim
108
- USING {$wpdb->prefix}learnpress_user_items AS ui
109
- LEFT JOIN {$wpdb->prefix}learnpress_user_itemmeta AS uim ON ui.user_item_id = uim.learnpress_user_item_id
110
- WHERE ref_id IN(" . join( ',', $format ) . ") AND user_id = %d
111
- ", $args );
112
- $wpdb->query( $query );
113
-
114
- }
115
-
116
  // delete all data related user order
117
  if ( $user_id ) {
118
  learn_press_delete_user_data( $user_id );
@@ -120,99 +82,18 @@ if ( !class_exists( 'LP_Order_Post_Type' ) ) {
120
  }
121
  }
122
 
123
- /**
124
- * Process when saving order with multi users
125
- *
126
- * @param $post_id
127
- * @param $user_id
128
- */
129
- private function _save_order_multi_users( $post_id, $user_id ) {
130
- global $wpdb;
131
- settype( $user_id, 'array' );
132
- $sql = "
133
- SELECT meta_id, meta_value
134
- FROM {$wpdb->postmeta}
135
- WHERE post_id = %d
136
- AND meta_key = %s
137
- ";
138
- $sql = $wpdb->prepare( $sql, $post_id, '_user_id' );
139
- /**
140
- * A simpler way is remove all meta_key are _user_id and then
141
- * add new user_id as new meta_key but this maybe make our database
142
- * increase the auto-increment each time order is updated
143
- * in case the user_id is not changed
144
- */
145
- if ( $existed = $wpdb->get_results( $sql ) ) {
146
- $cases = array();
147
- $edited = array();
148
- $meta_ids = array();
149
- $remove_ids = array( 0 );
150
- foreach ( $existed as $k => $r ) {
151
- if ( empty( $user_id[$k] ) ) {
152
- $remove_ids[] = $r->meta_id;
153
- continue;
154
- }
155
- $cases[] = $wpdb->prepare( "WHEN meta_id = %d THEN %d", $r->meta_id, $user_id[$k] );
156
- $edited[] = $user_id[$k];
157
- $meta_ids[] = $r->meta_id;
158
- }
159
- $sql = "
160
- UPDATE {$wpdb->postmeta}
161
- SET meta_value = CASE
162
- " . join( "\n", $cases ) . "
163
- ELSE meta_value
164
- END
165
- WHERE meta_id IN(" . join( ', ', $meta_ids ) . ")
166
- AND post_id = %d
167
- AND meta_key = %s
168
- ";
169
- $sql = $wpdb->prepare( $sql, $post_id, '_user_id' );
170
- $wpdb->query( $sql );
171
- $user_id = array_diff( $user_id, $edited );
172
- }
173
- if ( $user_id ) {
174
- $values = array();
175
- foreach ( $user_id as $id ) {
176
- $values[] = sprintf( "(%d, '%s', %d)", $post_id, '_user_id', $id );
177
- }
178
- $sql = "INSERT INTO {$wpdb->postmeta}(post_id, meta_key, meta_value) VALUES" . join( ',', $values );
179
- $wpdb->query( $sql );
180
- }
181
- $sql = "
182
- SELECT meta_id FROM wp_postmeta WHERE meta_id NOT IN(" . join( ',', $remove_ids ) . ") AND post_id = %d AND meta_key = %s GROUP BY meta_value
183
- ";
184
- $sql = $wpdb->prepare( $sql, $post_id, '_user_id' );
185
- $keep_users = $wpdb->get_col( $sql );
186
- if ( $keep_users ) {
187
- $sql = "
188
- DELETE
189
- FROM {$wpdb->postmeta}
190
- WHERE post_id = %d
191
- AND meta_key = %s
192
- AND ( meta_id NOT IN(" . join( ',', $keep_users ) . ") OR meta_value = 0)
193
- ";
194
- $sql = $wpdb->prepare( $sql, $post_id, '_user_id' );
195
- $wpdb->query( $sql );
196
- }
197
- update_post_meta( $post_id, '_lp_multi_users', 'yes', 'yes' );
198
- learn_press_reset_auto_increment( $wpdb->postmeta );
199
- }
200
-
201
  public function save_order( $post_id ) {
202
  global $action;
203
  if ( wp_is_post_revision( $post_id ) )
204
  return;
205
  if ( $action == 'editpost' && get_post_type( $post_id ) == 'lp_order' ) {
206
  remove_action( 'save_post', array( $this, 'save_order' ) );
 
207
  $user_id = learn_press_get_request( 'order-customer' );
208
- $order = learn_press_get_order( $post_id );
 
209
 
210
- if ( $order->is_multi_users() ) {
211
- $this->_save_order_multi_users( $post_id, $user_id );
212
- } else {
213
- update_post_meta( $post_id, '_user_id', $user_id > 0 ? $user_id : 0 );
214
- delete_post_meta( $post_id, '_lp_multi_users' );
215
- }
216
 
217
  $order_statuses = learn_press_get_order_statuses();
218
  $order_statuses = array_keys( $order_statuses );
@@ -221,19 +102,8 @@ if ( !class_exists( 'LP_Order_Post_Type' ) ) {
221
  if ( !in_array( $status, $order_statuses ) ) {
222
  $status = reset( $order_statuses );
223
  }
224
-
225
- global $post;
226
- if ( empty( $post->post_title ) ) {
227
- wp_update_post(
228
- array(
229
- 'ID' => $post_id,
230
- 'post_title' => __( 'Order on', 'learnpress' ) . ' ' . current_time( "l jS F Y h:i:s A" )
231
- )
232
- );
233
- }
234
-
235
- $force = learn_press_get_request( 'trigger-order-action' ) == 'yes';
236
- $order->update_status( $status, $force );
237
  }
238
  }
239
 
@@ -461,17 +331,13 @@ if ( !class_exists( 'LP_Order_Post_Type' ) ) {
461
  $the_order = learn_press_get_order( $post->ID );
462
  switch ( $column ) {
463
  case 'order_student':
464
- if ( $the_order->is_multi_users() ) {
465
- $the_order->print_users();
 
 
 
466
  } else {
467
- if ( $the_order->customer_exists() ) {
468
- $user = learn_press_get_user( $the_order->user_id );
469
- printf( '<a href="user-edit.php?user_id=%d">%s (%s)</a>', $the_order->user_id, $user->user_login, $user->display_name );
470
- ?><?php
471
- printf( '<br /><span>%s</span>', $user->user_email );
472
- } else {
473
- echo $the_order->get_customer_name();
474
- }
475
  }
476
  break;
477
  case 'order_status' :
@@ -571,7 +437,7 @@ if ( !class_exists( 'LP_Order_Post_Type' ) ) {
571
  'rewrite' => array( 'slug' => LP_ORDER_CPT, 'hierarchical' => true, 'with_front' => true ),
572
  'supports' => array(
573
  'title',
574
- 'custom-fields'
575
  )
576
  );
577
  }
26
  add_action( 'admin_init', array( $this, 'remove_box' ) );
27
  add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
28
  add_filter( 'admin_footer', array( $this, 'admin_footer' ) );
 
29
 
30
  $this
31
+ ->add_map_method( 'before_delete', 'delete_order_items' )
32
  ->add_map_method( 'save', 'save_order' );
33
 
34
  parent::__construct( $post_type );
35
  }
36
 
 
 
 
 
 
 
 
37
  public function enqueue_scripts() {
38
  if ( get_post_type() != 'lp_order' ) {
39
  return;
46
  *
47
  * @param $post_id
48
  */
49
+ public function delete_order_items( $post_id ) {
50
  global $wpdb, $post;
51
  if ( get_post_type( $post_id ) != 'lp_order' ) {
52
  return;
75
  ", $post_id );
76
  $wpdb->query( $query );
77
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  // delete all data related user order
79
  if ( $user_id ) {
80
  learn_press_delete_user_data( $user_id );
82
  }
83
  }
84
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  public function save_order( $post_id ) {
86
  global $action;
87
  if ( wp_is_post_revision( $post_id ) )
88
  return;
89
  if ( $action == 'editpost' && get_post_type( $post_id ) == 'lp_order' ) {
90
  remove_action( 'save_post', array( $this, 'save_order' ) );
91
+
92
  $user_id = learn_press_get_request( 'order-customer' );
93
+ //$postdata = array( 'post_status' => $status, 'ID' => $post_id );
94
+ ///wp_update_post( $postdata );
95
 
96
+ update_post_meta( $post_id, '_user_id', $user_id > 0 ? $user_id : 0 );
 
 
 
 
 
97
 
98
  $order_statuses = learn_press_get_order_statuses();
99
  $order_statuses = array_keys( $order_statuses );
102
  if ( !in_array( $status, $order_statuses ) ) {
103
  $status = reset( $order_statuses );
104
  }
105
+ $order = learn_press_get_order( $post_id );
106
+ $order->update_status( $status );
 
 
 
 
 
 
 
 
 
 
 
107
  }
108
  }
109
 
331
  $the_order = learn_press_get_order( $post->ID );
332
  switch ( $column ) {
333
  case 'order_student':
334
+ if ( $the_order->customer_exists() ) {
335
+ $user = learn_press_get_user( $the_order->user_id );
336
+ printf( '<a href="user-edit.php?user_id=%d">%s (%s)</a>', $the_order->user_id, $user->user_login, $user->display_name );
337
+ ?><?php
338
+ printf( '<br /><span>%s</span>', $user->user_email );
339
  } else {
340
+ echo $the_order->get_customer_name();
 
 
 
 
 
 
 
341
  }
342
  break;
343
  case 'order_status' :
437
  'rewrite' => array( 'slug' => LP_ORDER_CPT, 'hierarchical' => true, 'with_front' => true ),
438
  'supports' => array(
439
  'title',
440
+ 'custom-fields'
441
  )
442
  );
443
  }
inc/custom-post-types/quiz.php CHANGED
@@ -27,10 +27,6 @@ if ( !class_exists( 'LP_Quiz_Post_Type' ) ) {
27
  public function __construct( $post_type, $args = '' ) {
28
  add_action( 'admin_head', array( $this, 'enqueue_script' ) );
29
  $this->add_map_method( 'before_delete', 'delete_quiz_questions' );
30
-
31
- $this
32
- ->add_map_method( 'save', 'update_quiz', false );
33
-
34
  add_action( 'init', array( $this, 'init_quiz' ) );
35
 
36
  /**
@@ -46,9 +42,6 @@ if ( !class_exists( 'LP_Quiz_Post_Type' ) ) {
46
  parent::__construct( $post_type, $args );
47
  }
48
 
49
- public function update_quiz( $post_id ) {
50
- }
51
-
52
  public function init_quiz() {
53
  if ( !empty( $_REQUEST['post'] ) && get_post_type( $_REQUEST['post'] ) == LP_QUIZ_CPT ) {
54
  $q = _learn_press_get_quiz_questions( array( $_REQUEST['post'] ) );
@@ -162,18 +155,11 @@ if ( !class_exists( 'LP_Quiz_Post_Type' ) ) {
162
  'options' => array(
163
  // Removed from 2.1.4
164
  //'global' => __( wp_kses( 'Global Setting <a target="_blank" href="' . admin_url( 'admin.php?page=learn-press-settings&tab=courses' ) . '">Go to the setting</a>', array( 'a' => array( 'href' => array(), 'target' => array() ) ) ), 'learnpress' ),
165
- 'show' => __( 'Show', 'learnpress' ),
166
- 'hide' => __( 'Hide', 'learnpress' )
167
  ),
168
  'std' => 'hide'
169
  ),
170
- array(
171
- 'name' => __( 'Show correct answer', 'learnpress' ),
172
- 'id' => "{$prefix}show_result",
173
- 'type' => 'yes_no',
174
- 'desc' => __( 'Show the correct answer in result of the quiz.', 'learnpress' ),
175
- 'std' => 'no'
176
- ),
177
  array(
178
  'name' => __( 'Duration', 'learnpress' ),
179
  'desc' => __( 'Duration of the quiz. Set 0 to disable.', 'learnpress' ),
@@ -212,6 +198,13 @@ if ( !class_exists( 'LP_Quiz_Post_Type' ) ) {
212
  'min' => 0,
213
  'std' => 0
214
  ),
 
 
 
 
 
 
 
215
  array(
216
  'name' => __( 'Show check answer', 'learnpress' ),
217
  'id' => "{$prefix}show_check_answer",
@@ -254,7 +247,7 @@ if ( !class_exists( 'LP_Quiz_Post_Type' ) ) {
254
  if ( LP_QUIZ_CPT != get_post_type() ) return;
255
  ob_start();
256
  ?>
257
- <script>
258
  var form = $('#post');
259
 
260
  form.submit(function (evt) {
@@ -267,7 +260,7 @@ if ( !class_exists( 'LP_Quiz_Post_Type' ) ) {
267
  is_error = true;
268
  }
269
 
270
- /* hook */
271
  is_error = form.triggerHandler('learn_press_question_before_update') === false;
272
 
273
  if (window.learn_press_before_update_quiz_message.length /*true == is_error*/) {
@@ -278,7 +271,7 @@ if ( !class_exists( 'LP_Quiz_Post_Type' ) ) {
278
  return false;
279
  }
280
  });
281
- </script>
282
  <?php
283
  $script = ob_get_clean();
284
  $script = preg_replace( '!</?script>!', '', $script );
@@ -286,21 +279,21 @@ if ( !class_exists( 'LP_Quiz_Post_Type' ) ) {
286
 
287
  ob_start();
288
  ?>
289
- <script type="text/html" id="tmpl-form-quick-add-question">
290
- <div id="lpr-form-quick-add-question" class="lpr-quick-add-form">
291
- <input type="text">
292
- <select class="lpr-question-types lpr-select2" name="lpr_question[type]" id="lpr-quiz-question-type">
293
  <?php if ( $questions = learn_press_question_types() ): ?>
294
  <?php foreach ( $questions as $type => $name ): ?>
295
- <option value="<?php echo $type; ?>"><?php echo $name; ?></option>
296
  <?php endforeach; ?>
297
  <?php endif; ?>
298
- </select>
299
- <button class="button" data-action="add" type="button"><?php _e( 'Add [Enter]', 'learnpress' ); ?></button>
300
- <button data-action="cancel" class="button" type="button"><?php _e( 'Cancel [ESC]', 'learnpress' ); ?></button>
301
- <span class="lpr-ajaxload">...</span>
302
- </div>
303
- </script>
304
  <?php
305
  $js_template = ob_get_clean();
306
  learn_press_enqueue_script( $js_template, true );
@@ -541,31 +534,29 @@ if ( !class_exists( 'LP_Quiz_Post_Type' ) ) {
541
  }
542
  if ( $current_screen->id === LP_QUIZ_CPT && !learn_press_get_item_course_id( $post->ID, $post->post_type ) ) {
543
  ?>
544
- <style type="text/css">
545
- #wp-admin-bar-view {
546
- display: none;
547
- }
548
-
549
- #sample-permalink a {
550
- pointer-events: none;
551
- cursor: default;
552
- text-decoration: none;
553
- color: #666;
554
- }
555
-
556
- #preview-action {
557
- display: none;
558
- }
559
- </style>
560
  <?php
561
  }
562
  }
563
 
564
- public function get_sample_permalink_html( $return, $post_id, $new_title, $new_slug, $post ) {
565
 
566
- return $return;
567
 
568
- }
569
 
570
  public static function instance() {
571
  if ( !self::$_instance ) {
@@ -578,4 +569,4 @@ if ( !class_exists( 'LP_Quiz_Post_Type' ) ) {
578
 
579
  // end LP_Quiz_Post_Type
580
  $quiz_post_type = LP_Quiz_Post_Type::instance();
581
- }
27
  public function __construct( $post_type, $args = '' ) {
28
  add_action( 'admin_head', array( $this, 'enqueue_script' ) );
29
  $this->add_map_method( 'before_delete', 'delete_quiz_questions' );
 
 
 
 
30
  add_action( 'init', array( $this, 'init_quiz' ) );
31
 
32
  /**
42
  parent::__construct( $post_type, $args );
43
  }
44
 
 
 
 
45
  public function init_quiz() {
46
  if ( !empty( $_REQUEST['post'] ) && get_post_type( $_REQUEST['post'] ) == LP_QUIZ_CPT ) {
47
  $q = _learn_press_get_quiz_questions( array( $_REQUEST['post'] ) );
155
  'options' => array(
156
  // Removed from 2.1.4
157
  //'global' => __( wp_kses( 'Global Setting <a target="_blank" href="' . admin_url( 'admin.php?page=learn-press-settings&tab=courses' ) . '">Go to the setting</a>', array( 'a' => array( 'href' => array(), 'target' => array() ) ) ), 'learnpress' ),
158
+ 'show' => __( 'Show', 'learnpress' ),
159
+ 'hide' => __( 'Hide', 'learnpress' )
160
  ),
161
  'std' => 'hide'
162
  ),
 
 
 
 
 
 
 
163
  array(
164
  'name' => __( 'Duration', 'learnpress' ),
165
  'desc' => __( 'Duration of the quiz. Set 0 to disable.', 'learnpress' ),
198
  'min' => 0,
199
  'std' => 0
200
  ),
201
+ array(
202
+ 'name' => __( 'Show correct answer', 'learnpress' ),
203
+ 'id' => "{$prefix}show_result",
204
+ 'type' => 'yes_no',
205
+ 'desc' => __( 'Show the correct answer in result of the quiz.', 'learnpress' ),
206
+ 'std' => 'no'
207
+ ),
208
  array(
209
  'name' => __( 'Show check answer', 'learnpress' ),
210
  'id' => "{$prefix}show_check_answer",
247
  if ( LP_QUIZ_CPT != get_post_type() ) return;
248
  ob_start();
249
  ?>
250
+ <script>
251
  var form = $('#post');
252
 
253
  form.submit(function (evt) {
260
  is_error = true;
261
  }
262
 
263
+ /* hook */
264
  is_error = form.triggerHandler('learn_press_question_before_update') === false;
265
 
266
  if (window.learn_press_before_update_quiz_message.length /*true == is_error*/) {
271
  return false;
272
  }
273
  });
274
+ </script>
275
  <?php
276
  $script = ob_get_clean();
277
  $script = preg_replace( '!</?script>!', '', $script );
279
 
280
  ob_start();
281
  ?>
282
+ <script type="text/html" id="tmpl-form-quick-add-question">
283
+ <div id="lpr-form-quick-add-question" class="lpr-quick-add-form">
284
+ <input type="text">
285
+ <select class="lpr-question-types lpr-select2" name="lpr_question[type]" id="lpr-quiz-question-type">
286
  <?php if ( $questions = learn_press_question_types() ): ?>
287
  <?php foreach ( $questions as $type => $name ): ?>
288
+ <option value="<?php echo $type; ?>"><?php echo $name; ?></option>
289
  <?php endforeach; ?>
290
  <?php endif; ?>
291
+ </select>
292
+ <button class="button" data-action="add" type="button"><?php _e( 'Add [Enter]', 'learnpress' ); ?></button>
293
+ <button data-action="cancel" class="button" type="button"><?php _e( 'Cancel [ESC]', 'learnpress' ); ?></button>
294
+ <span class="lpr-ajaxload">...</span>
295
+ </div>
296
+ </script>
297
  <?php
298
  $js_template = ob_get_clean();
299
  learn_press_enqueue_script( $js_template, true );
534
  }
535
  if ( $current_screen->id === LP_QUIZ_CPT && !learn_press_get_item_course_id( $post->ID, $post->post_type ) ) {
536
  ?>
537
+ <style type="text/css">
538
+ #wp-admin-bar-view {
539
+ display: none;
540
+ }
541
+ #sample-permalink a {
542
+ pointer-events: none;
543
+ cursor: default;
544
+ text-decoration: none;
545
+ color: #666;
546
+ }
547
+ #preview-action {
548
+ display: none;
549
+ }
550
+ </style>
 
 
551
  <?php
552
  }
553
  }
554
 
555
+ public function get_sample_permalink_html( $return, $post_id , $new_title, $new_slug, $post ) {
556
 
557
+ return $return;
558
 
559
+ }
560
 
561
  public static function instance() {
562
  if ( !self::$_instance ) {
569
 
570
  // end LP_Quiz_Post_Type
571
  $quiz_post_type = LP_Quiz_Post_Type::instance();
572
+ }
inc/debug.php CHANGED
@@ -6,10 +6,3 @@
6
  /**
7
  * use http://example.com?debug=yes to execute the code in this file
8
  */
9
-
10
- add_filter( 'wp_head', function ( $url ) {
11
- global $wp, $wp_rewrite;
12
- flush_rewrite_rules();
13
- learn_press_debug($wp, $wp_rewrite);
14
- } );
15
-
6
  /**
7
  * use http://example.com?debug=yes to execute the code in this file
8
  */
 
 
 
 
 
 
 
inc/emails/class-lp-email-enrolled-course-admin.php DELETED
@@ -1,172 +0,0 @@
1
- <?php
2
- /**
3
- * Class LP_Email_Enrolled_Course_Admin
4
- *
5
- * @author ThimPress
6
- * @package LearnPress/Classes
7
- * @version 1.0
8
- */
9
-
10
- defined( 'ABSPATH' ) || exit();
11
-
12
- if ( ! class_exists( 'LP_Email_Enrolled_Course_Admin' ) ) {
13
-
14
- class LP_Email_Enrolled_Course_Admin extends LP_Email {
15
-
16
-
17
- /**
18
- * LP_Email_Enrolled_Course_Admin constructor.
19
- */
20
- public function __construct () {
21
- $this->id = 'enrolled_course_admin';
22
- $this->title = __( 'Enrolled course admin', 'learnpress' );
23
-
24
- $this->template_html = 'emails/enrolled-course-admin.php';
25
- $this->template_plain = 'emails/plain/enrolled-course-admin.php';
26
-
27
- $this->default_subject = __( '[{{site_title}}] ({{course_name}}) has been enrolled by {{custom_name}}', 'learnpress' );
28
- $this->default_heading = __( 'Course has been enrolled', 'learnpress' );
29
-
30
- $this->support_variables = array(
31
- '{{site_url}}',
32
- '{{site_title}}',
33
- '{{site_admin_email}}',
34
- '{{site_admin_name}}',
35
- '{{login_url}}',
36
- '{{header}}',
37
- '{{footer}}',
38
- '{{email_heading}}',
39
- '{{footer_text}}',
40
- '{{course_id}}',
41
- '{{course_name}}',
42
- '{{course_url}}',
43
- '{{user_id}}',
44
- '{{user_name}}',
45
- '{{user_email}}',
46
- '{{user_profile_url}}',
47
- '{{custom_name}}',
48
- '{{custom_profile_url}}',
49
- '{{custom_slug}}',
50
- '{{start_time}}'
51
- );
52
-
53
- //$this->email_text_message_description = sprintf( '%s {{course_id}}, {{course_title}}, {{course_url}}, {{user_email}}, {{user_name}}, {{user_profile_url}}', __( 'Shortcodes', 'learnpress' ) );
54
-
55
- add_action( 'learn_press_user_enrolled_course_notification', array( $this, 'get_users_to_send' ), 99, 3 );
56
-
57
- parent::__construct();
58
- }
59
-
60
- public function admin_options ( $settings_class ) {
61
- $view = learn_press_get_admin_view( 'settings/emails/enrolled-course-admin.php' );
62
- include_once $view;
63
- }
64
-
65
- public function get_users_to_send ( $course_id, $user_id, $user_course_id ) {
66
-
67
- if ( empty( $course_id ) || empty( $user_id ) || empty( $user_course_id ) ) {
68
- return;
69
- }
70
-
71
- $all_users_id = array();
72
-
73
- if ( LP()->settings->get( 'emails_enrolled_course_admin.send_admins' ) === 'yes' ) {
74
-
75
- // Get all users with role admin
76
- $admins = get_users( array(
77
- 'role' => 'administrator'
78
- ) );
79
-
80
- foreach ( $admins as $admin ) {
81
- $all_users_id[] = $admin->ID;
82
- }
83
- }
84
-
85
- if ( ! in_array( $user_id, $all_users_id ) ) {
86
- $all_users_id[] = $user_id;
87
- }
88
-
89
- $all_users_id = apply_filters( 'learn_press_user_admin_send_mail_enrolled_course', $all_users_id, $course_id, $user_id, $user_course_id );
90
- foreach ( $all_users_id as $user ) {
91
- $this->trigger( $course_id, $user, $user_course_id );
92
- }
93
-
94
- }
95
-
96
- public function trigger ( $course_id, $user_id, $user_course_id ) {
97
-
98
- if ( ! $this->enable ) {
99
- return;
100
- }
101
-
102
- global $wpdb;
103
-
104
- $user_course_data = $wpdb->get_row(
105
- $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}learnpress_user_items WHERE user_item_id = %d", $user_course_id )
106
- );
107
- $start_time = '';
108
- $customer = array(
109
- 'name' => '',
110
- 'slug' => '',
111
- 'profile_url' => '',
112
- );
113
-
114
- if ( ! $user_course_data ) {
115
- return;
116
- }
117
- if ( ! empty( $user_course_data->start_time ) ) {
118
- $start_time = $user_course_data->start_time;
119
-
120
- // Get data customer
121
- $data = get_userdata( $user_course_data->user_id );
122
- if ( ! empty( $data ) && ! empty( $data->data ) ) {
123
- $customer['name'] = $data->data->display_name;
124
- $customer['slug'] = $data->data->user_login;
125
- $customer['profile_url'] = learn_press_user_profile_link( $data->ID );
126
- }
127
- }
128
-
129
-
130
- $format = $this->email_format == 'plain_text' ? 'plain' : 'html';
131
- $course = learn_press_get_course( $course_id );
132
- $user = learn_press_get_user( $user_id );
133
-
134
- $this->object = $this->get_common_template_data(
135
- $format,
136
- array(
137
- 'course_id' => $course_id,
138
- 'course_name' => $course->get_title(),
139
- 'course_url' => get_the_permalink( $course_id ),
140
- 'user_id' => $user_id,
141
- 'user_name' => learn_press_get_profile_display_name( $user ),
142
- 'user_email' => $user->user_email,
143
- 'user_profile_url' => learn_press_user_profile_link( $user->id ),
144
- 'start_time' => $start_time,
145
- 'custom_name' => $customer['name'],
146
- 'custom_profile_url' => $customer['custom_profile_url'],
147
- 'custom_slug' => $customer['slug']
148
- )
149
- );
150
-
151
- $this->variables = $this->data_to_variables( $this->object );
152
-
153
- $this->object['course'] = $course;
154
- $this->object['user'] = $user;
155
-
156
- $this->recipient = $user->user_email;
157
-
158
- $return = $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
159
-
160
- return $return;
161
-
162
- }
163
-
164
- public function get_template_data ( $format = 'plain' ) {
165
- return $this->object;
166
- }
167
-
168
-
169
- }
170
-
171
- }
172
- return new LP_Email_Enrolled_Course_Admin();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/emails/class-lp-email-update-course.php DELETED
@@ -1,130 +0,0 @@
1
- <?php
2
- /**
3
- * Class LP_Email_Update_Course
4
- *
5
- * @author ThimPress
6
- * @package LearnPress/Classes
7
- * @version 1.0
8
- */
9
-
10
- defined( 'ABSPATH' ) || exit();
11
-
12
- if ( ! class_exists( 'LP_Email_Update_Course' ) ) {
13
-
14
- class LP_Email_Update_Course extends LP_Email {
15
-
16
- public $object;
17
-
18
- public function __construct () {
19
-
20
- $this->id = 'update_course';
21
- $this->title = __( 'Update course', 'learnpress' );
22
-
23
- $this->template_html = 'emails/update-course.php';
24
- $this->template_plain = 'emails/plain/update-course.php';
25
-
26
- $this->default_subject = __( '[{{site_title}}] The course ({{course_name}}) has just been updated.', 'learnpress' );
27
- $this->default_heading = __( 'Update course', 'learnpress' );
28
-
29
- $this->support_variables = array(
30
- '{{site_url}}',
31
- '{{site_title}}',
32
- // '{{site_admin_email}}',
33
- // '{{site_admin_name}}',
34
- '{{login_url}}',
35
- '{{header}}',
36
- '{{footer}}',
37
- '{{email_heading}}',
38
- '{{footer_text}}',
39
- '{{course_id}}',
40
- '{{course_name}}',
41
- '{{course_url}}',
42
- '{{user_id}}',
43
- '{{user_name}}',
44
- '{{user_email}}',
45
- '{{user_profile_url}}'
46
- );
47
-
48
- add_action( 'post_updated', array( $this, 'update_course' ), 10, 2 );
49
-
50
- parent::__construct();
51
-
52
- }
53
-
54
- public function admin_options ( $settings_class ) {
55
- $view = learn_press_get_admin_view( 'settings/emails/update-course.php' );
56
- include_once $view;
57
- }
58
-
59
- public function update_course ( $post_id, $post ) {
60
-
61
- if ( empty( $post_id ) || empty( $post ) ) {
62
- return;
63
- }
64
- $post_type = $post->post_type;
65
- if ( empty( $post_type ) || $post_type != 'lp_course' ) {
66
- return;
67
- }
68
- global $wpdb;
69
-
70
- $query = $wpdb->prepare( "
71
- SELECT pmt.meta_value
72
- FROM {$wpdb->posts} o
73
- INNER JOIN {$wpdb->learnpress_order_items} oi ON oi.order_id = o.ID
74
- INNER JOIN {$wpdb->learnpress_order_itemmeta} oim ON oim.learnpress_order_item_id = oi.order_item_id
75
- INNER JOIN {$wpdb->prefix}postmeta pmt ON pmt.meta_key = %s and pmt.post_id = oi.order_id
76
- AND oim.meta_key = %s AND oim.meta_value = %d
77
- WHERE o.post_status = %s
78
- ", '_user_id', '_course_id', $post_id, 'lp-completed' );
79
-
80
- $users_enrolled = $wpdb->get_results( $query );
81
- foreach ( $users_enrolled as $user ) {
82
-
83
- if ( ! empty( $user ) && !empty($user->meta_value) ) {
84
- $this->trigger( $post_id, $user->meta_value );
85
- }
86
- }
87
- }
88
-
89
- public function trigger ( $course_id, $user_id ) {
90
-
91
- if (empty($course_id) || empty($user_id)) {
92
- return;
93
- }
94
- $format = $this->email_format == 'plain_text' ? 'plain' : 'html';
95
- $course = learn_press_get_course( $course_id );
96
- $user = learn_press_get_user( $user_id );
97
- $is_send_mail = apply_filters( 'learn_press_has_send_mail_update_course', $course->send_mail_update_course, $course, $user );
98
-
99
- if (empty($is_send_mail) || $is_send_mail !== 'yes') {
100
- return;
101
- }
102
- $this->object = $this->get_common_template_data(
103
- $format,
104
- array(
105
- 'course_id' => $course_id,
106
- 'course_name' => $course->get_title(),
107
- 'course_url' => get_the_permalink( $course_id ),
108
- 'user_id' => $user_id,
109
- 'user_name' => learn_press_get_profile_display_name( $user ),
110
- 'user_email' => $user->user_email,
111
- 'user_profile_url' => learn_press_user_profile_link( $user->id )
112
- )
113
- );
114
-
115
- $this->variables = $this->data_to_variables( $this->object );
116
- $this->object['course'] = $course;
117
- $this->object['user'] = $user;
118
- $this->recipient = $user->user_email;
119
- $return = $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
120
-
121
- return $return;
122
- }
123
-
124
- public function get_template_data ( $format = 'plain' ) {
125
- return $this->object;
126
- }
127
- }
128
- }
129
-
130
- return new LP_Email_Update_Course();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/emails/class-lp-email-user-order-changed-status.php DELETED
@@ -1,109 +0,0 @@
1
- <?php
2
- /**
3
- * Class LP_Email_User_Order_Changed_Status
4
- *
5
- * @author ThimPress
6
- * @package LearnPress/Classes
7
- * @version 1.0
8
- */
9
-
10
- if ( ! class_exists( 'LP_Email_User_Order_Changed_Status' ) ) {
11
-
12
- class LP_Email_User_Order_Changed_Status extends LP_Email {
13
-
14
- /**
15
- * LP_Email_User_Order_Changed_Status constructor.
16
- */
17
- public function __construct () {
18
-
19
- $this->id = 'user_order_changed_status';
20
- $this->title = __( 'User order changed status', 'learnpress' );
21
- $this->template_html = 'emails/user-order-changed-status.php';
22
- $this->template_plain = 'emails/plain/user-order-changed-status.php';
23
- $this->default_subject = __( 'Your order {{order_date}} has just been changed status', 'learnpress' );
24
- $this->default_heading = __( 'Your order {{order_number}} has just been changed status', 'learnpress' );
25
- $this->support_variables = array(
26
- '{{site_url}}',
27
- '{{site_title}}',
28
- '{{site_admin_email}}',
29
- '{{site_admin_name}}',
30
- '{{login_url}}',
31
- '{{header}}',
32
- '{{footer}}',
33
- '{{email_heading}}',
34
- '{{footer_text}}',
35
- '{{order_id}}',
36
- '{{order_user_id}}',
37
- '{{order_user_name}}',
38
- '{{order_status}}',
39
- '{{order_items_table}}',
40
- '{{order_detail_url}}',
41
- '{{order_number}}',
42
- );
43
-
44
- add_action( 'learn_press_update_order_status', array( $this, 'update_order_status' ), 10, 2 );
45
- parent::__construct();
46
- }
47
-
48
- public function admin_options ( $settings_class ) {
49
- $view = learn_press_get_admin_view( 'settings/emails/user-order-changed-status.php' );
50
- include_once $view;
51
- }
52
-
53
- public function update_order_status ( $new_status, $order_id ) {
54
-
55
- if ( empty( $new_status ) || $new_status == 'completed' || empty( $order_id ) ) {
56
- return;
57
- }
58
-
59
- $this->trigger( $new_status, $order_id );
60
- }
61
-
62
- public function trigger ( $new_status, $order_id ) {
63
-
64
- if ( ! $this->enable ) {
65
- return;
66
- }
67
-
68
- $format = $this->email_format == 'plain_text' ? 'plain' : 'html';
69
- $order = learn_press_get_order( $order_id );
70
-
71
- $this->object = $this->get_common_template_data(
72
- $format,
73
- array(
74
- 'order_id' => $order_id,
75
- 'order_user_id' => $order->user_id,
76
- 'order_user_name' => $order->get_user_name(),
77
- 'order_items_table' => learn_press_get_template_content( 'emails/' . ( $format == 'plain' ? 'plain/' : '' ) . 'order-items-table.php', array( 'order' => $order ) ),
78
- 'order_detail_url' => learn_press_user_profile_link( $order->user_id, 'orders' ),
79
- 'order_number' => $order->get_order_number(),
80
- 'order_subtotal' => $order->get_formatted_order_subtotal(),
81
- 'order_total' => $order->get_formatted_order_total(),
82
- 'order_date' => date_i18n( get_option( 'date_format' ), strtotime( $order->order_date ) ),
83
- 'order_status' => $new_status
84
- )
85
- );
86
-
87
- $this->variables = $this->data_to_variables( $this->object );
88
-
89
- $this->object['order'] = $order;
90
-
91
- $return = $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
92
-
93
- return $return;
94
- }
95
-
96
- public function get_recipient () {
97
- $user = learn_press_get_user( $this->object['order']->user_id );
98
- $this->recipient = $user->user_email;
99
-
100
- return parent::get_recipient();
101
- }
102
-
103
- public function get_template_data ( $format = 'plain' ) {
104
- return $this->object;
105
- }
106
- }
107
- }
108
-
109
- return new LP_Email_User_Order_Changed_Status();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/emails/class-lp-email-user-order-completed.php CHANGED
@@ -10,7 +10,7 @@
10
 
11
  defined( 'ABSPATH' ) || exit();
12
 
13
- if ( !class_exists( 'LP_Email_User_Order_Completed' ) ) {
14
 
15
  class LP_Email_User_Order_Completed extends LP_Email {
16
  /**
@@ -56,17 +56,10 @@ if ( !class_exists( 'LP_Email_User_Order_Completed' ) ) {
56
  include_once $view;
57
  }
58
 
59
- /**
60
- * Trigger email to send to users
61
- *
62
- * @param $order_id
63
- *
64
- * @return bool
65
- */
66
  public function trigger( $order_id ) {
67
 
68
  if ( !$this->enable ) {
69
- return false;
70
  }
71
 
72
  $format = $this->email_format == 'plain_text' ? 'plain' : 'html';
@@ -87,37 +80,33 @@ if ( !class_exists( 'LP_Email_User_Order_Completed' ) ) {
87
  )
88
  );
89
 
90
- if ( $order->is_multi_users() ) {
91
- if ( $recipient = $order->get_user_data() ) {
92
 
93
- foreach ( $recipient as $uid => $data ) {
94
- $this->object['order_user_id'] = $uid;
95
- $this->object['order_user_name'] = $data->name;
96
- $this->object['order_detail_url'] = learn_press_user_profile_link( $uid, 'orders' );
97
- $this->variables = $this->data_to_variables( $this->object );
98
- $r = $this->send( $data->email, $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
99
- }
100
- }
101
- } else {
102
- $this->variables = $this->data_to_variables( $this->object );
103
- $this->object['order'] = $order;
104
- $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
105
- }
106
- return false;
107
  }
108
 
109
- /**
110
- * Get email recipients
111
- *
112
- * @return mixed|void
113
- */
114
  public function get_recipient() {
115
- if ( $order = $this->object['order'] ) {
116
- $this->recipient = $order->get_user_email();
117
- }
118
- return parent::get_recipient();
119
  }
 
 
 
 
 
 
120
 
 
 
 
 
 
 
121
  /**
122
  * @param string $format
123
  *
@@ -125,8 +114,36 @@ if ( !class_exists( 'LP_Email_User_Order_Completed' ) ) {
125
  */
126
  public function get_template_data( $format = 'plain' ) {
127
  return $this->object;
128
-
 
 
 
 
 
 
129
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  }
131
  }
132
 
10
 
11
  defined( 'ABSPATH' ) || exit();
12
 
13
+ if(!class_exists('LP_Email_User_Order_Completed')) {
14
 
15
  class LP_Email_User_Order_Completed extends LP_Email {
16
  /**
56
  include_once $view;
57
  }
58
 
 
 
 
 
 
 
 
59
  public function trigger( $order_id ) {
60
 
61
  if ( !$this->enable ) {
62
+ return;
63
  }
64
 
65
  $format = $this->email_format == 'plain_text' ? 'plain' : 'html';
80
  )
81
  );
82
 
83
+ $this->variables = $this->data_to_variables( $this->object );
 
84
 
85
+ $this->object['order'] = $order;
86
+
87
+ $return = $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
88
+
89
+ return $return;
 
 
 
 
 
 
 
 
 
90
  }
91
 
 
 
 
 
 
92
  public function get_recipient() {
93
+ $user = learn_press_get_user( $this->object['order']->user_id );
94
+ $this->recipient = $user->user_email;
95
+ return parent::get_recipient(); // TODO: Change the autogenerated stub
 
96
  }
97
+ /*
98
+ public function get_content_html() {
99
+ ob_start();
100
+ learn_press_get_template( $this->template_html, $this->get_template_data( 'html' ) );
101
+ return ob_get_clean();
102
+ }
103
 
104
+ public function get_content_plain() {
105
+ ob_start();
106
+ learn_press_get_template( $this->template_plain, $this->get_template_data( 'plain' ) );
107
+ return ob_get_clean();
108
+ }
109
+ */
110
  /**
111
  * @param string $format
112
  *
114
  */
115
  public function get_template_data( $format = 'plain' ) {
116
  return $this->object;
117
+ return array(
118
+ 'email_heading' => $this->get_heading(),
119
+ 'footer_text' => $this->get_footer_text(),
120
+ 'site_title' => $this->get_blogname(),
121
+ 'plain_text' => $format == 'plain',
122
+ 'order' => $this->object['order']
123
+ );
124
  }
125
+ /*
126
+ public function _prepare_content_text_message() {
127
+ $order = isset( $this->object['order'] ) ? $this->object['order'] : null;
128
+ if ( $order ) {
129
+ $this->text_search = array(
130
+ "/\{\{order\_number\}\}/",
131
+ "/\{\{order\_view\_url\}\}/",
132
+ "/\{\{order\_total\}\}/",
133
+ "/\{\{user\_email\}\}/",
134
+ "/\{\{user\_name\}\}/",
135
+ "/\{\{user\_profile\_url\}\}/",
136
+ );
137
+ $this->text_replace = array(
138
+ $order->get_order_number(),
139
+ $order->get_view_order_url(),
140
+ $order->get_formatted_order_total(),
141
+ $order->get_user( 'user_email' ),
142
+ $order->get_customer_name(),
143
+ learn_press_user_profile_link( $order->user_id )
144
+ );
145
+ }
146
+ }*/
147
  }
148
  }
149
 
inc/emails/class-lp-email.php CHANGED
@@ -565,30 +565,18 @@ class LP_Email {
565
  }
566
 
567
  public function send( $to, $subject, $message, $headers, $attachments ) {
568
- LP_Debug::instance()->add( $to );
569
- LP_Debug::instance()->add( func_get_args() );
570
 
571
  add_filter( 'wp_mail_from', array( $this, 'get_from_address' ) );
572
  add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );
573
  add_filter( 'wp_mail_content_type', array( $this, 'get_content_format' ) );
574
- $return = false;
575
  $message = apply_filters( 'learn_press_mail_content', $this->apply_style_inline( $message ), $this );
576
- if ( !is_array( $to ) ) {
577
- $to = preg_split( '~\s?,\s?~', $to );
578
- }
579
- $separated = apply_filters( 'learn_press_email_to_separated', false, $to, $this );
580
- if ( !$separated ) {
581
- $return = wp_mail( $to, $subject, $message, $headers, $attachments );
582
- } else {
583
- if ( is_array( $to ) ) {
584
- foreach ( $to as $t ) {
585
- $return = wp_mail( $t, $subject, $message, $headers, $attachments );
586
- }
587
- }
588
- }
589
  remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ) );
590
  remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );
591
  remove_filter( 'wp_mail_content_type', array( $this, 'get_content_format' ) );
 
592
  return $return;
593
  }
594
 
565
  }
566
 
567
  public function send( $to, $subject, $message, $headers, $attachments ) {
 
 
568
 
569
  add_filter( 'wp_mail_from', array( $this, 'get_from_address' ) );
570
  add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );
571
  add_filter( 'wp_mail_content_type', array( $this, 'get_content_format' ) );
572
+
573
  $message = apply_filters( 'learn_press_mail_content', $this->apply_style_inline( $message ), $this );
574
+ $return = wp_mail( $to, $subject, $message, $headers, $attachments );
575
+
 
 
 
 
 
 
 
 
 
 
 
576
  remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ) );
577
  remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );
578
  remove_filter( 'wp_mail_content_type', array( $this, 'get_content_format' ) );
579
+
580
  return $return;
581
  }
582
 
inc/lesson/lp-lesson-functions.php CHANGED
@@ -29,17 +29,11 @@ if ( !function_exists( 'learn_press_get_only_content_permalink' ) ) {
29
  }
30
  }
31
 
32
- function learn_press_lesson_comment_form( $lesson_id, $course_id, $content_only ) {
33
  global $post;
34
  if ( get_post_type( $lesson_id ) != LP_LESSON_CPT ) {
35
  return;
36
  }
37
-
38
- $user = learn_press_get_current_user();
39
- if ( !$user->has_enrolled_course( $course_id ) ) {
40
- return;
41
- }
42
-
43
  $post = get_post( $lesson_id );
44
  setup_postdata( $post );
45
  if ( comments_open() || get_comments_number() ) {
@@ -65,24 +59,12 @@ if (!function_exists('lesson_comment_reply_link')) {
65
  /**
66
  * Add class css js-action to element cancel comment reply link
67
  */
68
- add_filter( 'cancel_comment_reply_link', 'lesson_cancel_comment_reply_link', 10, 3 );
69
-
70
- if ( !function_exists( 'lesson_cancel_comment_reply_link' ) ) {
71
- function lesson_cancel_comment_reply_link( $formatted_link, $link, $text ) {
72
 
73
- $formatted_link = str_replace( 'cancel-comment-reply-link"', 'cancel-comment-reply-link" class="js-action"', $formatted_link );
74
- return $formatted_link;
75
- }
76
- }
77
 
78
- /**
79
- * Remove data section after remove lesson
80
- */
81
- add_action( 'delete_post', 'learn_press_lesson_before_delete_post', 10, 2 );
82
- function learn_press_lesson_before_delete_post( $post_id, $force=false ) {
83
- global $wpdb;
84
- if( 'lp_lesson' === get_post_type( $post_id ) ) {
85
- $sql = 'DELETE FROM `'.$wpdb->prefix.'learnpress_section_items` WHERE `item_id` = '.$post_id.' AND `item_type` = "lp_lesson"';
86
- $wpdb->query($sql);
87
- }
88
- }
29
  }
30
  }
31
 
32
+ function learn_press_lesson_comment_form( $lesson_id ) {
33
  global $post;
34
  if ( get_post_type( $lesson_id ) != LP_LESSON_CPT ) {
35
  return;
36
  }
 
 
 
 
 
 
37
  $post = get_post( $lesson_id );
38
  setup_postdata( $post );
39
  if ( comments_open() || get_comments_number() ) {
59
  /**
60
  * Add class css js-action to element cancel comment reply link
61
  */
62
+ add_filter('cancel_comment_reply_link', 'lesson_cancel_comment_reply_link', 10, 3);
 
 
 
63
 
64
+ if (!function_exists('lesson_cancel_comment_reply_link')) {
65
+ function lesson_cancel_comment_reply_link($formatted_link, $link, $text) {
 
 
66
 
67
+ $formatted_link = str_replace('cancel-comment-reply-link"', 'cancel-comment-reply-link" class="js-action"', $formatted_link);
68
+ return $formatted_link;
69
+ }
70
+ }
 
 
 
 
 
 
 
inc/libraries/meta-box/inc/fields/checkbox-list.php CHANGED
@@ -2,7 +2,7 @@
2
  // Prevent loading this file directly
3
  defined( 'ABSPATH' ) || exit;
4
 
5
- if ( !class_exists( 'RWMB_Checkbox_List_Field' ) ) {
6
  class RWMB_Checkbox_List_Field extends RWMB_Field {
7
  /**
8
  * Get field HTML
@@ -13,11 +13,6 @@ if ( !class_exists( 'RWMB_Checkbox_List_Field' ) ) {
13
  * @return string
14
  */
15
  static function html( $meta, $field ) {
16
- if ( empty( $field['multiple'] ) || ( $field['multiple'] == true ) || ( $field['multiple'] == 'yes' ) ) {
17
- $multiple = true;
18
- } else {
19
- $multiple = false;
20
- }
21
  $meta = (array) $meta;
22
  $html = array();
23
  $tpl = '<label><input type="checkbox" class="rwmb-checkbox-list" name="%s" value="%s"%s> %s</label>';
@@ -25,7 +20,7 @@ if ( !class_exists( 'RWMB_Checkbox_List_Field' ) ) {
25
  foreach ( $field['options'] as $value => $label ) {
26
  $html[] = sprintf(
27
  $tpl,
28
- sprintf( '%s%s', $field['field_name'], $multiple ? '[]' : '' ),
29
  $value,
30
  checked( in_array( $value, $meta ), 1, false ),
31
  $label
@@ -52,7 +47,7 @@ if ( !class_exists( 'RWMB_Checkbox_List_Field' ) ) {
52
  */
53
  static function meta( $post_id, $saved, $field ) {
54
  $meta = get_post_meta( $post_id, $field['id'], $field['clone'] );
55
- $meta = ( !$saved && '' === $meta || array() === $meta ) ? $field['std'] : $meta;
56
  $meta = array_map( 'esc_attr', (array) $meta );
57
 
58
  return $meta;
@@ -71,7 +66,7 @@ if ( !class_exists( 'RWMB_Checkbox_List_Field' ) ) {
71
  * @param $field
72
  */
73
  static function save( $new, $old, $post_id, $field ) {
74
- if ( !$field['clone'] ) {
75
  parent::save( $new, $old, $post_id, $field );
76
 
77
  return;
@@ -94,7 +89,7 @@ if ( !class_exists( 'RWMB_Checkbox_List_Field' ) ) {
94
  static function normalize_field( $field ) {
95
  $field['multiple'] = true;
96
  $field['field_name'] = $field['id'];
97
- if ( !$field['clone'] ) {
98
  $field['field_name'] .= '[]';
99
  }
100
 
2
  // Prevent loading this file directly
3
  defined( 'ABSPATH' ) || exit;
4
 
5
+ if ( ! class_exists( 'RWMB_Checkbox_List_Field' ) ) {
6
  class RWMB_Checkbox_List_Field extends RWMB_Field {
7
  /**
8
  * Get field HTML
13
  * @return string
14
  */
15
  static function html( $meta, $field ) {
 
 
 
 
 
16
  $meta = (array) $meta;
17
  $html = array();
18
  $tpl = '<label><input type="checkbox" class="rwmb-checkbox-list" name="%s" value="%s"%s> %s</label>';
20
  foreach ( $field['options'] as $value => $label ) {
21
  $html[] = sprintf(
22
  $tpl,
23
+ $field['field_name'],
24
  $value,
25
  checked( in_array( $value, $meta ), 1, false ),
26
  $label
47
  */
48
  static function meta( $post_id, $saved, $field ) {
49
  $meta = get_post_meta( $post_id, $field['id'], $field['clone'] );
50
+ $meta = ( ! $saved && '' === $meta || array() === $meta ) ? $field['std'] : $meta;
51
  $meta = array_map( 'esc_attr', (array) $meta );
52
 
53
  return $meta;
66
  * @param $field
67
  */
68
  static function save( $new, $old, $post_id, $field ) {
69
+ if ( ! $field['clone'] ) {
70
  parent::save( $new, $old, $post_id, $field );
71
 
72
  return;
89
  static function normalize_field( $field ) {
90
  $field['multiple'] = true;
91
  $field['field_name'] = $field['id'];
92
+ if ( ! $field['clone'] ) {
93
  $field['field_name'] .= '[]';
94
  }
95
 
inc/libraries/meta-box/inc/fields/datetime.php CHANGED
@@ -11,7 +11,7 @@ if ( ! class_exists( 'RWMB_Datetime_Field' ) ) {
11
  */
12
  static function admin_enqueue_scripts() {
13
  $url = RWMB_CSS_URL . 'jqueryui';
14
- wp_enqueue_style( 'jquery-ui-timepicker', "{$url}/jquery-ui-timepicker-addon.css", array( /*'jquery-ui-datepicker', 'jquery-ui-slider'*/ ), '0.9.7' );
15
 
16
  wp_register_script( 'jquery-ui-timepicker', RWMB_JS_URL . 'jqueryui/jquery-ui-timepicker-addon.js', array( 'jquery-ui-datepicker', 'jquery-ui-slider' ), '0.9.7', true );
17
 
11
  */
12
  static function admin_enqueue_scripts() {
13
  $url = RWMB_CSS_URL . 'jqueryui';
14
+ wp_enqueue_style( 'jquery-ui-timepicker', "{$url}/jquery-ui-timepicker-addon.css", array( 'jquery-ui-datepicker', 'jquery-ui-slider' ), '0.9.7' );
15
 
16
  wp_register_script( 'jquery-ui-timepicker', RWMB_JS_URL . 'jqueryui/jquery-ui-timepicker-addon.js', array( 'jquery-ui-datepicker', 'jquery-ui-slider' ), '0.9.7', true );
17
 
inc/{admin/meta-boxes → libraries/meta-box/inc/fields}/duration.php RENAMED
@@ -39,7 +39,7 @@ if ( !class_exists( 'RWMB_Duration_Field' ) ) {
39
  ) . sprintf(
40
  '<select name="%s[]" id="%s">%s</select>',
41
  $field['field_name'],
42
- empty( $field['clone'] ) ? $field['id'] . '_select' : '',
43
  $html_option
44
  );
45
  }
@@ -52,24 +52,11 @@ if ( !class_exists( 'RWMB_Duration_Field' ) ) {
52
  * @return array
53
  */
54
  static function normalize_field( $field ) {
55
- return self::normalize( $field );
56
- }
57
-
58
- /**
59
- * Normalize parameters for field
60
- *
61
- * @param array $field
62
- *
63
- * @return array
64
- */
65
- static function normalize( $field ) {
66
- if ( is_callable( 'parent::normalize' ) ) {
67
- $field = parent::normalize( $field );
68
- }
69
  $field = wp_parse_args( $field, array(
70
  'step' => 1,
71
  'min' => 0,
72
  ) );
 
73
  return $field;
74
  }
75
 
39
  ) . sprintf(
40
  '<select name="%s[]" id="%s">%s</select>',
41
  $field['field_name'],
42
+ empty( $field['clone'] ) ? $field['id'].'_select' : '',
43
  $html_option
44
  );
45
  }
52
  * @return array
53
  */
54
  static function normalize_field( $field ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  $field = wp_parse_args( $field, array(
56
  'step' => 1,
57
  'min' => 0,
58
  ) );
59
+
60
  return $field;
61
  }
62
 
inc/libraries/meta-box/inc/fields/time.php CHANGED
@@ -2,7 +2,7 @@
2
  // Prevent loading this file directly
3
  defined( 'ABSPATH' ) || exit;
4
 
5
- if ( !class_exists( 'RWMB_Time_Field' ) ) {
6
  class RWMB_Time_Field extends RWMB_Field {
7
  /**
8
  * Enqueue scripts and styles
@@ -11,7 +11,7 @@ if ( !class_exists( 'RWMB_Time_Field' ) ) {
11
  */
12
  static function admin_enqueue_scripts() {
13
  $url = RWMB_CSS_URL . 'jqueryui';
14
- wp_enqueue_style( 'jquery-ui-timepicker', "{$url}/jquery-ui-timepicker-addon.css", array( /*'jquery-ui-datepicker', 'jquery-ui-slider'*/ ), '0.9.7' );
15
 
16
  $url = RWMB_JS_URL . 'jqueryui';
17
  wp_register_script( 'jquery-ui-timepicker', "{$url}/jquery-ui-timepicker-addon.js", array( 'jquery-ui-datepicker', 'jquery-ui-slider' ), '0.9.7', true );
2
  // Prevent loading this file directly
3
  defined( 'ABSPATH' ) || exit;
4
 
5
+ if ( ! class_exists( 'RWMB_Time_Field' ) ) {
6
  class RWMB_Time_Field extends RWMB_Field {
7
  /**
8
  * Enqueue scripts and styles
11
  */
12
  static function admin_enqueue_scripts() {
13
  $url = RWMB_CSS_URL . 'jqueryui';
14
+ wp_enqueue_style( 'jquery-ui-timepicker', "{$url}/jquery-ui-timepicker-addon.css", array( 'jquery-ui-datepicker', 'jquery-ui-slider' ), '0.9.7' );
15
 
16
  $url = RWMB_JS_URL . 'jqueryui';
17
  wp_register_script( 'jquery-ui-timepicker', "{$url}/jquery-ui-timepicker-addon.js", array( 'jquery-ui-datepicker', 'jquery-ui-slider' ), '0.9.7', true );
inc/libraries/meta-box/inc/meta-box.php CHANGED
@@ -4,7 +4,6 @@ defined( 'ABSPATH' ) || exit;
4
 
5
  // Meta Box Class
6
  if ( !class_exists( 'RW_Meta_Box' ) ) {
7
-
8
  /**
9
  * A class to rapid develop meta boxes for custom & built in content types
10
  * Piggybacks on WordPress
@@ -92,6 +91,7 @@ if ( !class_exists( 'RW_Meta_Box' ) ) {
92
  // @see wp_update_post(), wp_insert_attachment()
93
  add_action( 'edit_attachment', array( $this, 'save_post' ) );
94
  add_action( 'add_attachment', array( $this, 'save_post' ) );
 
95
  }
96
 
97
  /**
4
 
5
  // Meta Box Class
6
  if ( !class_exists( 'RW_Meta_Box' ) ) {
 
7
  /**
8
  * A class to rapid develop meta boxes for custom & built in content types
9
  * Piggybacks on WordPress
91
  // @see wp_update_post(), wp_insert_attachment()
92
  add_action( 'edit_attachment', array( $this, 'save_post' ) );
93
  add_action( 'add_attachment', array( $this, 'save_post' ) );
94
+
95
  }
96
 
97
  /**
inc/libraries/meta-box/meta-box.php CHANGED
@@ -41,31 +41,21 @@ if ( !defined( 'RWMB_VER' ) ) {
41
  if ( !defined( 'LP_METABOX_INC' ) ) {
42
  define( 'LP_METABOX_INC', LP_PLUGIN_PATH . 'inc/libraries/meta-box/inc/' );
43
  }
 
44
  if ( is_admin() ) {
45
  //require_once RWMB_INC_DIR . 'common.php';
46
  if ( !class_exists( 'RWMB_Field' ) ) {
47
  require_once LP_METABOX_INC . 'field.php';
48
  }
49
-
50
- if ( defined( 'RWMB_FIELDS_DIR' ) ) {
51
- // Field classes
52
- foreach ( glob( RWMB_FIELDS_DIR . '*.php' ) as $file ) {
53
- require_once $file;
54
- }
55
- }
56
-
57
  // Field classes
58
- foreach ( glob( LP_PLUGIN_PATH . 'inc/admin/meta-boxes/*.php' ) as $file ) {
59
  require_once $file;
60
  }
61
- if ( !class_exists( 'RWMB_Loader' ) && !class_exists( 'RW_Meta_Box' ) ) {
62
- // Main file
63
- require_once LP_METABOX_INC . 'meta-box.php';
64
- if ( !function_exists( 'rwmb_register_meta_boxes' ) ) {
65
- require_once LP_METABOX_INC . 'init.php';
66
- }
67
- }
68
-
69
 
 
 
 
 
 
70
  }
71
  do_action( 'learn_press_meta_box_loaded' );
41
  if ( !defined( 'LP_METABOX_INC' ) ) {
42
  define( 'LP_METABOX_INC', LP_PLUGIN_PATH . 'inc/libraries/meta-box/inc/' );
43
  }
44
+
45
  if ( is_admin() ) {
46
  //require_once RWMB_INC_DIR . 'common.php';
47
  if ( !class_exists( 'RWMB_Field' ) ) {
48
  require_once LP_METABOX_INC . 'field.php';
49
  }
 
 
 
 
 
 
 
 
50
  // Field classes
51
+ foreach ( glob( RWMB_FIELDS_DIR . '*.php' ) as $file ) {
52
  require_once $file;
53
  }
 
 
 
 
 
 
 
 
54
 
55
+ // Main file
56
+ require_once LP_METABOX_INC . 'meta-box.php';
57
+ if ( !function_exists( 'rwmb_register_meta_boxes' ) ) {
58
+ require_once LP_METABOX_INC . 'init.php';
59
+ }
60
  }
61
  do_action( 'learn_press_meta_box_loaded' );
inc/lp-constants.php CHANGED
@@ -4,7 +4,7 @@
4
  */
5
  $upload_dir = wp_upload_dir();
6
  // version
7
- define( 'LEARNPRESS_VERSION', '2.1.6.1' );
8
 
9
  define( 'LP_WP_CONTENT', basename( WP_CONTENT_DIR ) );
10
 
@@ -38,9 +38,4 @@ define( 'LP_ORDER_CPT', 'lp_order' );
38
  define( 'LP_TEACHER_ROLE', 'lp_teacher' );
39
 
40
  // Turn debug mode on/off
41
- define( 'LP_DEBUG', true );
42
-
43
- // Options
44
- define( 'LP_USE_ATTRIBUTES', false );
45
- define( 'LP_WIDGET_PATH', LP_PLUGIN_PATH . 'inc/widgets' );
46
- define( 'LP_WIDGET_URL', LP_PLUGIN_URL . 'inc/widgets' );
4
  */
5
  $upload_dir = wp_upload_dir();
6
  // version
7
+ define( 'LEARNPRESS_VERSION', '2.1.4.2' );
8
 
9
  define( 'LP_WP_CONTENT', basename( WP_CONTENT_DIR ) );
10
 
38
  define( 'LP_TEACHER_ROLE', 'lp_teacher' );
39
 
40
  // Turn debug mode on/off
41
+ define( 'LP_DEBUG', true );
 
 
 
 
 
inc/lp-core-functions.php CHANGED
@@ -348,7 +348,7 @@ function learn_press_get_post_by_name( $name, $type, $single = true ) {
348
  SELECT *
349
  FROM {$wpdb->posts}
350
  WHERE 1 AND post_name = %s
351
- ", sanitize_title( $name ) );
352
 
353
  $query .= " AND post_type IN ('" . $type . "' )";
354
 
@@ -573,18 +573,10 @@ function learn_press_seconds_to_time( $seconds, $separator = ':' ) {
573
  function learn_press_post_object( $defaults = false ) {
574
  static $post_object = false;
575
  if ( !$post_object ) {
576
- if ( !function_exists( 'get_default_post_to_edit' ) ) {
577
- @include_once ABSPATH . '/wp-admin/includes/post.php';
578
- }
579
-
580
- if ( function_exists( 'get_default_post_to_edit' ) ) {
581
- $post_object = get_default_post_to_edit();
582
- } else {
583
- global $wpdb;
584
- $post_object = new stdClass();
585
- foreach ( $wpdb->get_col( "DESC " . $wpdb->posts, 0 ) as $column_name ) {
586
- $post_object->{$column_name} = null;
587
- }
588
  }
589
  }
590
  settype( $defaults, 'array' );
@@ -1222,7 +1214,7 @@ function learn_press_get_currency_symbol( $currency = '' ) {
1222
 
1223
  function learn_press_get_page_link( $key ) {
1224
  $page_id = LP()->settings->get( $key . '_page_id' );
1225
- if ( get_post_status( $page_id ) == 'publish' ) {
1226
  $link = apply_filters( 'learn_press_get_page_link', get_permalink( $page_id ), $page_id, $key );
1227
  } else {
1228
  $link = '';
@@ -1361,31 +1353,6 @@ function learn_press_user_maybe_is_a_teacher( $user = null ) {
1361
  return apply_filters( 'learn_press_user_maybe_is_a_teacher', $role, $user->id );
1362
  }
1363
 
1364
- function learn_press_get_become_a_teacher_form_fields(){
1365
- $user = learn_press_get_current_user();
1366
- $fields = array(
1367
- 'bat_name' => array(
1368
- 'title' => __( 'Name', 'learnpress' ),
1369
- 'type' => 'text',
1370
- 'placeholder' => __( 'Your name', 'learnpress' ),
1371
- 'def' => $user->display_name
1372
- ),
1373
- 'bat_email' => array(
1374
- 'title' => __( 'Email', 'learnpress' ),
1375
- 'type' => 'email',
1376
- 'placeholder' => __( 'Your email address', 'learnpress' ),
1377
- 'def' => $user->user_email
1378
- ),
1379
- 'bat_phone' => array(
1380
- 'title' => __( 'Phone', 'learnpress' ),
1381
- 'type' => 'text',
1382
- 'placeholder' => __( 'Your phone number', 'learnpress' )
1383
- )
1384
- );
1385
- $fields = apply_filters( 'learn_press_become_teacher_form_fields', $fields );
1386
- return $fields;
1387
- }
1388
-
1389
  function learn_press_process_become_a_teacher_form( $args = null ) {
1390
  $user = learn_press_get_current_user();
1391
  $error = false;
@@ -1416,33 +1383,16 @@ function learn_press_process_become_a_teacher_form( $args = null ) {
1416
  $error = true;
1417
  }
1418
  }
1419
-
1420
  if ( !$error ) {
1421
  $to_email = array( get_option( 'admin_email' ) );
1422
  $message_headers = '';
1423
  $subject = __( 'Please moderate', 'learnpress' );
1424
-
1425
- $fields = learn_press_get_become_a_teacher_form_fields();
1426
- $default_fields = array('bat_name' , 'bat_email', 'bat_phone' );
1427
- foreach( $fields as $key => $field ){
1428
- if( isset($_POST[$key]) ) {
1429
- $fields[$key]['value'] = $_POST[$key];
1430
- }
1431
- }
1432
- $notify_message = apply_filters('learn_press_filter_become_a_teacher_notify_message','', $args, $fields, $user);
1433
- if( !$notify_message ) {
1434
- $notify_message = sprintf( __( 'The user <a href="%s">%s</a> wants to be a teacher.', 'learnpress' ) . "\r\n", admin_url( 'user-edit.php?user_id=' . $user->id ), $user->user_login ) . "\r\n";
1435
- $notify_message .= sprintf( __( 'Name: %s', 'learnpress' ), $args['name'] ) . "\r\n";
1436
- $notify_message .= sprintf( __( 'Email: %s', 'learnpress' ), $args['email'] ) . "\r\n";
1437
- $notify_message .= sprintf( __( 'Phone: %s', 'learnpress' ), $args['phone'] ) . "\r\n";
1438
- foreach( $fields as $key => $field ) {
1439
- if( !in_array( $key, $default_fields ) ) {
1440
- $notify_message .= $field['title'].': ' . ( isset($field['value']) ? $field['value'] : '' ) . "\r\n";
1441
- }
1442
- }
1443
- $notify_message .= wp_specialchars_decode( sprintf( __( 'Accept: %s', 'learnpress' ), wp_nonce_url( admin_url( 'user-edit.php?user_id=' . $user->id ) . '&action=accept-to-be-teacher', 'accept-to-be-teacher' ) ) ) . "\r\n";
1444
- }
1445
 
 
 
 
 
1446
  $args = array(
1447
  $to_email,
1448
  ( $subject ),
@@ -1455,7 +1405,6 @@ function learn_press_process_become_a_teacher_form( $args = null ) {
1455
 
1456
  set_transient( 'learn_press_become_teacher_sent_' . $user->id, 'yes', HOUR_IN_SECONDS * 2 );
1457
  }
1458
-
1459
  $return['result'] = $error ? 'error' : 'success';
1460
  return $return;
1461
  }
@@ -1558,10 +1507,10 @@ add_filter( 'pre_get_posts', 'learn_press_filter_search', 99 );
1558
  * @param $data
1559
  */
1560
  function learn_press_send_json( $data ) {
1561
- echo '<-- LP_AJAX_START -->';
1562
  @header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
1563
  echo wp_json_encode( $data );
1564
- echo '<-- LP_AJAX_END -->';
1565
  die;
1566
  }
1567
 
@@ -1867,15 +1816,13 @@ function learn_press_add_endpoints() {
1867
  if ( $endpoints = LP()->settings->get( 'profile_endpoints' ) ) foreach ( $endpoints as $endpoint => $value ) {
1868
  $endpoint = preg_replace( '!_!', '-', $endpoint );
1869
  LP()->query_vars[$endpoint] = $value;
1870
- add_rewrite_endpoint( $value,/* EP_ROOT |*/
1871
- EP_PAGES );
1872
  }
1873
 
1874
  if ( $endpoints = LP()->settings->get( 'quiz_endpoints' ) ) foreach ( $endpoints as $endpoint => $value ) {
1875
  $endpoint = preg_replace( '!_!', '-', $endpoint );
1876
  LP()->query_vars[$endpoint] = $value;
1877
- add_rewrite_endpoint( $value, /*EP_ROOT | */
1878
- EP_PAGES );
1879
  }
1880
  }
1881
 
@@ -2238,21 +2185,13 @@ function learn_press_profile_tab_exists( $tab ) {
2238
  */
2239
  function learn_press_user_profile_link( $user_id = 0, $tab = null ) {
2240
  if ( !$user_id ) {
2241
- $user_id = get_current_user_id();
2242
- }
2243
- $user = false;
2244
- $deleted = in_array( $user_id, LP_User_Factory::$_deleted_users );
2245
- if ( !$deleted ) {
2246
  if ( is_numeric( $user_id ) ) {
2247
  $user = get_user_by( 'id', $user_id );
2248
  } else {
2249
- $user = get_user_by( 'login', urldecode($user_id) );
2250
  }
2251
- } else {
2252
- return '';
2253
- }
2254
- if ( !$deleted && !$user ) {
2255
- LP_User_Factory::$_deleted_users[] = $user_id;
2256
  }
2257
 
2258
  if ( !$user ) {
@@ -2371,7 +2310,7 @@ function learn_press_auto_enroll_user_to_courses( $order_id ) {
2371
  return;
2372
  }
2373
 
2374
- if ( !$users = $order->get_user_data() ) {
2375
  return;
2376
  }
2377
 
@@ -2381,30 +2320,24 @@ function learn_press_auto_enroll_user_to_courses( $order_id ) {
2381
  if ( !$course ) {
2382
  continue;
2383
  }
2384
- foreach ( $users as $uid => $data ) {
2385
- $user = learn_press_get_user( $uid );
2386
- if ( !$user->is_exists() ) {
2387
- continue;
2388
- }
2389
- if ( $user->has( 'enrolled-course', $course->id ) ) {
2390
- continue;
2391
- }
2392
- // error. this scripts will create new order each course item
2393
- // $return = $user->enroll( $course->id, $order_id );
2394
- $return = learn_press_update_user_item_field( array(
2395
- 'user_id' => $user->ID,
2396
- 'item_id' => $course->id,
2397
- 'start_time' => current_time( 'mysql' ),
2398
- 'status' => 'enrolled',
2399
- 'end_time' => '0000-00-00 00:00:00',
2400
- 'ref_id' => $order->id, //$course->id,
2401
- 'item_type' => 'lp_course',
2402
- 'ref_type' => 'lp_order',
2403
- 'parent_id' => $user->get_course_history_id( $course->id )
2404
- ) );
2405
- ///learn_press_update_user_item_meta( $return, '_lp_order', $order->id );
2406
- //learn_press_update_user_item_meta( $return, '_lp_active', 'yes' );
2407
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2408
  }
2409
  return $return;
2410
  }
@@ -2704,10 +2637,6 @@ if ( !function_exists( 'learn_press_cancel_order_process' ) ) {
2704
  * get current time to user for caculate remaining time of quiz
2705
  */
2706
  function learn_press_get_current_time() {
2707
- $current_time = apply_filters( 'learn_press_get_current_time', 0 );
2708
- if ( $current_time > 0 ) {
2709
- return $current_time;
2710
- }
2711
  $a = current_time( "timestamp" );
2712
  $b = current_time( "timestamp", true );
2713
  $c = current_time( "mysql" );
@@ -2788,15 +2717,14 @@ function learn_press_get_students_list_filter() {
2788
  return apply_filters( 'learn_press_get_students_list_filter', $filter );
2789
  }
2790
 
2791
- function learn_press_execute_time( $n = 1 ) {
2792
  static $time;
2793
  if ( empty( $time ) ) {
2794
  $time = microtime( true );
2795
  return $time;
2796
  } else {
2797
  $execute_time = microtime( true ) - $time;
2798
-
2799
- echo "Execute time " . $n * $execute_time . "\n";
2800
  $time = 0;
2801
  return $execute_time;
2802
  }
@@ -2833,10 +2761,7 @@ function learn_press_comment_reply_link( $link, $args = array(), $comment = null
2833
  );
2834
 
2835
  $link = sprintf( "<a rel='nofollow' class='comment-reply-link' href='%s' onclick='%s' aria-label='%s'>%s</a>",
2836
- esc_url( add_query_arg( array(
2837
- 'replytocom' => $comment->comment_ID,
2838
- 'content-item-only' => 'yes'
2839
- ), get_permalink( $post->ID ) ) ) . "#" . $args['respond_id'],
2840
  $onclick,
2841
  esc_attr( sprintf( $args['reply_to_text'], $comment->comment_author ) ),
2842
  $args['reply_text']
@@ -2859,4 +2784,4 @@ function learn_press_validation_data_before_save( $value = '', $name = '' ) {
2859
  }
2860
 
2861
  return $value;
2862
- }
348
  SELECT *
349
  FROM {$wpdb->posts}
350
  WHERE 1 AND post_name = %s
351
+ ", $name );
352
 
353
  $query .= " AND post_type IN ('" . $type . "' )";
354
 
573
  function learn_press_post_object( $defaults = false ) {
574
  static $post_object = false;
575
  if ( !$post_object ) {
576
+ global $wpdb;
577
+ $post_object = new stdClass();
578
+ foreach ( $wpdb->get_col( "DESC " . $wpdb->posts, 0 ) as $column_name ) {
579
+ $post_object->{$column_name} = null;
 
 
 
 
 
 
 
 
580
  }
581
  }
582
  settype( $defaults, 'array' );
1214
 
1215
  function learn_press_get_page_link( $key ) {
1216
  $page_id = LP()->settings->get( $key . '_page_id' );
1217
+ if ( $page_id && get_post_status( $page_id ) == 'publish' ) {
1218
  $link = apply_filters( 'learn_press_get_page_link', get_permalink( $page_id ), $page_id, $key );
1219
  } else {
1220
  $link = '';
1353
  return apply_filters( 'learn_press_user_maybe_is_a_teacher', $role, $user->id );
1354
  }
1355
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1356
  function learn_press_process_become_a_teacher_form( $args = null ) {
1357
  $user = learn_press_get_current_user();
1358
  $error = false;
1383
  $error = true;
1384
  }
1385
  }
 
1386
  if ( !$error ) {
1387
  $to_email = array( get_option( 'admin_email' ) );
1388
  $message_headers = '';
1389
  $subject = __( 'Please moderate', 'learnpress' );
1390
+ $notify_message = sprintf( __( 'The user <a href="%s">%s</a> wants to be a teacher.', 'learnpress' ) . "\r\n", admin_url( 'user-edit.php?user_id=' . $user->id ), $user->user_login ) . "\r\n";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1391
 
1392
+ $notify_message .= sprintf( __( 'Name: %s', 'learnpress' ), $args['name'] ) . "\r\n";
1393
+ $notify_message .= sprintf( __( 'Email: %s', 'learnpress' ), $args['email'] ) . "\r\n";
1394
+ $notify_message .= sprintf( __( 'Phone: %s', 'learnpress' ), $args['phone'] ) . "\r\n";
1395
+ $notify_message .= wp_specialchars_decode( sprintf( __( 'Accept: %s', 'learnpress' ), wp_nonce_url( admin_url( 'user-edit.php?user_id=' . $user->id ) . '&action=accept-to-be-teacher', 'accept-to-be-teacher' ) ) ) . "\r\n";
1396
  $args = array(
1397
  $to_email,
1398
  ( $subject ),
1405
 
1406
  set_transient( 'learn_press_become_teacher_sent_' . $user->id, 'yes', HOUR_IN_SECONDS * 2 );
1407
  }
 
1408
  $return['result'] = $error ? 'error' : 'success';
1409
  return $return;
1410
  }
1507
  * @param $data
1508
  */
1509
  function learn_press_send_json( $data ) {
1510
+ echo '<!-- LP_AJAX_START -->';
1511
  @header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
1512
  echo wp_json_encode( $data );
1513
+ echo '<!-- LP_AJAX_END -->';
1514
  die;
1515
  }
1516
 
1816
  if ( $endpoints = LP()->settings->get( 'profile_endpoints' ) ) foreach ( $endpoints as $endpoint => $value ) {
1817
  $endpoint = preg_replace( '!_!', '-', $endpoint );
1818
  LP()->query_vars[$endpoint] = $value;
1819
+ add_rewrite_endpoint( $value, EP_ROOT | EP_PAGES );
 
1820
  }
1821
 
1822
  if ( $endpoints = LP()->settings->get( 'quiz_endpoints' ) ) foreach ( $endpoints as $endpoint => $value ) {
1823
  $endpoint = preg_replace( '!_!', '-', $endpoint );
1824
  LP()->query_vars[$endpoint] = $value;
1825
+ add_rewrite_endpoint( $value, EP_ROOT | EP_PAGES );
 
1826
  }
1827
  }
1828
 
2185
  */
2186
  function learn_press_user_profile_link( $user_id = 0, $tab = null ) {
2187
  if ( !$user_id ) {
2188
+ $user = get_user_by( 'id', get_current_user_id() );
2189
+ } else {
 
 
 
2190
  if ( is_numeric( $user_id ) ) {
2191
  $user = get_user_by( 'id', $user_id );
2192
  } else {
2193
+ $user = get_user_by( 'login', $user_id );
2194
  }
 
 
 
 
 
2195
  }
2196
 
2197
  if ( !$user ) {
2310
  return;
2311
  }
2312
 
2313
+ if ( !$user = $order->get_user() ) {
2314
  return;
2315
  }
2316
 
2320
  if ( !$course ) {
2321
  continue;
2322
  }
2323
+ if ( $user->has( 'enrolled-course', $course->id ) ) {
2324
+ continue;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2325
  }
2326
+ // error. this scripts will create new order each course item
2327
+ // $return = $user->enroll( $course->id, $order_id );
2328
+ $return = learn_press_update_user_item_field( array(
2329
+ 'user_id' => $user->ID,
2330
+ 'item_id' => $course->id,
2331
+ 'start_time' => current_time( 'mysql' ),
2332
+ 'status' => 'enrolled',
2333
+ 'end_time' => '0000-00-00 00:00:00',
2334
+ 'ref_id' => $course->id,
2335
+ 'item_type' => 'lp_course',
2336
+ 'ref_type' => 'lp_order',
2337
+ 'parent_id' => $user->get_course_history_id( $course->id )
2338
+ ) );
2339
+
2340
+
2341
  }
2342
  return $return;
2343
  }
2637
  * get current time to user for caculate remaining time of quiz
2638
  */
2639
  function learn_press_get_current_time() {
 
 
 
 
2640
  $a = current_time( "timestamp" );
2641
  $b = current_time( "timestamp", true );
2642
  $c = current_time( "mysql" );
2717
  return apply_filters( 'learn_press_get_students_list_filter', $filter );
2718
  }
2719
 
2720
+ function learn_press_execute_time() {
2721
  static $time;
2722
  if ( empty( $time ) ) {
2723
  $time = microtime( true );
2724
  return $time;
2725
  } else {
2726
  $execute_time = microtime( true ) - $time;
2727
+ echo "Execute time " . $execute_time;
 
2728
  $time = 0;
2729
  return $execute_time;
2730
  }
2761
  );
2762
 
2763
  $link = sprintf( "<a rel='nofollow' class='comment-reply-link' href='%s' onclick='%s' aria-label='%s'>%s</a>",
2764
+ esc_url( add_query_arg( array( 'replytocom' => $comment->comment_ID, 'content-item-only' => 'yes' ), get_permalink( $post->ID ) ) ) . "#" . $args['respond_id'],
 
 
 
2765
  $onclick,
2766
  esc_attr( sprintf( $args['reply_to_text'], $comment->comment_author ) ),
2767
  $args['reply_text']
2784
  }
2785
 
2786
  return $value;
2787
+ }
inc/lp-init.php CHANGED
@@ -3,7 +3,6 @@
3
  * Functions that are used to init a course to reduce SQL queries
4
  */
5
 
6
-
7
  if ( !defined( 'ABSPATH' ) ) {
8
  exit; // Exit if accessed directly
9
  }
@@ -14,7 +13,6 @@ add_action( 'init', '_learn_press_upgrade_table' );
14
  * TODO: remove in next version
15
  */
16
  function _learn_press_upgrade_table() {
17
-
18
  if ( version_compare( LEARNPRESS_VERSION, '2.1.0', '<' ) ) {
19
  global $wpdb;
20
  if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}learnpress_user_items'" ) != $wpdb->prefix . "learnpress_user_items" ) {
@@ -23,7 +21,6 @@ function _learn_press_upgrade_table() {
23
 
24
  $query = "SHOW COLUMNS FROM {$wpdb->prefix}learnpress_user_items LIKE 'parent_id'";
25
  if ( $row = $wpdb->get_var( $query ) ) {
26
- update_option( 'learn_press_upgrade_table_20', 'yes' );
27
  return;
28
  }
29
 
@@ -44,32 +41,29 @@ function _learn_press_setup_user_course_data( $query ) {
44
  */
45
  function learn_press_setup_pages() {
46
  global $wpdb;
47
- static $pages = false;
48
- if ( $pages == false ) {
49
- $pages = array( 'courses', 'profile', 'become_a_teacher', 'checkout' );
50
- $page_ids = array();
51
- foreach ( $pages as $page ) {
52
- $id = get_option( 'learn_press_' . $page . '_page_id' );
53
- if ( $id ) {
54
- $page_ids[] = $id;
55
- }
56
- }
57
- if ( !$page_ids ) {
58
- return;
59
- }
60
- $query = $wpdb->prepare( "
61
- SELECT *
62
- FROM {$wpdb->posts}
63
- WHERE %d AND ID IN(" . join( ',', $page_ids ) . ")
64
- AND post_status <> %s
65
- ", 1, 'trash' );
66
- if ( !$pages = $wpdb->get_results( $query ) ) {
67
- return;
68
- }
69
- foreach ( $pages as $page ) {
70
- wp_cache_add( $page->ID, $page, 'posts' );
71
  }
72
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  }
74
 
75
  /**
@@ -109,35 +103,26 @@ function learn_press_setup_course_data( $the_course ) {
109
  return $post->ID;
110
  }
111
 
112
- function _learn_press_count_users_enrolled_courses( $course_ids ) {
113
  global $wpdb;
114
- $counts = LP_Cache::get_enrolled_courses( false, array() );
115
- if ( $counts ) {
116
- $remove_ids = array();
117
- foreach ( $counts as $id => $data ) {
118
- $remove_ids[] = $id;
119
- }
120
- $course_ids = array_diff( $course_ids, $remove_ids );
121
- }
122
- if ( $course_ids ) {
123
- $in = array_fill( 0, sizeof( $course_ids ), '%d' );
124
- $format = array( '_course_id' );
125
- $format = array_merge( $format, $course_ids );
126
- $format[] = 'lp-completed';
127
- $query = $wpdb->prepare( "
128
- SELECT oim.meta_value as course_id, count(o.ID) as count
129
- FROM {$wpdb->posts} o
130
- INNER JOIN {$wpdb->learnpress_order_items} oi ON oi.order_id = o.ID
131
- INNER JOIN {$wpdb->learnpress_order_itemmeta} oim ON oim.learnpress_order_item_id = oi.order_item_id
132
- AND oim.meta_key = %s
133
- AND oim.meta_value IN(" . join( ',', $in ) . ")
134
- WHERE o.post_status = %s
135
- GROUP BY oim.meta_value
136
- ", $format );
137
- if ( $results = $wpdb->get_results( $query ) ) {
138
- foreach ( $results as $c => $v ) {
139
- $counts[$v->course_id] = absint( $v->count );
140
- }
141
  }
142
  }
143
  foreach ( $course_ids as $course_id ) {
@@ -145,45 +130,28 @@ function _learn_press_count_users_enrolled_courses( $course_ids ) {
145
  $counts[$course_id] = 0;
146
  }
147
  }
148
- LP_Cache::set_enrolled_courses( $counts );
149
  return $counts;
150
  }
151
 
152
- function _learn_press_get_courses_curriculum( $course_ids, $force = false, $parse_items = true ) {
153
  global $wpdb;
154
  $curriculum = LP_Cache::get_course_curriculum( false, array() );
155
  $post_names = LP_Cache::get_post_names( false, array() );
156
-
157
- $remove_courses = array();
158
- foreach ( $course_ids as $course_id ) {
159
- if ( array_key_exists( $course_id, $curriculum ) ) {
160
- $remove_courses[] = $course_id;
161
- } else {
162
- $curriculum[$course_id] = array();
163
- }
164
- }
165
-
166
- if ( $remove_courses ) {
167
- $course_ids = array_diff( $course_ids, $remove_courses );
168
- }
169
- if ( !$course_ids ) {
170
- return;
171
- }
172
- $in = array_fill( 0, sizeof( $course_ids ), '%d' );
173
- $query = $wpdb->prepare( "
174
- SELECT s.*, si.*, p.*
175
- FROM {$wpdb->prefix}posts p
176
- INNER JOIN {$wpdb->prefix}learnpress_section_items si ON si.item_id = p.ID
177
- INNER JOIN {$wpdb->prefix}learnpress_sections s ON s.section_id = si.section_id
178
- WHERE s.section_id IN(
179
- SELECT cc.section_id
180
- FROM {$wpdb->prefix}posts p
181
- INNER JOIN {$wpdb->prefix}learnpress_sections cc ON p.ID = cc.section_course_id
182
- WHERE p.ID IN(" . join( ',', $in ) . ")
183
- ORDER BY `section_order` ASC
184
- )
185
- ORDER BY s.section_course_id, s.section_order, si.item_order ASC
186
- ", $course_ids );
187
  asort( $course_ids );
188
 
189
  if ( $posts = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID IN (" . join( ',', $in ) . ")", $course_ids ) ) ) {
@@ -210,7 +178,7 @@ function _learn_press_get_courses_curriculum( $course_ids, $force = false, $pars
210
  $lesson_ids = array();
211
 
212
  foreach ( $rows as $row ) {
213
- if ( $course_id != $row->section_course_id || empty( $row->section_id ) ) {
214
  continue;
215
  }
216
  if ( $row->section_id != $section_id ) {
@@ -240,11 +208,10 @@ function _learn_press_get_courses_curriculum( $course_ids, $force = false, $pars
240
  $item->{$prop} = $row->{$prop};
241
  }
242
  }
243
- $item_ids[] = $item->ID;
 
244
  if ( $item->post_type == LP_QUIZ_CPT ) {
245
- if ( false == wp_cache_get( $item->ID, 'posts' ) ) {
246
- $quiz_ids[] = $item->ID;
247
- }
248
  } elseif ( $item->post_type == LP_LESSON_CPT ) {
249
  $lesson_ids[] = $item->ID;
250
  }
@@ -252,26 +219,16 @@ function _learn_press_get_courses_curriculum( $course_ids, $force = false, $pars
252
  $post_names[$item->post_type] = array();
253
  }
254
  $post_names[$item->post_type][$item->post_name] = $item->ID;
255
- if ( $item->post_type == LP_QUIZ_CPT ) {
256
- $cached_post = wp_cache_get( $item->ID, 'posts' );
257
- if ( $cached_post ) {
258
- foreach ( array( 'mark', 'questions' ) as $prop ) {
259
- if ( property_exists( $cached_post, $prop ) ) {
260
- $item->{$prop} = $cached_post->{$prop};
261
- }
262
- }
263
- }
264
- }
265
- $_curriculum[$section_id]->items[] = $item;
266
  wp_cache_delete( $item->ID, 'posts' );
267
  wp_cache_add( $item->ID, $item, 'posts' );
268
  }
269
 
270
- $meta_cache_ids = array_merge( $meta_cache_ids, $item_ids );
271
- $course = get_post( $course_id );
272
- $course->curriculum_items = is_admin() ? maybe_serialize( $item_ids ) : $item_ids;
 
273
  wp_cache_replace( $course_id, $course, 'posts' );
274
- if ( $quiz_ids && $parse_items ) {
275
  $question_ids = _learn_press_get_quiz_questions( $quiz_ids );
276
  if ( $question_ids ) {
277
  $meta_cache_ids = array_merge( $meta_cache_ids, $question_ids );
@@ -279,24 +236,7 @@ function _learn_press_get_courses_curriculum( $course_ids, $force = false, $pars
279
  }
280
  $curriculum[$course_id] = $_curriculum;
281
  }
282
- $meta_cache_ids = array_unique( $meta_cache_ids );
283
  update_meta_cache( 'post', $meta_cache_ids );
284
- $attachment_ids = array();
285
- foreach ( $meta_cache_ids as $id ) {
286
- if ( $postmeta = wp_cache_get( $id, 'post_meta' ) ) {
287
- if ( array_key_exists( '_thumbnail_id', $postmeta ) ) {
288
- $attachment_ids[] = $postmeta['_thumbnail_id'][0];
289
- }
290
- }
291
- }
292
- if ( $attachment_ids ) {
293
- update_meta_cache( 'post', $attachment_ids );
294
- if ( $attachments = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->posts} WHERE ID IN(" . join( ',', $attachment_ids ) . ") AND post_type=%s", 'attachment' ) ) ) {
295
- foreach ( $attachments as $attachment ) {
296
- wp_cache_add( $attachment->ID, $attachment, 'posts' );
297
- }
298
- }
299
- }
300
  LP_Cache::set_course_curriculum( $curriculum );
301
  LP_Cache::set_post_names( $post_names );
302
  }
@@ -310,16 +250,17 @@ function _learn_press_get_courses_curriculum( $course_ids, $force = false, $pars
310
  * @return array
311
  */
312
  function _learn_press_get_course_curriculum( $course_id, $force = false ) {
313
- //return learn_press_get_course_curriculumx( $course_id, $force );
314
- $curriculum = LP_Cache::get_course_curriculum( $course_id );
315
- if ( ( $curriculum == false ) || $force ) {
316
  $curriculum = _learn_press_get_courses_curriculum( array( $course_id ), $force );
317
  if ( empty( $curriculum[$course_id] ) ) {
318
  $curriculum[$course_id] = array();
319
  }
320
- $curriculum = $curriculum[$course_id];
321
  }
322
- return $curriculum;
 
 
323
  }
324
 
325
  /**
@@ -356,14 +297,14 @@ function _learn_press_get_quiz_questions( $quiz_ids ) {
356
  $format_ids = array_fill( 0, sizeof( $question_ids ), '%d' );
357
  $prepare_args = array_merge( array( '_lp_type', 'lp_question' ), $question_ids );
358
  $query = $wpdb->prepare( "
359
- SELECT qa.question_answer_id, ID as id, pm.meta_value as type, qa.answer_data as answer_data, answer_order
360
- FROM {$wpdb->posts} p
361
- INNER JOIN {$wpdb->postmeta} pm ON pm.post_id = p.ID AND pm.meta_key = %s
362
- INNER JOIN {$wpdb->prefix}learnpress_quiz_questions qq ON qq.question_id = p.ID
363
- RIGHT JOIN {$wpdb->prefix}learnpress_question_answers qa ON qa.question_id = p.ID
364
- WHERE qq.quiz_id IN (" . join( ',', $quiz_ids ) . ")
365
- ORDER BY id, qq.question_order, answer_order ASC
366
- ", $prepare_args );
367
  if ( $answers = $wpdb->get_results( $query ) ) {
368
  $question_id = 0;
369
  foreach ( $answers as $row ) {
@@ -429,6 +370,8 @@ function _learn_press_get_quiz_questions( $quiz_ids ) {
429
  function learn_press_setup_user_course_data( $user_id, $course_id, $force = false ) {
430
  if ( is_array( $course_id ) ) {
431
  _learn_press_get_courses_curriculum( $course_id );
 
 
432
  foreach ( $course_id as $cid ) {
433
  learn_press_setup_user_course_data( $user_id, $cid, $force );
434
  }
@@ -480,59 +423,43 @@ function _learn_press_parse_user_item_statuses( $user_id, $course_id, $force = f
480
  if ( $item_ids ) {
481
  $in = implode( ', ', $item_ids );
482
  $query = $wpdb->prepare( "
483
- SELECT X.*, ui.meta_value AS grade
484
- FROM (
485
- SELECT * FROM {$wpdb->prefix}learnpress_user_items t1
486
- WHERE user_id = %d
487
- AND item_id = %d
488
- UNION
489
- (
490
- SELECT * FROM {$wpdb->prefix}learnpress_user_items t2
491
- WHERE user_id = %d AND ref_id = %d
492
- AND user_item_id = (
493
- SELECT MAX(user_item_id) FROM {$wpdb->prefix}learnpress_user_items
494
- WHERE user_id = %d and ref_id = %d
495
- AND item_id = t2.item_id
496
- )
497
- AND item_id IN({$in})
498
  )
499
- ) AS X
500
- LEFT JOIN {$wpdb->prefix}learnpress_user_itemmeta ui ON ui.learnpress_user_item_id = X.user_item_id AND ui.meta_key = %s
501
  ORDER BY user_item_id ASC
502
- ", $user_id, $course_id, $user_id, $course_id, $user_id, $course_id, '_quiz_grade' );
503
  } else {
504
  $query = $wpdb->prepare( "
505
- SELECT ui.*, uim.meta_value as grade FROM {$wpdb->prefix}learnpress_user_items ui
506
- LEFT JOIN {$wpdb->prefix}learnpress_user_itemmeta uim ON uim.learnpress_user_item_id = ui.user_item_id AND uim.meta_key = %s
507
  WHERE user_id = %d
508
  AND item_id = %d
509
- ", '_quiz_grade', $user_id, $course_id );
510
  }
511
  $items = $wpdb->get_results( $query );
512
 
513
  $item_statuses = LP_Cache::get_item_statuses( false, array() );
514
- $quiz_grades = LP_Cache::get_quiz_grade( false, array() );
515
  foreach ( $item_ids as $id ) {
516
  if ( !array_key_exists( $id, $item_statuses ) || $force ) {
517
  $item_statuses[$user_id . '-' . $course_id . '-' . $id] = '';
518
  }
519
-
520
- if ( !array_key_exists( $id, $item_statuses ) || $force ) {
521
- $quiz_grades[$user_id . '-' . $course_id . '-' . $id] = '';
522
- }
523
  }
524
  if ( $items ) {
525
  foreach ( $items as $item ) {
526
  $item_statuses[$user_id . '-' . $course_id . '-' . $item->item_id] = learn_press_validate_item_status( $item );
527
- if ( !empty($item->grade) ) {
528
- $quiz_grades[$user_id . '-' . $course_id . '-' . $item->item_id] = $item->grade;
529
- }else{
530
- $quiz_grades[$user_id . '-' . $course_id . '-' . $item->item_id] = '';
531
- }
532
  }
533
  }
534
  LP_Cache::set_item_statuses( $item_statuses );
535
- LP_Cache::set_quiz_grade( $quiz_grades );
536
 
537
  do_action( "learn_press_parse_user_item_statuses", $user_id, $course_id );
538
  do_action( "learn_press_parse_user_item_statuses_{$user_id}_{$course_id}" );
@@ -541,12 +468,6 @@ function _learn_press_parse_user_item_statuses( $user_id, $course_id, $force = f
541
  function learn_press_validate_item_status( $item ) {
542
  $end_time = $item->end_time !== '0000-00-00 00:00:00';
543
  $status = $end_time > 0 ? ( $item->item_type != LP_COURSE_CPT ? 'completed' : 'finished' ) : $item->status;
544
- if ( $item->item_type == LP_QUIZ_CPT && $item->status == 'completed' && is_null( $item->grade ) ) {
545
- $user = learn_press_get_user( $item->user_id );
546
- $grade = $user->get_quiz_graduation( $item->item_id, $item->ref_id );
547
- LP_Cache::set_quiz_grade( sprintf( '%d-%d-%d', $item->user_id, $item->ref_id, $item->item_id ), $grade );
548
- learn_press_update_user_item_meta( $item->user_item_id, '_quiz_grade', $grade );
549
- }
550
  if ( $end_time && !in_array( $item->status, array( 'completed', 'finished' ) ) ) {
551
  global $wpdb;
552
  $data = (array) $item;
@@ -620,23 +541,16 @@ function _learn_press_get_user_profile_orders( $user_id = 0, $paged = 1, $limit
620
  $data = LP_Cache::get_user_profile_orders( false, array() );
621
 
622
  if ( !array_key_exists( $user_id, $data ) ) {
623
- $limit = absint( $limit );
624
- $offset = absint( $paged - 1 ) * $limit;
625
- $results = array();
626
- $statuses = learn_press_get_order_statuses( true, true );
627
- $status_format = array_fill( 0, sizeof( $statuses ), '%s' );
628
- $args = array( '_user_id', $user_id, LP_ORDER_CPT, $user_id, $offset, $limit );
629
- array_splice( $args, 3, 0, $statuses );
630
- $query = $wpdb->prepare( "
631
- SELECT DISTINCT po.*, oi.order_id, pm.meta_value as user_id
632
  FROM {$wpdb->prefix}learnpress_order_items oi
633
  INNER JOIN {$wpdb->prefix}postmeta pm ON pm.post_id = oi.order_id AND pm.meta_key = %s AND pm.meta_value = %d
634
- RIGHT JOIN {$wpdb->prefix}posts po ON po.ID = oi.order_id
635
- WHERE po.post_type = %s AND po.post_status IN(" . join( ',', $status_format ) . ")
636
- HAVING user_id = %d
637
- ORDER BY ID DESC
638
- LIMIT %d, %d
639
- ", $args );
640
  if ( $rows = $wpdb->get_results( $query ) ) {
641
  $results['total'] = count( $rows );
642
  $results['paged'] = $paged;
@@ -644,13 +558,9 @@ function _learn_press_get_user_profile_orders( $user_id = 0, $paged = 1, $limit
644
  $results['offset'] = $offset;
645
  $results['num_pages'] = ceil( $results['total'] / $limit );
646
  $rows = array_slice( $rows, $offset, $limit );
647
- $order_ids = array();
648
  foreach ( $rows as $row ) {
649
  $results['rows'][$row->ID] = $row;
650
- wp_cache_add( $row->ID, $row, 'posts' );
651
- $order_ids[] = $row->ID;
652
  }
653
- update_meta_cache( 'post', $order_ids );
654
  }
655
 
656
  $data[$user_id] = $results;
@@ -658,6 +568,8 @@ function _learn_press_get_user_profile_orders( $user_id = 0, $paged = 1, $limit
658
  } else {
659
  $results = $data[$user_id];
660
  }
 
 
661
  return $results;
662
  }
663
 
@@ -715,5 +627,4 @@ learn_press_setup_pages();
715
  //
716
  //function learn_press_remove_course_comment() {
717
  // remove_post_type_support( 'lp_course', 'comments' );
718
- //}
719
-
3
  * Functions that are used to init a course to reduce SQL queries
4
  */
5
 
 
6
  if ( !defined( 'ABSPATH' ) ) {
7
  exit; // Exit if accessed directly
8
  }
13
  * TODO: remove in next version
14
  */
15
  function _learn_press_upgrade_table() {
 
16
  if ( version_compare( LEARNPRESS_VERSION, '2.1.0', '<' ) ) {
17
  global $wpdb;
18
  if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}learnpress_user_items'" ) != $wpdb->prefix . "learnpress_user_items" ) {
21
 
22
  $query = "SHOW COLUMNS FROM {$wpdb->prefix}learnpress_user_items LIKE 'parent_id'";
23
  if ( $row = $wpdb->get_var( $query ) ) {
 
24
  return;
25
  }
26
 
41
  */
42
  function learn_press_setup_pages() {
43
  global $wpdb;
44
+ $pages = array( 'courses', 'profile', 'become_a_teacher', 'checkout' );
45
+ $page_ids = array();
46
+ foreach ( $pages as $page ) {
47
+ $id = get_option( 'learn_press_' . $page . '_page_id' );
48
+ if ( $id ) {
49
+ $page_ids[] = $id;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  }
51
  }
52
+ if ( !$page_ids ) {
53
+ return;
54
+ }
55
+ $query = $wpdb->prepare( "
56
+ SELECT *
57
+ FROM {$wpdb->posts}
58
+ WHERE %d AND ID IN(" . join( ',', $page_ids ) . ")
59
+ AND post_status <> %s
60
+ ", 1, 'trash' );
61
+ if ( !$pages = $wpdb->get_results( $query ) ) {
62
+ return;
63
+ }
64
+ foreach ( $pages as $page ) {
65
+ wp_cache_add( $page->ID, $page, 'posts' );
66
+ }
67
  }
68
 
69
  /**
103
  return $post->ID;
104
  }
105
 
106
+ function _learn_press_get_users_enrolled_courses( $course_ids ) {
107
  global $wpdb;
108
+ static $counts = array();
109
+ $in = array_fill( 0, sizeof( $course_ids ), '%d' );
110
+ $format = array( '_course_id' );
111
+ $format = array_merge( $format, $course_ids );
112
+ $format[] = 'lp-completed';
113
+ $query = $wpdb->prepare( "
114
+ SELECT oim.meta_value as course_id, count(o.ID) as count
115
+ FROM {$wpdb->posts} o
116
+ INNER JOIN {$wpdb->learnpress_order_items} oi ON oi.order_id = o.ID
117
+ INNER JOIN {$wpdb->learnpress_order_itemmeta} oim ON oim.learnpress_order_item_id = oi.order_item_id
118
+ AND oim.meta_key = %s
119
+ AND oim.meta_value IN(" . join( ',', $in ) . ")
120
+ WHERE o.post_status = %s
121
+ GROUP BY oim.meta_value
122
+ ", $format );
123
+ if ( $results = $wpdb->get_results( $query ) ) {
124
+ foreach ( $results as $c => $v ) {
125
+ $counts[$v->course_id] = absint( $v->count );
 
 
 
 
 
 
 
 
 
126
  }
127
  }
128
  foreach ( $course_ids as $course_id ) {
130
  $counts[$course_id] = 0;
131
  }
132
  }
 
133
  return $counts;
134
  }
135
 
136
+ function _learn_press_get_courses_curriculum( $course_ids, $force = false ) {
137
  global $wpdb;
138
  $curriculum = LP_Cache::get_course_curriculum( false, array() );
139
  $post_names = LP_Cache::get_post_names( false, array() );
140
+ $in = array_fill( 0, sizeof( $course_ids ), '%d' );
141
+ $query = $wpdb->prepare( "
142
+ SELECT s.*, si.*, p.*
143
+ FROM {$wpdb->prefix}posts p
144
+ INNER JOIN {$wpdb->prefix}learnpress_section_items si ON si.item_id = p.ID
145
+ INNER JOIN {$wpdb->prefix}learnpress_sections s ON s.section_id = si.section_id
146
+ WHERE s.section_id IN(
147
+ SELECT cc.section_id
148
+ FROM {$wpdb->prefix}posts p
149
+ INNER JOIN {$wpdb->prefix}learnpress_sections cc ON p.ID = cc.section_course_id
150
+ WHERE p.ID IN(" . join( ',', $in ) . ")
151
+ ORDER BY `section_order` ASC
152
+ )
153
+ ORDER BY s.section_course_id, s.section_order, si.item_order ASC
154
+ ", $course_ids );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
  asort( $course_ids );
156
 
157
  if ( $posts = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID IN (" . join( ',', $in ) . ")", $course_ids ) ) ) {
178
  $lesson_ids = array();
179
 
180
  foreach ( $rows as $row ) {
181
+ if ( $course_id != $row->section_course_id ) {
182
  continue;
183
  }
184
  if ( $row->section_id != $section_id ) {
208
  $item->{$prop} = $row->{$prop};
209
  }
210
  }
211
+ $_curriculum[$section_id]->items[] = $item;
212
+ $item_ids[] = $item->ID;
213
  if ( $item->post_type == LP_QUIZ_CPT ) {
214
+ $quiz_ids[] = $item->ID;
 
 
215
  } elseif ( $item->post_type == LP_LESSON_CPT ) {
216
  $lesson_ids[] = $item->ID;
217
  }
219
  $post_names[$item->post_type] = array();
220
  }
221
  $post_names[$item->post_type][$item->post_name] = $item->ID;
 
 
 
 
 
 
 
 
 
 
 
222
  wp_cache_delete( $item->ID, 'posts' );
223
  wp_cache_add( $item->ID, $item, 'posts' );
224
  }
225
 
226
+ $meta_cache_ids = array_merge( $meta_cache_ids, $item_ids );
227
+ if ( $course = get_post( $course_id ) ) {
228
+ $course->curriculum_items = is_admin() ? maybe_serialize( $item_ids ) : $item_ids;
229
+ }
230
  wp_cache_replace( $course_id, $course, 'posts' );
231
+ if ( $quiz_ids ) {
232
  $question_ids = _learn_press_get_quiz_questions( $quiz_ids );
233
  if ( $question_ids ) {
234
  $meta_cache_ids = array_merge( $meta_cache_ids, $question_ids );
236
  }
237
  $curriculum[$course_id] = $_curriculum;
238
  }
 
239
  update_meta_cache( 'post', $meta_cache_ids );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
240
  LP_Cache::set_course_curriculum( $curriculum );
241
  LP_Cache::set_post_names( $post_names );
242
  }
250
  * @return array
251
  */
252
  function _learn_press_get_course_curriculum( $course_id, $force = false ) {
253
+ $curriculum = LP_Cache::get_course_curriculum( false, array() );
254
+ //$post_names = LP_Cache::get_post_names( false, array() );
255
+ if ( !array_key_exists( $course_id, $curriculum ) || $force ) {
256
  $curriculum = _learn_press_get_courses_curriculum( array( $course_id ), $force );
257
  if ( empty( $curriculum[$course_id] ) ) {
258
  $curriculum[$course_id] = array();
259
  }
 
260
  }
261
+ $_curriculum = $curriculum[$course_id];
262
+
263
+ return $_curriculum;
264
  }
265
 
266
  /**
297
  $format_ids = array_fill( 0, sizeof( $question_ids ), '%d' );
298
  $prepare_args = array_merge( array( '_lp_type', 'lp_question' ), $question_ids );
299
  $query = $wpdb->prepare( "
300
+ SELECT qa.question_answer_id, ID as id, pm.meta_value as type, qa.answer_data as answer_data, answer_order
301
+ FROM {$wpdb->posts} p
302
+ INNER JOIN {$wpdb->postmeta} pm ON pm.post_id = p.ID AND pm.meta_key = %s
303
+ INNER JOIN {$wpdb->prefix}learnpress_quiz_questions qq ON qq.question_id = p.ID
304
+ RIGHT JOIN {$wpdb->prefix}learnpress_question_answers qa ON qa.question_id = p.ID
305
+ WHERE qq.quiz_id IN (" . join( ',', $quiz_ids ) . ")
306
+ ORDER BY id, qq.question_order, answer_order ASC
307
+ ", $prepare_args );
308
  if ( $answers = $wpdb->get_results( $query ) ) {
309
  $question_id = 0;
310
  foreach ( $answers as $row ) {
370
  function learn_press_setup_user_course_data( $user_id, $course_id, $force = false ) {
371
  if ( is_array( $course_id ) ) {
372
  _learn_press_get_courses_curriculum( $course_id );
373
+ //_learn_press_parse_user_item_statuses( $user_id, $course_id );
374
+
375
  foreach ( $course_id as $cid ) {
376
  learn_press_setup_user_course_data( $user_id, $cid, $force );
377
  }
423
  if ( $item_ids ) {
424
  $in = implode( ', ', $item_ids );
425
  $query = $wpdb->prepare( "
426
+ SELECT * FROM {$wpdb->prefix}learnpress_user_items t1
427
+ WHERE user_id = %d
428
+ AND item_id = %d
429
+ UNION
430
+ (
431
+ SELECT * FROM {$wpdb->prefix}learnpress_user_items t2
432
+ WHERE user_id = %d AND ref_id = %d
433
+ AND user_item_id = (
434
+ SELECT MAX(user_item_id) FROM {$wpdb->prefix}learnpress_user_items
435
+ WHERE user_id = %d and ref_id = %d
436
+ AND item_id = t2.item_id
 
 
 
 
437
  )
438
+ AND item_id IN({$in})
439
+ )
440
  ORDER BY user_item_id ASC
441
+ ", $user_id, $course_id, $user_id, $course_id, $user_id, $course_id );
442
  } else {
443
  $query = $wpdb->prepare( "
444
+ SELECT * FROM {$wpdb->prefix}learnpress_user_items t1
 
445
  WHERE user_id = %d
446
  AND item_id = %d
447
+ ", $user_id, $course_id );
448
  }
449
  $items = $wpdb->get_results( $query );
450
 
451
  $item_statuses = LP_Cache::get_item_statuses( false, array() );
 
452
  foreach ( $item_ids as $id ) {
453
  if ( !array_key_exists( $id, $item_statuses ) || $force ) {
454
  $item_statuses[$user_id . '-' . $course_id . '-' . $id] = '';
455
  }
 
 
 
 
456
  }
457
  if ( $items ) {
458
  foreach ( $items as $item ) {
459
  $item_statuses[$user_id . '-' . $course_id . '-' . $item->item_id] = learn_press_validate_item_status( $item );
 
 
 
 
 
460
  }
461
  }
462
  LP_Cache::set_item_statuses( $item_statuses );
 
463
 
464
  do_action( "learn_press_parse_user_item_statuses", $user_id, $course_id );
465
  do_action( "learn_press_parse_user_item_statuses_{$user_id}_{$course_id}" );
468
  function learn_press_validate_item_status( $item ) {
469
  $end_time = $item->end_time !== '0000-00-00 00:00:00';
470
  $status = $end_time > 0 ? ( $item->item_type != LP_COURSE_CPT ? 'completed' : 'finished' ) : $item->status;
 
 
 
 
 
 
471
  if ( $end_time && !in_array( $item->status, array( 'completed', 'finished' ) ) ) {
472
  global $wpdb;
473
  $data = (array) $item;
541
  $data = LP_Cache::get_user_profile_orders( false, array() );
542
 
543
  if ( !array_key_exists( $user_id, $data ) ) {
544
+ $limit = absint( $limit );
545
+ $offset = absint( $paged - 1 ) * $limit;
546
+ $results = array();
547
+ $query = $wpdb->prepare( "
548
+ SELECT DISTINCT po.*, oi.order_id
 
 
 
 
549
  FROM {$wpdb->prefix}learnpress_order_items oi
550
  INNER JOIN {$wpdb->prefix}postmeta pm ON pm.post_id = oi.order_id AND pm.meta_key = %s AND pm.meta_value = %d
551
+ INNER JOIN {$wpdb->prefix}posts po ON po.ID = oi.order_id
552
+ WHERE po.post_type = %s ORDER BY ID DESC
553
+ ", '_user_id', $user_id, LP_ORDER_CPT );
 
 
 
554
  if ( $rows = $wpdb->get_results( $query ) ) {
555
  $results['total'] = count( $rows );
556
  $results['paged'] = $paged;
558
  $results['offset'] = $offset;
559
  $results['num_pages'] = ceil( $results['total'] / $limit );
560
  $rows = array_slice( $rows, $offset, $limit );
 
561
  foreach ( $rows as $row ) {
562
  $results['rows'][$row->ID] = $row;
 
 
563
  }
 
564
  }
565
 
566
  $data[$user_id] = $results;
568
  } else {
569
  $results = $data[$user_id];
570
  }
571
+
572
+
573
  return $results;
574
  }
575
 
627
  //
628
  //function learn_press_remove_course_comment() {
629
  // remove_post_type_support( 'lp_course', 'comments' );
630
+ //}
 
inc/lp-template-functions.php CHANGED
@@ -672,7 +672,62 @@ if ( !function_exists( 'learn_press_user_profile_tabs' ) ) {
672
  if ( !$user ) {
673
  $user = learn_press_get_current_user();
674
  }
675
- return LP_Profile::instance( $user->id )->get_tabs();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
676
  }
677
  }
678
 
@@ -683,11 +738,7 @@ if ( !function_exists( 'learn_press_output_user_profile_info' ) ) {
683
  * @param $user
684
  */
685
  function learn_press_output_user_profile_info( $user, $current, $tabs ) {
686
- learn_press_get_template( 'profile/info.php', array(
687
- 'user' => $user,
688
- 'tabs' => $tabs,
689
- 'current' => $current
690
- ) );
691
  }
692
  }
693
 
@@ -704,10 +755,7 @@ if ( !function_exists( 'learn_press_single_quiz_title' ) ) {
704
 
705
  if ( !function_exists( 'learn_press_after_quiz_question_title' ) ) {
706
  function learn_press_single_quiz_question_answer( $question_id = null, $quiz_id = null ) {
707
- learn_press_get_template( 'content-quiz/question-answer.php', array(
708
- 'question_id' => $question_id,
709
- 'quiz_id' => $quiz_id
710
- ) );
711
  }
712
  }
713
 
@@ -747,11 +795,8 @@ if ( !function_exists( 'learn_press_course_lesson_class' ) ) {
747
  return '';
748
  }
749
 
750
- if ( is_string( $class ) && $class ) {
751
- $class = preg_split( '!\s+!', $class );
752
- } else {
753
- $class = array();
754
- }
755
 
756
  $classes = array(
757
  'course-lesson course-item course-item-' . $lesson_id
@@ -800,11 +845,8 @@ if ( !function_exists( 'learn_press_course_quiz_class' ) ) {
800
  if ( !$course_id ) {
801
  $course_id = get_the_ID();
802
  }
803
- if ( is_string( $class ) && $class ) {
804
- $class = preg_split( '!\s+!', $class );
805
- } else {
806
- $class = array();
807
- }
808
 
809
  $course = learn_press_get_course( $course_id );
810
  if ( !$course ) {
@@ -827,10 +869,6 @@ if ( !function_exists( 'learn_press_course_quiz_class' ) ) {
827
  $classes[] = 'viewable';
828
  }
829
 
830
- if ( $course->is_final_quiz( $quiz_id ) ) {
831
- $classes[] = 'final-quiz';
832
- }
833
-
834
  $classes = array_unique( array_merge( $classes, $class ) );
835
 
836
  if ( $echo ) {
@@ -1135,10 +1173,7 @@ function learn_press_get_template_part( $slug, $name = '' ) {
1135
 
1136
  // Look in yourtheme/slug-name.php and yourtheme/learnpress/slug-name.php
1137
  if ( $name ) {
1138
- $template = locate_template( array(
1139
- "{$slug}-{$name}.php",
1140
- learn_press_template_path() . "/{$slug}-{$name}.php"
1141
- ) );
1142
  }
1143
 
1144
  // Get default slug-name.php
@@ -1291,7 +1326,7 @@ if ( !function_exists( 'learn_press_404_page' ) ) {
1291
 
1292
  if ( !function_exists( 'learn_press_course_curriculum_popup' ) ) {
1293
  function learn_press_course_curriculum_popup() {
1294
- learn_press_get_template( 'global/js-template.php' );
1295
  }
1296
  }
1297
 
@@ -1511,9 +1546,6 @@ if ( !function_exists( 'learn_press_get_profile_display_name' ) ) {
1511
  * @return string
1512
  */
1513
  function learn_press_get_profile_display_name( $user ) {
1514
- if ( empty( $user ) ) {
1515
- return '';
1516
- }
1517
  $info = get_userdata( $user->ID );
1518
  return $info ? $info->display_name : '';
1519
  }
@@ -1588,4 +1620,4 @@ function learn_press_fontend_js_template() {
1588
  learn_press_get_template( 'global/js-template.php' );
1589
  }
1590
 
1591
- add_action( 'wp_footer', 'learn_press_fontend_js_template' );
672
  if ( !$user ) {
673
  $user = learn_press_get_current_user();
674
  }
675
+ $course_endpoint = LP()->settings->get( 'profile_endpoints.profile-courses' );
676
+ if ( !$course_endpoint ) {
677
+ $course_endpoint = 'profile-courses';
678
+ }
679
+
680
+ $quiz_endpoint = LP()->settings->get( 'profile_endpoints.profile-quizzes' );
681
+ if ( !$quiz_endpoint ) {
682
+ $quiz_endpoint = 'profile-quizzes';
683
+ }
684
+
685
+ $order_endpoint = LP()->settings->get( 'profile_endpoints.profile-orders' );
686
+ if ( !$order_endpoint ) {
687
+ $order_endpoint = 'profile-orders';
688
+ }
689
+
690
+ $view_order_endpoint = LP()->settings->get( 'profile_endpoints' );
691
+ if ( !$view_order_endpoint ) {
692
+ $view_order_endpoint = 'order';
693
+ }
694
+
695
+ $defaults = array(
696
+ $course_endpoint => array(
697
+ 'title' => __( 'Courses', 'learnpress' ),
698
+ 'callback' => 'learn_press_profile_tab_courses_content'
699
+ ),
700
+ /*$quiz_endpoint => array(
701
+ 'title' => __( 'Quiz Results', 'learnpress' ),
702
+ 'callback' => 'learn_press_profile_tab_quizzes_content'
703
+ )*/
704
+ );
705
+
706
+ if ( $user->id == get_current_user_id() ) {
707
+ $defaults[$order_endpoint] = array(
708
+ 'title' => __( 'Orders', 'learnpress' ),
709
+ 'callback' => 'learn_press_profile_tab_orders_content'
710
+ );
711
+ }
712
+
713
+ $tabs = apply_filters( 'learn_press_user_profile_tabs', $defaults, $user );
714
+ if ( $user->id == get_current_user_id() ) {
715
+ $tabs['edit'] = array(
716
+ 'title' => apply_filters( 'learn_press_user_profile_tab_edit_title', __( 'Edit', 'learnpress' ) ),
717
+ 'callback' => 'learn_press_profile_tab_edit_content'
718
+ );
719
+ }
720
+
721
+
722
+ foreach ( $tabs as $slug => $opt ) {
723
+ if ( !empty( $defaults[$slug] ) ) {
724
+ continue;
725
+ }
726
+ LP()->query_vars[$slug] = $slug;
727
+ add_rewrite_endpoint( $slug, EP_ROOT | EP_PAGES );
728
+ }
729
+
730
+ return $tabs;
731
  }
732
  }
733
 
738
  * @param $user
739
  */
740
  function learn_press_output_user_profile_info( $user, $current, $tabs ) {
741
+ learn_press_get_template( 'profile/info.php', array( 'user' => $user, 'tabs' => $tabs, 'current' => $current ) );
 
 
 
 
742
  }
743
  }
744
 
755
 
756
  if ( !function_exists( 'learn_press_after_quiz_question_title' ) ) {
757
  function learn_press_single_quiz_question_answer( $question_id = null, $quiz_id = null ) {
758
+ learn_press_get_template( 'content-quiz/question-answer.php', array( 'question_id' => $question_id, 'quiz_id' => $quiz_id ) );
 
 
 
759
  }
760
  }
761
 
795
  return '';
796
  }
797
 
798
+ if ( is_string( $class ) && $class ) $class = preg_split( '!\s+!', $class );
799
+ else $class = array();
 
 
 
800
 
801
  $classes = array(
802
  'course-lesson course-item course-item-' . $lesson_id
845
  if ( !$course_id ) {
846
  $course_id = get_the_ID();
847
  }
848
+ if ( is_string( $class ) && $class ) $class = preg_split( '!\s+!', $class );
849
+ else $class = array();
 
 
 
850
 
851
  $course = learn_press_get_course( $course_id );
852
  if ( !$course ) {
869
  $classes[] = 'viewable';
870
  }
871
 
 
 
 
 
872
  $classes = array_unique( array_merge( $classes, $class ) );
873
 
874
  if ( $echo ) {
1173
 
1174
  // Look in yourtheme/slug-name.php and yourtheme/learnpress/slug-name.php
1175
  if ( $name ) {
1176
+ $template = locate_template( array( "{$slug}-{$name}.php", learn_press_template_path() . "/{$slug}-{$name}.php" ) );
 
 
 
1177
  }
1178
 
1179
  // Get default slug-name.php
1326
 
1327
  if ( !function_exists( 'learn_press_course_curriculum_popup' ) ) {
1328
  function learn_press_course_curriculum_popup() {
1329
+ learn_press_get_template( 'single-course/popup.php' );
1330
  }
1331
  }
1332
 
1546
  * @return string
1547
  */
1548
  function learn_press_get_profile_display_name( $user ) {
 
 
 
1549
  $info = get_userdata( $user->ID );
1550
  return $info ? $info->display_name : '';
1551
  }
1620
  learn_press_get_template( 'global/js-template.php' );
1621
  }
1622
 
1623
+ add_action( 'wp_footer', 'learn_press_fontend_js_template' );
inc/lp-template-hooks.php CHANGED
@@ -123,9 +123,6 @@ add_action( 'learn_press_order_received', 'learn_press_order_details_table', 5 )
123
  add_action( 'learn_press_before_template_part', 'learn_press_generate_template_information', 999, 4 );
124
 
125
 
126
- add_action('learn_press_after_content_item', 'learn_press_course_nav_items', 10, 3);
127
- add_action('learn_press_after_content_item', 'learn_press_lesson_comment_form', 10, 3);
128
-
129
  /*
130
  add_action( 'learn_press_single_quiz_summary', 'learn_press_single_quiz_preview_mode', 5 );
131
  add_action( 'learn_press_single_quiz_summary', 'learn_press_single_quiz_left_start_wrap', 10 );
123
  add_action( 'learn_press_before_template_part', 'learn_press_generate_template_information', 999, 4 );
124
 
125
 
 
 
 
126
  /*
127
  add_action( 'learn_press_single_quiz_summary', 'learn_press_single_quiz_preview_mode', 5 );
128
  add_action( 'learn_press_single_quiz_summary', 'learn_press_single_quiz_left_start_wrap', 10 );
inc/order/class-lp-order.php CHANGED
@@ -107,17 +107,16 @@ class LP_Order {
107
  * Updates order to new status if needed
108
  *
109
  * @param mixed $new_status
110
- * @param bool $force Force to update/trigger action even the status is not changed
111
  *
112
  * @return bool
113
  * @throws Exception
114
  */
115
- public function update_status( $new_status = 'pending', $force = false ) {
116
  global $post;
117
  $new_status = 'lp-' === substr( $new_status, 0, 3 ) ? substr( $new_status, 3 ) : $new_status;
118
  $old_status = $this->get_status();
119
 
120
- if ( ( ( $new_status !== $old_status ) || $force ) && in_array( $new_status, array_keys( learn_press_get_order_statuses( false ) ) ) ) {
121
  // Update the order
122
  global $wpdb;
123
  $updated = $wpdb->update( $wpdb->posts, array( 'post_status' => 'lp-' . $new_status ), array( 'ID' => $this->id ), array( '%s' ) );
@@ -173,29 +172,12 @@ class LP_Order {
173
  * @return mixed|void
174
  */
175
  public function get_order_status() {
176
- $statuses = learn_press_get_order_statuses();
177
- $status = '';
178
- if ( !empty( $statuses[$this->post_status] ) ) {
179
- $status = str_replace( 'lp-', '', $this->post_status );
180
- } else {
181
- $status = $this->post_status;
182
- }
183
- return apply_filters( 'learn_press_get_order_status', $status, $this );
184
- }
185
-
186
- public function get_order_status_html() {
187
  $statuses = learn_press_get_order_statuses();
188
  $status = '';
189
  if ( !empty( $statuses[$this->post_status] ) ) {
190
  $status = $statuses[$this->post_status];
191
- } elseif ( $this->post_status == 'trash' ) {
192
- $status = __( 'Removed', 'learnpress' );
193
- } else {
194
- $status = ucfirst( $this->post_status );
195
  }
196
- $class = 'order-status order-status-' . sanitize_title( $status );
197
- $html = sprintf( '<span class="%s">%s</span>', apply_filters( 'learn_press_order_status_class', $class, $status, $this ), $status, $this );
198
- return apply_filters( 'learn_press_order_status_html', $html, $this );
199
  }
200
 
201
  /**
@@ -264,9 +246,10 @@ class LP_Order {
264
  return $customer_name;
265
  }
266
 
267
- public function customer_exists() {
268
- $user_id = $this->user_id;
269
- return false !== get_userdata( $user_id );
 
270
  }
271
 
272
  /**
@@ -354,6 +337,7 @@ class LP_Order {
354
  }
355
 
356
  public function get_user( $field = '' ) {
 
357
  $user = learn_press_get_user( $this->user_id );
358
  if ( $field ) {
359
  return $user->{$field};
@@ -361,33 +345,9 @@ class LP_Order {
361
  return $user;
362
  }
363
 
364
- public function get_users() {
365
- $users = false;
366
- if ( $this->is_multi_users() ) {
367
- $users = get_post_meta( $this->id, '_user_id' );
368
- }
369
- return $users;
370
- }
371
-
372
- public function dropdown_users() {
373
- $order_users = $this->get_users();
374
- $users = get_users( array() );
375
- echo '<select name="order-customer[]" id="order-customer" multiple="multiple">';
376
- foreach ( (array) $users as $user ) {
377
- $user->ID = (int) $user->ID;
378
- if ( in_array( $user->ID, $order_users ) ) {
379
- $found_selected = true;
380
- } else {
381
- $found_selected = false;
382
- }
383
- echo sprintf( '<option value="%d"%s>%s</option>', $user->ID, selected( $found_selected, true, false ), $user->user_login );
384
- }
385
- echo '</select>';
386
- }
387
-
388
  public function __get( $key ) {
389
  $value = null;
390
- if ( !property_exists( $this, $key ) ) {
391
  $value = get_post_meta( $this->id, '_' . $key, true );
392
  }
393
  return $value;
@@ -446,16 +406,16 @@ class LP_Order {
446
  return apply_filters( 'learn_press_view_order_url', $view_order_url, $this );
447
  }
448
 
449
- public function get_cancel_order_url( $force = false ) {
450
- $user = learn_press_get_current_user();
451
- $url = learn_press_user_profile_link( $user->id, LP()->settings->get( 'profile_endpoints.profile-orders' ) );
452
- if ( !$force ) {
453
- $url = add_query_arg( 'cancel-order', $this->id, $url );
454
- } else {
455
- $url = add_query_arg( 'cancelled-order', $this->id, $url );
456
- }
457
- return apply_filters( 'learn_press_cancel_order_url', wp_nonce_url( $url, 'cancel-order', 'lp-nonce' ) );
458
- }
459
 
460
  public function add_note( $note = null ) {
461
  if ( is_user_logged_in() ) {
@@ -486,73 +446,6 @@ class LP_Order {
486
  return apply_filters( 'learn_press_order_user_name', sprintf( _x( '%1$s', 'full name', 'learnpress' ), $this->get_user( 'user_login' ) ) );
487
  }
488
 
489
- /**
490
- * Check to see if this order is for multi users
491
- *
492
- * @since 2.1.5
493
- *
494
- * @return bool
495
- */
496
- public function is_multi_users() {
497
- $multiple = $this->get_status() == 'auto-draft' && 'yes' == learn_press_get_request( 'multi-users' );
498
- $multiple = $multiple || ( 'yes' == get_post_meta( $this->id, '_lp_multi_users', true ) );
499
- return $multiple;
500
- }
501
-
502
- /**
503
- * Print the list of all users has assigned to this order
504
- * in case this order is for multi users
505
- *
506
- * @since 2.1.5
507
- */
508
- public function print_users() {
509
- if ( $user_ids = get_post_meta( $this->id, '_user_id' ) ) {
510
- global $wpdb;
511
- $format_ids = array_fill( 0, sizeof( $user_ids ), '%d' );
512
- $users = $wpdb->get_results( $wpdb->prepare( "SELECT user_login, user_email FROM {$wpdb->users} WHERE ID IN(" . join( ',', $format_ids ) . ")", $user_ids ) );
513
- $size = sizeof( $users );
514
- foreach ( $users as $i => $user ) {
515
- printf( '<strong>%s</strong> ( %s )', $user->user_login, $user->user_email );
516
- if ( $i < $size - 1 ) {
517
- echo ', ';
518
- }
519
- }
520
- } else {
521
- _e( 'No user assigned', 'learnpress' );
522
- }
523
- }
524
-
525
- /**
526
- * Get email of user has bought this order.
527
- * In case this order is for multi users return an array with multi email addresses.
528
- *
529
- * @since 2.1.5
530
- *
531
- * @return mixed|array
532
- */
533
- public function get_user_data() {
534
- $data = false;
535
- if ( $user_ids = get_post_meta( $this->id, '_user_id' ) ) {
536
- global $wpdb;
537
- $format = array_fill( 0, sizeof( $user_ids ), '%d' );
538
- $sql = "
539
- SELECT ID, user_email as email, display_name as name
540
- FROM {$wpdb->users} u
541
- WHERE ID IN(" . join( ', ', $format ) . ")
542
- ";
543
- $data = $wpdb->get_results( $wpdb->prepare( $sql, $user_ids ), OBJECT_K );
544
- }
545
- return $data;
546
- }
547
-
548
- public function get_user_email() {
549
- $email = false;
550
- if ( $user = learn_press_get_user( $this->user_id ) ) {
551
- $email = $user->user_email;
552
- }
553
- return $email;
554
- }
555
-
556
  /**
557
  * Get an instance of LP_Order by post ID or WP_Post object
558
  *
107
  * Updates order to new status if needed
108
  *
109
  * @param mixed $new_status
 
110
  *
111
  * @return bool
112
  * @throws Exception
113
  */
114
+ public function update_status( $new_status = 'pending' ) {
115
  global $post;
116
  $new_status = 'lp-' === substr( $new_status, 0, 3 ) ? substr( $new_status, 3 ) : $new_status;
117
  $old_status = $this->get_status();
118
 
119
+ if ( $new_status !== $old_status && in_array( $new_status, array_keys( learn_press_get_order_statuses( false ) ) ) ) {
120
  // Update the order
121
  global $wpdb;
122
  $updated = $wpdb->update( $wpdb->posts, array( 'post_status' => 'lp-' . $new_status ), array( 'ID' => $this->id ), array( '%s' ) );
172
  * @return mixed|void
173
  */
174
  public function get_order_status() {
 
 
 
 
 
 
 
 
 
 
 
175
  $statuses = learn_press_get_order_statuses();
176
  $status = '';
177
  if ( !empty( $statuses[$this->post_status] ) ) {
178
  $status = $statuses[$this->post_status];
 
 
 
 
179
  }
180
+ return apply_filters( 'learn_press_get_order_status', $status, $this );
 
 
181
  }
182
 
183
  /**
246
  return $customer_name;
247
  }
248
 
249
+ public function customer_exists(){
250
+ $user_id = $this->user_id;
251
+ $user = learn_press_get_user( $user_id );
252
+ return $user->is_exists();
253
  }
254
 
255
  /**
337
  }
338
 
339
  public function get_user( $field = '' ) {
340
+
341
  $user = learn_press_get_user( $this->user_id );
342
  if ( $field ) {
343
  return $user->{$field};
345
  return $user;
346
  }
347
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
348
  public function __get( $key ) {
349
  $value = null;
350
+ if ( !isset( $this->{$key} ) ) {
351
  $value = get_post_meta( $this->id, '_' . $key, true );
352
  }
353
  return $value;
406
  return apply_filters( 'learn_press_view_order_url', $view_order_url, $this );
407
  }
408
 
409
+ public function get_cancel_order_url( $force = false ) {
410
+ $user = learn_press_get_current_user();
411
+ $url = learn_press_user_profile_link( $user->id, LP()->settings->get( 'profile_endpoints.profile-orders' ) );
412
+ if ( ! $force ) {
413
+ $url = add_query_arg( 'cancel-order', $this->id, $url );
414
+ } else {
415
+ $url = add_query_arg( 'cancelled-order', $this->id, $url );
416
+ }
417
+ return apply_filters( 'learn_press_cancel_order_url', wp_nonce_url( $url, 'cancel-order', 'lp-nonce' ) );
418
+ }
419
 
420
  public function add_note( $note = null ) {
421
  if ( is_user_logged_in() ) {
446
  return apply_filters( 'learn_press_order_user_name', sprintf( _x( '%1$s', 'full name', 'learnpress' ), $this->get_user( 'user_login' ) ) );
447
  }
448
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
449
  /**
450
  * Get an instance of LP_Order by post ID or WP_Post object
451
  *
inc/order/lp-order-functions.php CHANGED
@@ -506,55 +506,6 @@ function learn_press_get_orders( $args = array() ) {
506
  return apply_filters( 'learn_press_get_orders', $orders, $args );
507
  }
508
 
509
- /**
510
- * Count orders by it's status
511
- *
512
- * @param array $args
513
- *
514
- * @return array
515
- */
516
- function learn_press_count_orders( $args = array() ) {
517
- if ( is_string( $args ) ) {
518
- $args = array( 'status' => $args );
519
- } else {
520
- $args = wp_parse_args(
521
- $args,
522
- array(
523
- 'status' => ''
524
- )
525
- );
526
- }
527
- global $wpdb;
528
- $statuses = $args['status'];
529
- if ( !$statuses ) {
530
- $statuses = learn_press_get_register_order_statuses();
531
- $statuses = array_keys( $statuses );
532
- }
533
- settype( $statuses, 'array' );
534
- $size_of_status = sizeof( $statuses );
535
- foreach ( $statuses as $k => $status ) {
536
- $statuses[$k] = !preg_match( '~^lp-~', $status ) ? 'lp-' . $status : $status;
537
- }
538
- $format = array_fill( 0, $size_of_status, '%s' );
539
- $counts = array_fill_keys( $statuses, 0 );
540
- $statuses[] = LP_ORDER_CPT;
541
- $query = $wpdb->prepare( "
542
- SELECT COUNT(ID) AS count, post_status AS status
543
- FROM {$wpdb->posts} o
544
- WHERE post_status IN(" . join( ',', $format ) . ")
545
- AND post_type = %s
546
- GROUP BY o.post_status
547
- ", $statuses );
548
- if ( $results = $wpdb->get_results( $query ) ) {
549
- foreach ( $results as $result ) {
550
- if ( array_key_exists( $result->status, $counts ) ) {
551
- $counts[$result->status] = absint( $result->count );
552
- }
553
- }
554
- }
555
- return $size_of_status > 1 ? $counts : reset( $counts );
556
- }
557
-
558
  function learn_press_get_course_price_text( $price, $course_id ) {
559
  if ( !$price && LP_COURSE_CPT == get_post_type( $course_id ) ) {
560
  $price = __( 'Free', 'learnpress' );
@@ -698,18 +649,16 @@ function learn_press_get_order_status_label( $order_id = 0 ) {
698
  return !empty( $statuses[$status] ) ? $statuses[$status] : __( 'Pending', 'learnpress' );
699
  }
700
 
701
- function learn_press_get_order_statuses( $prefix = true, $status_only = false ) {
702
- $register_statues = learn_press_get_register_order_statuses();
703
- if ( !$prefix ) {
704
- $order_statuses = array();
705
- foreach ( $register_statues as $k => $v ) {
706
- $k = preg_replace( '~^lp-~', '', $k );
707
- $order_statuses[$k] = $v;
708
  }
709
- } else {
710
- $order_statuses = $register_statues;
711
- }
712
- /*$order_statuses = array(
713
  $prefix . 'pending' => _x( 'Pending', 'Order status', 'learnpress' ),
714
  $prefix . 'processing' => _x( 'Processing', 'Order status', 'learnpress' ),
715
  $prefix . 'completed' => _x( 'Completed', 'Order status', 'learnpress' ),
@@ -717,12 +666,7 @@ function learn_press_get_order_statuses( $prefix = true, $status_only = false )
717
  // $prefix . 'refunded' => _x( 'Refunded', 'Order status', 'learnpress' ),
718
  // $prefix . 'failed' => _x( 'Failed', 'Order status', 'learnpress' ),
719
  // $prefix . 'on-hold' => _x( 'On Hold', 'Order status', 'learnpress' ),
720
- );*/
721
- $order_statuses = wp_list_pluck( $order_statuses, 'label' );
722
-
723
- if ( $status_only ) {
724
- $order_statuses = array_keys( $order_statuses );
725
- }
726
 
727
  return apply_filters( 'learn_press_order_statuses', $order_statuses );
728
  }
506
  return apply_filters( 'learn_press_get_orders', $orders, $args );
507
  }
508
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
509
  function learn_press_get_course_price_text( $price, $course_id ) {
510
  if ( !$price && LP_COURSE_CPT == get_post_type( $course_id ) ) {
511
  $price = __( 'Free', 'learnpress' );
649
  return !empty( $statuses[$status] ) ? $statuses[$status] : __( 'Pending', 'learnpress' );
650
  }
651
 
652
+ function learn_press_get_order_statuses( $prefix = true ) {
653
+ $prefix = $prefix ? 'lp-' : '';
654
+ /*$register_statues = learn_press_get_register_order_statuses();
655
+ $order_statuses= array();
656
+ foreach($register_statues as $k => $v){
657
+ if($prefix){
658
+
659
  }
660
+ }*/
661
+ $order_statuses = array(
 
 
662
  $prefix . 'pending' => _x( 'Pending', 'Order status', 'learnpress' ),
663
  $prefix . 'processing' => _x( 'Processing', 'Order status', 'learnpress' ),
664
  $prefix . 'completed' => _x( 'Completed', 'Order status', 'learnpress' ),
666
  // $prefix . 'refunded' => _x( 'Refunded', 'Order status', 'learnpress' ),
667
  // $prefix . 'failed' => _x( 'Failed', 'Order status', 'learnpress' ),
668
  // $prefix . 'on-hold' => _x( 'On Hold', 'Order status', 'learnpress' ),
669
+ );
 
 
 
 
 
670
 
671
  return apply_filters( 'learn_press_order_statuses', $order_statuses );
672
  }
inc/question/class-lp-question-factory.php CHANGED
@@ -60,7 +60,6 @@ class LP_Question_Factory {
60
  return self::$_instances[$the_id];
61
  }
62
 
63
-
64
  /**
65
  * @param string
66
  *
@@ -161,7 +160,6 @@ class LP_Question_Factory {
161
  add_action( 'learn_press_after_quiz_question_title', array( __CLASS__, 'show_answer' ), 100, 2 );
162
  add_action( 'learn_press_after_question_wrap', array( __CLASS__, 'show_hint' ), 100, 2 );
163
  add_action( 'learn_press_after_question_wrap', array( __CLASS__, 'show_explanation' ), 110, 2 );
164
- add_action( 'delete_post', array( __CLASS__, 'delete_question' ), 10, 2 );
165
 
166
  LP_Question_Factory::add_template( 'multi-choice-option', LP_Question_Multi_Choice::admin_js_template() );
167
  LP_Question_Factory::add_template( 'single-choice-option', LP_Question_Single_Choice::admin_js_template() );
@@ -169,19 +167,6 @@ class LP_Question_Factory {
169
  do_action( 'learn_press_question_factory_init', __CLASS__ );
170
  }
171
 
172
-
173
- public static function delete_question( $post_id, $force=false ) {
174
- global $wpdb;
175
- if( 'lp_question' === get_post_type($post_id) ) {
176
- // remove question answears
177
- $sql = 'DELETE FROM `'.$wpdb->prefix.'learnpress_question_answers` WHERE `question_id` = '.$post_id;
178
- $wpdb->query($sql);
179
- // remove question in quiz
180
- $sql = 'DELETE FROM `'.$wpdb->prefix.'learnpress_quiz_questions` WHERE `question_id` = '.$post_id;
181
- $wpdb->query($sql);
182
- }
183
- }
184
-
185
  public static function show_answer( $id, $quiz_id ) {
186
 
187
  $quiz = LP_Quiz::get_quiz( $quiz_id );
@@ -314,7 +299,7 @@ class LP_Question_Factory {
314
  }
315
 
316
  public static function admin_assets() {
317
- //LP_Assets::enqueue_style( 'learn-press-meta-box-question' );
318
  //LP_Assets::enqueue_script( 'learn-press-meta-box-question', false, array( 'learn-press-admin' ) );
319
  }
320
 
@@ -392,4 +377,4 @@ class LP_Question_Factory {
392
  }
393
  }
394
 
395
- LP_Question_Factory::init();
60
  return self::$_instances[$the_id];
61
  }
62
 
 
63
  /**
64
  * @param string
65
  *
160
  add_action( 'learn_press_after_quiz_question_title', array( __CLASS__, 'show_answer' ), 100, 2 );
161
  add_action( 'learn_press_after_question_wrap', array( __CLASS__, 'show_hint' ), 100, 2 );
162
  add_action( 'learn_press_after_question_wrap', array( __CLASS__, 'show_explanation' ), 110, 2 );
 
163
 
164
  LP_Question_Factory::add_template( 'multi-choice-option', LP_Question_Multi_Choice::admin_js_template() );
165
  LP_Question_Factory::add_template( 'single-choice-option', LP_Question_Single_Choice::admin_js_template() );
167
  do_action( 'learn_press_question_factory_init', __CLASS__ );
168
  }
169
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
  public static function show_answer( $id, $quiz_id ) {
171
 
172
  $quiz = LP_Quiz::get_quiz( $quiz_id );
299
  }
300
 
301
  public static function admin_assets() {
302
+ LP_Assets::enqueue_style( 'learn-press-meta-box-question' );
303
  //LP_Assets::enqueue_script( 'learn-press-meta-box-question', false, array( 'learn-press-admin' ) );
304
  }
305
 
377
  }
378
  }
379
 
380
+ LP_Question_Factory::init();
inc/quiz/class-lp-quiz-factory.php CHANGED
@@ -30,15 +30,6 @@ class LP_Quiz_Factory {
30
  LP_Request_Handler::register_ajax( $k, array( __CLASS__, $v ) );
31
  }
32
  add_action( 'learn_press_after_single_quiz_summary', array( __CLASS__, 'output_quiz_params' ) );
33
- add_action( 'delete_post', array( __CLASS__, 'delete_quiz' ), 10, 2 );
34
- }
35
-
36
- public static function delete_quiz( $post_id, $force=false ) {
37
- global $wpdb;
38
- if('lp_quiz' === get_post_type($post_id) ){
39
- $sql = 'DELETE FROM `'.$wpdb->prefix.'learnpress_quiz_questions` WHERE `quiz_id` = '.$post_id;
40
- $wpdb->query($sql);
41
- }
42
  }
43
 
44
  public static function output_quiz_params( $quiz ) {
@@ -217,7 +208,7 @@ class LP_Quiz_Factory {
217
  $result = $user->finish_quiz( $quiz_id, $course_id, $args );
218
  if ( $result ) {
219
  if ( !empty( $args['auto_finish'] ) ) {
220
- learn_press_add_message( __( 'Your quiz has finished automatically', 'learnpress' ) );
221
  } else {
222
  learn_press_add_message( __( 'You have finished quiz', 'learnpress' ) );
223
  }
@@ -307,7 +298,7 @@ class LP_Quiz_Factory {
307
  learn_press_update_user_item_meta( $history->history_id, 'question_checked', $checked );
308
  }
309
  }
310
- } else {
311
  }
312
  learn_press_setup_user_course_data( $user_id, $course_id );
313
  $question = LP_Question_Factory::get_question( $question_id );
@@ -320,15 +311,15 @@ class LP_Quiz_Factory {
320
  }
321
 
322
  public static function _current_question( $question_id, $quiz_id, $course_id, $user_id ) {
323
- $user = learn_press_get_current_user();
324
- $history = $user->get_quiz_results( $quiz_id, $course_id, true );
325
 
326
  if ( !empty( $_REQUEST['lp-ajax'] ) && $_REQUEST['lp-ajax'] == 'fetch-question' ) {
327
  $question_id = !empty( $_REQUEST['id'] ) ? $_REQUEST['id'] : $question_id;
328
  learn_press_update_user_item_meta( $history->history_id, 'lp_current_question_after_close', $question_id );
329
  }
330
 
331
- if ( !empty( $_REQUEST['lp-update-current-question'] ) ) {
332
  $current_id = absint( $_REQUEST['id'] );
333
  learn_press_update_user_item_meta( $history->history_id, 'lp_current_question_after_close', $current_id );
334
  }
@@ -368,7 +359,6 @@ class LP_Quiz_Factory {
368
  * @return mixed
369
  */
370
  public static function _verify_nonce( $action, $error_message = false ) {
371
- do_action( 'learn_press_before_verify_quiz_action_none' );
372
  $action = str_replace( '_', '-', $action );
373
  $course_id = learn_press_get_request( 'course_id', 0 );
374
  $quiz_id = learn_press_get_request( 'quiz_id', 0 );
@@ -380,16 +370,16 @@ class LP_Quiz_Factory {
380
  if ( $error_message === false ) {
381
  $error_message = array( 'title' => __( 'Error', 'learnpress' ), 'message' => sprintf( __( 'Action %s failed! Please contact site\'s administrator for more information.', 'learnpress' ), $action ) );
382
  }
383
- if ( learn_press_is_ajax() ) {
384
  learn_press_send_json(
385
  array(
386
  'result' => 'error',
387
  'message' => $error_message
388
  )
389
  );
390
- } else {
391
- learn_press_add_message( $error_message['message'] );
392
- wp_redirect( learn_press_get_current_url() );
393
  exit();
394
  }
395
  }
30
  LP_Request_Handler::register_ajax( $k, array( __CLASS__, $v ) );
31
  }
32
  add_action( 'learn_press_after_single_quiz_summary', array( __CLASS__, 'output_quiz_params' ) );
 
 
 
 
 
 
 
 
 
33
  }
34
 
35
  public static function output_quiz_params( $quiz ) {
208
  $result = $user->finish_quiz( $quiz_id, $course_id, $args );
209
  if ( $result ) {
210
  if ( !empty( $args['auto_finish'] ) ) {
211
+ learn_press_add_message( __( 'You quiz has finished automatically', 'learnpress' ) );
212
  } else {
213
  learn_press_add_message( __( 'You have finished quiz', 'learnpress' ) );
214
  }
298
  learn_press_update_user_item_meta( $history->history_id, 'question_checked', $checked );
299
  }
300
  }
301
+ }else{
302
  }
303
  learn_press_setup_user_course_data( $user_id, $course_id );
304
  $question = LP_Question_Factory::get_question( $question_id );
311
  }
312
 
313
  public static function _current_question( $question_id, $quiz_id, $course_id, $user_id ) {
314
+ $user = learn_press_get_current_user();
315
+ $history = $user->get_quiz_results( $quiz_id, $course_id, true );
316
 
317
  if ( !empty( $_REQUEST['lp-ajax'] ) && $_REQUEST['lp-ajax'] == 'fetch-question' ) {
318
  $question_id = !empty( $_REQUEST['id'] ) ? $_REQUEST['id'] : $question_id;
319
  learn_press_update_user_item_meta( $history->history_id, 'lp_current_question_after_close', $question_id );
320
  }
321
 
322
+ if (!empty($_REQUEST['lp-update-current-question'])) {
323
  $current_id = absint( $_REQUEST['id'] );
324
  learn_press_update_user_item_meta( $history->history_id, 'lp_current_question_after_close', $current_id );
325
  }
359
  * @return mixed
360
  */
361
  public static function _verify_nonce( $action, $error_message = false ) {
 
362
  $action = str_replace( '_', '-', $action );
363
  $course_id = learn_press_get_request( 'course_id', 0 );
364
  $quiz_id = learn_press_get_request( 'quiz_id', 0 );
370
  if ( $error_message === false ) {
371
  $error_message = array( 'title' => __( 'Error', 'learnpress' ), 'message' => sprintf( __( 'Action %s failed! Please contact site\'s administrator for more information.', 'learnpress' ), $action ) );
372
  }
373
+ if(learn_press_is_ajax()) {
374
  learn_press_send_json(
375
  array(
376
  'result' => 'error',
377
  'message' => $error_message
378
  )
379
  );
380
+ }else{
381
+ learn_press_add_message($error_message['message']);
382
+ wp_redirect(learn_press_get_current_url());
383
  exit();
384
  }
385
  }
inc/shortcodes/archive-courses.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Shortcodes to display archive courses
4
+ */
5
+
6
+ defined( 'ABSPATH' ) || exit();
7
+
8
+ /**
9
+ * Shortcode to display all newest courses
10
+ *
11
+ * @param mixed|array
12
+ *
13
+ * @return string
14
+ */
15
+ function learn_press_newest_courses_shortcode( $atts ) {
16
+ return '';
17
+ }
18
+
19
+ add_shortcode( 'learn_press_newest_courses', 'learn_press_newest_courses_shortcode' );
20
+
21
+ /**
22
+ * Shortcode to display all free courses
23
+ *
24
+ * @param mixed|array
25
+ *
26
+ * @return string
27
+ */
28
+ function learn_press_free_courses_shortcode( $atts ) {
29
+ return '';
30
+ }
31
+
32
+ add_shortcode( 'learn_press_free_courses', 'learn_press_free_courses_shortcode' );
33
+
34
+ /**
35
+ * Shortcode to display paid courses
36
+ *
37
+ * @param mixed|array
38
+ *
39
+ * @return string
40
+ */
41
+ function learn_press_paid_courses_shortcode( $atts ) {
42
+ return '';
43
+ }
44
+
45
+ add_shortcode( 'learn_press_paid_courses', 'learn_press_paid_courses_shortcode' );
inc/shortcodes/class-lp-abstract-archive-shortcode.php ADDED
@@ -0,0 +1,354 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Shortcodes to display archive courses
4
+ */
5
+
6
+ /**
7
+ * Warning: this is a abstract class, do not create instance directly.
8
+ * Important note: It's is my the very first WP plugin, if find out any issue please report me (Minhlv) to fix it out ^^
9
+ */
10
+
11
+ /**
12
+ * Shortcode to display list of courses by custom query
13
+ * ------GENERAL SYNTAX----------
14
+ * [shortcode_name
15
+ * title=""
16
+ * limit="10"
17
+ * display="5"
18
+ * show_desc="true"
19
+ * show_thumbnail="true"
20
+ * show_enrolled_students="true"
21
+ * show_teacher="true"
22
+ * css_class=""
23
+ * template = "list"
24
+ *
25
+ * items=""
26
+ * items_desktop="", //null or number
27
+ * items_desktop_small="",
28
+ * itemsTablet= "",
29
+ * items_tablet_small="",
30
+ * items_mobile= "",
31
+ * single_item= "false",
32
+ * items_scale_up= "true",
33
+ * slide_speed= "200",
34
+ * pagination_Speed= "800",
35
+ * rewind_speed= "1000",
36
+ * auto_play= "false",
37
+ * stop_on_hover= "true",
38
+ * navigation= "true",
39
+ * navigation_text_next= "&rarr;",
40
+ * navigation_text_prev= "&larr;",
41
+ * scroll_per_age= "false",
42
+ * pagination= "false",
43
+ * auto_height= "false"
44
+ * ]
45
+ *
46
+ */
47
+
48
+ /**
49
+ * -----OPTIONS-------
50
+ * -Title:
51
+ * the title of collection
52
+ * empty by default
53
+ *
54
+ * -Limit:
55
+ * number, limit of the records will be queried by get_courses function
56
+ *
57
+ * -Display:
58
+ * number of items display on each carousel item
59
+ * only used in list template
60
+ *
61
+ * -show_thumbnail:
62
+ * set whether show course cover picture or not
63
+ * "true" by default
64
+ *
65
+ * -show_desc
66
+ * set whether show course description
67
+ * "false" by default
68
+ *
69
+ * -show_enrolled_students
70
+ * set whether show course's enrolled students
71
+ * "true" by default
72
+ *
73
+ * -show_teacher:
74
+ * set whether show course's instructor
75
+ * "true" by default
76
+ *
77
+ * -css_class:
78
+ * additional custom css class
79
+ *
80
+ * -Templates:
81
+ * there are 3 standard templates is list, grids and cards (list by default)
82
+ * you can also add your custom template by adding php file into templates folder
83
+ *
84
+ * - options for owl carousel (from items to the end)
85
+ * shortcode support some owl carousel slider options
86
+ *
87
+ * please take a look to owl-carousel docs to understand
88
+ * documentation: http://owlgraphic.com/owlcarousel/#customizing
89
+ *
90
+ * the responsive options (items to mobile_items) use short code parameters as the second
91
+ * element of owl carousel option array
92
+ * navigation_text_prev and navigation_text_next is options for navigation button's content
93
+ * by default is left arrow and right arrow
94
+ * -----USAGE----------
95
+ * create class that extends LP_Archive_Courses_Shortcode
96
+ * implement get_course methods which return array of LP_Course to be display
97
+ *
98
+ * override optional methods
99
+ * add_default_atts to modify default attributes
100
+ */
101
+
102
+ defined( 'ABSPATH' ) || exit();
103
+
104
+ if ( !class_exists( 'LP_Archive_Courses_Shortcode' ) ) {
105
+ /**
106
+ * Class LP_AJAX
107
+ */
108
+ class LP_Archive_Courses_Shortcode {
109
+ /**
110
+ * @var array null shortcode attribute
111
+ */
112
+ protected $atts = null;
113
+
114
+ /**
115
+ * @var string null template directory
116
+ */
117
+ protected $template_dir = null;
118
+
119
+ /**
120
+ * @var string shortcode name
121
+ */
122
+
123
+ protected $name = "";
124
+
125
+ /**
126
+ * @var string template file name
127
+ */
128
+ protected $template_file_name = null;
129
+
130
+ /**
131
+ * @var null|string shortcode script url
132
+ */
133
+ protected $script_url = null;
134
+
135
+ /**
136
+ * get shortcode be initial
137
+ * call once
138
+ */
139
+ public function init() {
140
+ $this->init_const();
141
+ $this->enqueue_style();
142
+ add_shortcode( $this->name, array( $this, 'shortcode_output' ) );
143
+ }
144
+
145
+ /**
146
+ * get learn press course from wordpress post object
147
+ *
148
+ * @param object -reference $post wordpress post object
149
+ *
150
+ * @return LP_Course course
151
+ */
152
+ public function get_lp_course( $post ) {
153
+ $id = $post->ID;
154
+ $course = null;
155
+ if ( !empty( $id ) ) {
156
+ $course = new LP_Course( $id );
157
+ }
158
+ return $course;
159
+ }
160
+
161
+ /**
162
+ * get shortcode output
163
+ * main function of shortcode
164
+ */
165
+ public function shortcode_output( $atts ) {
166
+ $default_atts = $this->default_atts();
167
+ $a = shortcode_atts( $default_atts, $atts );
168
+ $a = $this->parse_atts( $a );
169
+
170
+ $template_file_name = $this->get_template( $a );
171
+ $courses = $this->get_courses( $a );
172
+
173
+ if ( empty( $courses ) ) return;
174
+ $output = $this->render( $courses, $a, $template_file_name );
175
+ return $output;
176
+ }
177
+
178
+ /**
179
+ * parse shortcode input array
180
+ *
181
+ * @param array $a
182
+ *
183
+ * @return array well parsed shortcode attributes
184
+ */
185
+ public function parse_atts( $a ) {
186
+ $a['show_desc'] = filter_var( $a['show_desc'], FILTER_VALIDATE_BOOLEAN );
187
+ $a['show_lesson'] = filter_var( $a['show_lesson'], FILTER_VALIDATE_BOOLEAN );
188
+ $a['show_thumbnail'] = filter_var( $a['show_thumbnail'], FILTER_VALIDATE_BOOLEAN );
189
+ $a['show_enrolled_students'] = filter_var( $a['show_enrolled_students'], FILTER_VALIDATE_BOOLEAN );
190
+ $a['show_teacher'] = filter_var( $a['show_teacher'], FILTER_VALIDATE_BOOLEAN );
191
+ $a['show_actions'] = filter_var( $a['show_actions'], FILTER_VALIDATE_BOOLEAN );
192
+ $a['show_action_view_course'] = filter_var( $a['show_action_view_course'], FILTER_VALIDATE_BOOLEAN );
193
+ $a['show_price'] = filter_var( $a['show_price'], FILTER_VALIDATE_BOOLEAN );
194
+ $a['limit'] = intval( $a['limit'] );
195
+ $a['display'] = intval( $a['display'] );
196
+
197
+ return $a;
198
+ }
199
+
200
+ /**
201
+ * get archive course by attributes
202
+ * @return /LP_Course[] array of courses
203
+ */
204
+ public function get_courses( $a ) {
205
+ //TODO
206
+ return null;
207
+ }
208
+
209
+ /**
210
+ * include layout
211
+ *
212
+ * @param $atts
213
+ *
214
+ * @return string
215
+ */
216
+ public function get_template( $atts ) {
217
+ $template_file_name = $atts['template'] . '.php';
218
+ if ( !file_exists( $this->template_dir . $template_file_name ) ) {
219
+ $template_file_name = 'list.php';
220
+ }
221
+ return $template_file_name;
222
+ }
223
+
224
+ /**
225
+ * include course template
226
+ *
227
+ * @param LP_Course current course
228
+ * @param array
229
+ * @param string
230
+ *
231
+ * @return string
232
+ */
233
+ public function render( $courses, $a = null, $template_file_name = 'cards.php' ) {
234
+
235
+ $courses_count = sizeof( $courses );
236
+ if ( $a['display'] > $courses_count ) {
237
+ $a['display'] = $courses_count;
238
+ }
239
+
240
+ ob_start();
241
+ $page_count = floor( $courses_count / $a['display'] );
242
+ $page_count += ( $courses_count % $a['display'] == 0 ) ? 0 : 1;
243
+
244
+ //include template file
245
+ include $this->template_dir . $template_file_name;
246
+
247
+ if ( isset( $template_script ) ) {
248
+ $this->enqueue_scripts
249
+ ( $template_script );
250
+ }
251
+
252
+ return ob_get_clean();
253
+ }
254
+
255
+ /**
256
+ * add shortcode style
257
+ */
258
+ public function enqueue_style() {
259
+ add_action( 'wp_head', array( __CLASS__, 'apply_style' ) );
260
+ }
261
+
262
+ public function apply_style() {
263
+ wp_enqueue_style( 'owl_carousel_css', LP()->css( 'owl.carousel.css' ) );
264
+ }
265
+
266
+ /**
267
+ * apply shortcode style
268
+ */
269
+ /**
270
+ * add shortcode script
271
+ *
272
+ * @param $script_url script url
273
+ */
274
+ public function enqueue_scripts( $script_url ) {
275
+ $this->script_url = $script_url;
276
+ add_action( 'wp_footer', array( __CLASS__, 'apply_script' ) );
277
+ }
278
+
279
+ /**
280
+ * callback to apply shortcode script
281
+ */
282
+ public function apply_script() {
283
+ $url = $this->script_url;
284
+ $owl = LP()->js( 'owl.carousel.min.js' );
285
+ wp_enqueue_script( 'owl_carousel_js', $owl, array( 'jquery' ) );
286
+ wp_enqueue_script( 'lp_shortcode_archive_course', $url, array( 'jquery' ) );
287
+ }
288
+
289
+ /**
290
+ * define variable
291
+ */
292
+ public function init_const() {
293
+ $this->template_dir = LP_PLUGIN_PATH . '/inc/shortcodes/' . $this->name . '/templates/';
294
+ }
295
+
296
+ /**
297
+ * add default attributes
298
+ * return array
299
+ */
300
+ public function add_default_atts() {
301
+ return null;
302
+ }
303
+
304
+ /**
305
+ * define default shortcode attributes
306
+ *
307
+ * @param array
308
+ *
309
+ * @return array default attributes
310
+ */
311
+ public function default_atts() {
312
+ $a = array(
313
+ 'limit' => '8',
314
+ 'display' => '8',
315
+ 'title' => "",
316
+ 'show_desc' => 'false',
317
+ 'show_thumbnail' => 'true',
318
+ 'show_lesson' => 'true',
319
+ 'show_enrolled_students' => 'true',
320
+ 'show_teacher' => 'true',
321
+ 'show_actions' => 'false',
322
+ 'show_action_view_course' => 'true',
323
+ 'show_price' => 'true',
324
+ 'css_class' => '',
325
+ 'template' => 'list',
326
+
327
+ //options for owl carousel
328
+ 'items' => "",
329
+ 'items_desktop' => "",
330
+ 'items_desktop_small' => "",
331
+ 'itemsTablet' => "",
332
+ 'items_tablet_small' => "",
333
+ 'items_mobile' => "",
334
+ 'single_item' => "false",
335
+ 'items_scale_up' => "false",
336
+ 'slide_speed' => "200",
337
+ 'pagination_Speed' => "800",
338
+ 'rewind_speed' => "1000",
339
+ 'auto_play' => "false",
340
+ 'stop_on_hover' => "true",
341
+ 'navigation' => "true",
342
+ 'navigation_text_next' => '&rarr;',
343
+ 'navigation_text_prev' => '&larr;',
344
+ 'scroll_per_page' => "false",
345
+ 'pagination' => "false",
346
+ 'auto_height' => "false"
347
+ );
348
+
349
+ $add_atts = $this->add_default_atts();
350
+ return wp_parse_args( $a, $add_atts );
351
+ }
352
+
353
+ }
354
+ }
inc/shortcodes/course-summary.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( !defined( 'ABSPATH' ) ) {
4
+ exit; // Exit if accessed directly
5
+ }
6
+
7
+ function course_page_summary_shortcode() {
8
+
9
+ }
10
+
11
+ add_shortcode( 'learn_press_course_summary', 'course_page_summary_shortcode' );
inc/shortcodes/featured-courses/featured-course.php ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once LP_PLUGIN_PATH."/inc/shortcodes/class-lp-abstract-archive-shortcode.php";
3
+
4
+
5
+ /**
6
+ * Shortcode to display collection of featured courses
7
+ * ------GENERAL SYNTAX----------
8
+ * [recent_course
9
+ * title=""
10
+ * limit="10"
11
+ * display="5"
12
+ * show_desc="true"
13
+ * show_thumbnail="true"
14
+ * show_enrolled_students="true"
15
+ * show_teacher="true"
16
+ * css_class=""
17
+ * template = "list"
18
+ *
19
+ * items=""
20
+ * items_desktop="", //null or number
21
+ * items_desktop_small="",
22
+ * itemsTablet= "",
23
+ * items_tablet_small="",
24
+ * items_mobile= "",
25
+ * single_item= "false",
26
+ * items_scale_up= "true",
27
+ * slide_speed= "200",
28
+ * pagination_Speed= "800",
29
+ * rewind_speed= "1000",
30
+ * auto_play= "false",
31
+ * stop_on_hover= "true",
32
+ * navigation= "true",
33
+ * navigation_text_next= "&rarr;",
34
+ * navigation_text_prev= "&larr;",
35
+ * scroll_per_age= "false",
36
+ * pagination= "false",
37
+ * auto_height= "false"
38
+ * ]
39
+ *
40
+ */
41
+
42
+ /**
43
+ * -----OPTIONS-------
44
+ * -Title:
45
+ * the title of collection
46
+ * empty by default
47
+ *
48
+ * -Limit:
49
+ * number, limit of the records will be queried by get_courses function
50
+ *
51
+ * -Display:
52
+ * number of items display on each carousel item
53
+ * only used in list template
54
+ *
55
+ * -show_thumbnail:
56
+ * set whether show course cover picture or not
57
+ * "true" by default
58
+ *
59
+ * -show_desc
60
+ * set whether show course description
61
+ * "false" by default
62
+ *
63
+ * -show_enrolled_students
64
+ * set whether show course's enrolled students
65
+ * "true" by default
66
+ *
67
+ * -show_teacher:
68
+ * set whether show course's instructor
69
+ * "true" by default
70
+ *
71
+ * -css_class:
72
+ * additional custom css class
73
+ *
74
+ * -Templates:
75
+ * there are 3 standard templates is list, grids and cards (list by default)
76
+ * you can also add your custom template by adding php file into templates folder
77
+ *
78
+ * - options for owl carousel (from items to the end)
79
+ * shortcode support some owl carousel slider options
80
+ *
81
+ * please take a look to owl-carousel docs to understand
82
+ * documentation: http://owlgraphic.com/owlcarousel/#customizing
83
+ *
84
+ * the responsive options (items to mobile_items) use short code parameters as the second
85
+ * element of owl carousel option array
86
+ * navigation_text_prev and navigation_text_next is options for navigation button's content
87
+ * by default is left arrow and right arrow
88
+ * -----USAGE----------
89
+ * [featured_course title="Recent courses" template="cards" show_desc="false" limit="20" display="8"]
90
+ */
91
+
92
+
93
+ if ( !class_exists( 'LP_Featured_Courses_Shortcode' ) ) {
94
+ /**
95
+ * Class LP_Featured_Courses_Shortcode
96
+ */
97
+ class LP_Featured_Courses_Shortcode extends LP_Archive_Courses_Shortcode
98
+ {
99
+ protected static $name = "featured_course";
100
+
101
+ public static function get_courses($a)
102
+ {
103
+ global $wpdb;
104
+ $posts = $wpdb->get_results(
105
+ $wpdb->prepare(
106
+ "SELECT DISTINCT *
107
+ FROM wp_posts p
108
+ LEFT JOIN wp_postmeta as pmeta
109
+ ON p.ID=pmeta.post_id
110
+ AND pmeta.meta_key = %s
111
+ WHERE p.post_type = %s
112
+ AND p.post_status = %s
113
+ AND meta_value = %s
114
+ ORDER BY p.post_date
115
+ LIMIT %d",
116
+ '_lp_featured',
117
+ LP_COURSE_CPT,
118
+ 'publish',
119
+ '1',
120
+ (int)$a['limit']
121
+ )
122
+ );
123
+
124
+ $courses = array_map(array(get_called_class(), 'get_lp_course'), $posts);
125
+ return $courses;
126
+ }
127
+
128
+ public static function add_default_atts(){
129
+ return array(
130
+ 'limit' => "1",
131
+ );
132
+ }
133
+ }
134
+
135
+ LP_Featured_Courses_Shortcode::init();
136
+ }
inc/shortcodes/featured-courses/featured-courses.php ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once LP_PLUGIN_PATH . "/inc/shortcodes/class-lp-abstract-archive-shortcode.php";
3
+
4
+
5
+ /**
6
+ * Shortcode to display collection of featured courses
7
+ * ------GENERAL SYNTAX----------
8
+ * [recent_course
9
+ * title=""
10
+ * limit="10"
11
+ * display="5"
12
+ * show_desc="true"
13
+ * show_thumbnail="true"
14
+ * show_enrolled_students="true"
15
+ * show_teacher="true"
16
+ * css_class=""
17
+ * template = "list"
18
+ *
19
+ * items=""
20
+ * items_desktop="", //null or number
21
+ * items_desktop_small="",
22
+ * itemsTablet= "",
23
+ * items_tablet_small="",
24
+ * items_mobile= "",
25
+ * single_item= "false",
26
+ * items_scale_up= "true",
27
+ * slide_speed= "200",
28
+ * pagination_Speed= "800",
29
+ * rewind_speed= "1000",
30
+ * auto_play= "false",
31
+ * stop_on_hover= "true",
32
+ * navigation= "true",
33
+ * navigation_text_next= "&rarr;",
34
+ * navigation_text_prev= "&larr;",
35
+ * scroll_per_age= "false",
36
+ * pagination= "false",
37
+ * auto_height= "false"
38
+ * ]
39
+ *
40
+ */
41
+
42
+ /**
43
+ * -----OPTIONS-------
44
+ * -Title:
45
+ * the title of collection
46
+ * empty by default
47
+ *
48
+ * -Limit:
49
+ * number, limit of the records will be queried by get_courses function
50
+ *
51
+ * -Display:
52
+ * number of items display on each carousel item
53
+ * only used in list template
54
+ *
55
+ * -show_thumbnail:
56
+ * set whether show course cover picture or not
57
+ * "true" by default
58
+ *
59
+ * -show_desc
60
+ * set whether show course description
61
+ * "false" by default
62
+ *
63
+ * -show_enrolled_students
64
+ * set whether show course's enrolled students
65
+ * "true" by default
66
+ *
67
+ * -show_teacher:
68
+ * set whether show course's instructor
69
+ * "true" by default
70
+ *
71
+ * -css_class:
72
+ * additional custom css class
73
+ *
74
+ * -Templates:
75
+ * there are 3 standard templates is list, grids and cards (list by default)
76
+ * you can also add your custom template by adding php file into templates folder
77
+ *
78
+ * - options for owl carousel (from items to the end)
79
+ * shortcode support some owl carousel slider options
80
+ *
81
+ * please take a look to owl-carousel docs to understand
82
+ * documentation: http://owlgraphic.com/owlcarousel/#customizing
83
+ *
84
+ * the responsive options (items to mobile_items) use short code parameters as the second
85
+ * element of owl carousel option array
86
+ * navigation_text_prev and navigation_text_next is options for navigation button's content
87
+ * by default is left arrow and right arrow
88
+ * -----USAGE----------
89
+ * [featured_course title="Recent courses" template="cards" show_desc="false" limit="20" display="8"]
90
+ */
91
+
92
+
93
+ if ( !class_exists( 'LP_Featured_Courses_Shortcode' ) ) {
94
+ /**
95
+ * Class LP_Featured_Courses_Shortcode
96
+ */
97
+ class LP_Featured_Courses_Shortcode extends LP_Archive_Courses_Shortcode {
98
+ protected $name = "featured-courses";
99
+
100
+ public function get_courses( $a ) {
101
+ global $wpdb;
102
+ $posts = $wpdb->get_results(
103
+ $wpdb->prepare(
104
+ "SELECT DISTINCT *
105
+ FROM wp_posts p
106
+ LEFT JOIN wp_postmeta as pmeta
107
+ ON p.ID=pmeta.post_id
108
+ AND pmeta.meta_key = %s
109
+ WHERE p.post_type = %s
110
+ AND p.post_status = %s
111
+ AND meta_value = %s
112
+ ORDER BY p.post_date
113
+ LIMIT %d",
114
+ '_lp_featured',
115
+ LP_COURSE_CPT,
116
+ 'publish',
117
+ 'yes',
118
+ (int) $a['limit']
119
+ )
120
+ );
121
+
122
+ $courses = array_map( array( $this, 'get_lp_course' ), $posts );
123
+ return $courses;
124
+ }
125
+
126
+ public function add_default_atts() {
127
+ return array(
128
+ 'limit' => "1",
129
+ );
130
+ }
131
+ }
132
+ }
133
+ return new LP_Featured_Courses_Shortcode();
inc/{widgets/course-attributes/tmpl → shortcodes/featured-courses}/index.php RENAMED
File without changes
inc/shortcodes/featured-courses/templates/cards.php ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //template script
3
+ $template_script = get_site_url() . '/' . LP_WP_CONTENT . '/plugins/learnpress/assets/js/frontend/shortcodes.js';
4
+ ?>
5
+
6
+ <div class="<?php echo 'archive-course-collection-outer recent ' . $a['template'] . ' ' . $a["css_class"] ?>">
7
+ <?php if (!empty($a['title'])): ?>
8
+ <h3 class="title"><?php echo $a['title'] ?></h3>
9
+ <?php endif; ?>
10
+ <div class="collection-body">
11
+ <div class="owl-carousel owl-theme"
12
+ data-items="<?php echo (empty($a['items']))?'3':$a['items']; ?>"
13
+ data-itemsdesktop="<?php echo (empty($a['items_desktop']))?'2':$a['items_desktop']; ?>"
14
+ data-itemsdesktopsmall="<?php echo (empty($a['items_desktop_small']))?'2':$a['items_desktop_small']; ?>"
15
+ data-itemsTablet="<?php echo (empty($a['items_tablet']))?'1':$a['items_tablet']; ?>"
16
+ data-itemsTabletSmall="<?php echo (empty($a['items_tablet_small']))?'1':$a['items_tablet_small']; ?>"
17
+ data-itemsmobile="<?php echo (empty($a['items_mobile']))?'1':$a['items_mobile']; ?>"
18
+ data-singleitem="<?php echo (empty($a['single_item']))?'false':$a['single_item']; ?>"
19
+ data-itemscaleup="<?php echo (empty($a['item_scale_up']))?'true':$a['item_scale_up']; ?>"
20
+ data-slidespeed="<?php echo (empty($a['slide_speed']))?'200':$a['slide_speed']; ?>"
21
+ data-paginationspeed="<?php echo (empty($a['pagination_speed']))?'800':$a['pagination_speed']; ?>"
22
+ data-rewindspeed="<?php echo (empty($a['rewind_speed']))?'1000':$a['rewind_speed']; ?>"
23
+ data-autoplay="<?php echo (empty($a['auto_play']))?'false':$a['auto_play']; ?>"
24
+ data-stoponhover="<?php echo (empty($a['stop_on_hover']))?'true':$a['stop_on_hover']; ?>"
25
+ data-navigation="<?php echo (empty($a['navigation']))?'true':$a['navigation']; ?>"
26
+ data-navigationtextnext="<?php echo $a['navigation_text_next']; ?>"
27
+ data-navigationtextprev="<?php echo $a['navigation_text_prev']; ?>"
28
+ data-scrollperpage="<?php echo $a['scroll_per_page']; ?>"
29
+ data-pagination="<?php echo $a['pagination']; ?>"
30
+ data-autoheight="<?php echo $a['auto_height']; ?>"
31
+ >
32
+ <?php foreach ($courses as $course): ?>
33
+ <div class="item">
34
+ <a href="<?php echo get_the_permalink($course->id) ?>" class="course-entry">
35
+ <div class="course-cover">
36
+ <?php if ($a['show_thumbnail']): ?>
37
+ <?php echo get_the_post_thumbnail($course->id) ?>
38
+ <?php endif; ?>
39
+ <div class="course-detail">
40
+ <?php if ($a['show_desc']): ?>
41
+ <div class="course-description"><?php
42
+ $the_content = $course->post->post_content;
43
+ $the_content = get_extended($the_content);
44
+ echo $the_content['main'];
45
+ ?></div>
46
+ <?php endif; ?>
47
+ <div class="course-meta-data">
48
+ <div class="section section-1">
49
+ <?php if ($a['show_price']): ?>
50
+ <div
51
+ class="course-price
52
+ <?php if (lp_is_paid_course($course->id)) {
53
+ echo 'paid';
54
+ } else {
55
+ echo 'free';
56
+ };
57
+ ?>">
58
+ <?php
59
+ $paid = lp_is_paid_course($course->id);
60
+ if (!$paid) {
61
+ esc_html_e('Free', 'learnpress');
62
+ } else {
63
+ $price = get_post_meta($course->id, '_lp_price', true);
64
+ echo learn_press_format_price($price, true);
65
+ }
66
+ ?>
67
+ </div>
68
+ <?php endif; ?>
69
+ </div>
70
+ <div class="section section-2">
71
+ <?php if ($a['show_enrolled_students']): ?>
72
+ <div class="course-student-number meta-field">
73
+ <?php
74
+ $students = $course->get_users_enrolled();
75
+ echo $students;
76
+ if (intval($students) > 1) {
77
+ _e(' students', 'learnpress');
78
+ } else {
79
+ _e(' student', 'learnpress');
80
+ }
81
+
82
+ ?>
83
+ </div>
84
+ <?php endif; ?>
85
+ <?php if ($a['show_lesson']): ?>
86
+
87
+ <div class="course-lesson-number meta-field">
88
+ <?php
89
+ $lessons = sizeof($course->get_lessons());
90
+ echo $lessons;
91
+ if (intval($lessons) > 1) {
92
+ _e(' lessons', 'learnpress');
93
+ } else {
94
+ _e(' lesson', 'learnpress');
95
+ }
96
+
97
+ ?>
98
+ </div>
99
+ </div>
100
+ <?php endif; ?>
101
+ <?php if ($a['show_teacher']): ?>
102
+ <div class="section section-3">
103
+ <div class="course-teacher">
104
+ <small>
105
+ <?php _e('instructor: ', 'learnpress'); ?>
106
+ <?php echo $course->get_instructor(); ?>
107
+ </small>
108
+ </div>
109
+ </div>
110
+ <?php endif; ?>
111
+ </div>
112
+ </div>
113
+ </div>
114
+ <div class="course-title">
115
+ <?php echo $course->post->post_title; ?>
116
+ </div>
117
+ </a>
118
+ </div>
119
+ <?php endforeach; ?>
120
+ </div>
121
+ </div>
122
+ <div class="collection-footer">
123
+ <?php if ($page_count > 1): ?>
124
+ <?php endif; ?>
125
+ </div>
126
+ </div>
127
+ <div class="clearfix"></div>
inc/shortcodes/featured-courses/templates/grids.php ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //template script
3
+ $template_script = get_site_url() . '/' . LP_WP_CONTENT . '/plugins/learnpress/assets/js/frontend/shortcodes.js';
4
+ ?>
5
+
6
+ <div class="<?php echo 'archive-course-collection-outer recent ' . $a['template'] . ' ' . $a["css_class"] ?>">
7
+ <?php if (!empty($a['title'])): ?>
8
+ <h3 class="title"><?php echo $a['title'] ?></h3>
9
+ <?php endif; ?>
10
+ <div class="collection-body">
11
+ <div class="owl-carousel owl-theme"
12
+ data-items="<?php echo (empty($a['items']))?'4':$a['items']; ?>"
13
+ data-itemsdesktop="<?php echo (empty($a['items_desktop']))?'4':$a['items_desktop']; ?>"
14
+ data-itemsdesktopsmall="<?php echo (empty($a['items_desktop_small']))?'3':$a['items_desktop_small']; ?>"
15
+ data-itemsTablet="<?php echo (empty($a['items_tablet']))?'3':$a['items_tablet']; ?>"
16
+ data-itemsTabletSmall="<?php echo (empty($a['items_tablet_small']))?'2':$a['items_tablet_small']; ?>"
17
+ data-itemsmobile="<?php echo (empty($a['items_mobile']))?'1':$a['items_mobile']; ?>"
18
+ data-singleitem="<?php echo (empty($a['single_item']))?'false':$a['single_item']; ?>"
19
+ data-itemscaleup="<?php echo (empty($a['item_scale_up']))?'true':$a['item_scale_up']; ?>"
20
+ data-slidespeed="<?php echo (empty($a['slide_speed']))?'200':$a['slide_speed']; ?>"
21
+ data-paginationspeed="<?php echo (empty($a['pagination_speed']))?'800':$a['pagination_speed']; ?>"
22
+ data-rewindspeed="<?php echo (empty($a['rewind_speed']))?'1000':$a['rewind_speed']; ?>"
23
+ data-autoplay="<?php echo (empty($a['auto_play']))?'false':$a['auto_play']; ?>"
24
+ data-stoponhover="<?php echo (empty($a['stop_on_hover']))?'true':$a['stop_on_hover']; ?>"
25
+ data-navigation="<?php echo (empty($a['navigation']))?'true':$a['navigation']; ?>"
26
+ data-navigationtextnext="<?php echo $a['navigation_text_next']; ?>"
27
+ data-navigationtextprev="<?php echo $a['navigation_text_prev']; ?>"
28
+ data-scrollperpage="<?php echo $a['scroll_per_page']; ?>"
29
+ data-pagination="<?php echo $a['pagination']; ?>"
30
+ data-autoheight="<?php echo $a['auto_height']; ?>"
31
+ >
32
+ <?php foreach ($courses as $course): ?>
33
+ <div class="item">
34
+ <div class="course-entry">
35
+ <?php if ($a['show_thumbnail']): ?>
36
+ <div class="course-cover">
37
+ <a class="img-link" href="<?php echo get_the_permalink($course->id) ?>">
38
+ <?php echo get_the_post_thumbnail($course->id) ?>
39
+ </a>
40
+ </div>
41
+ <?php endif; ?>
42
+ <div class="course-detail">
43
+ <a href="<?php echo get_the_permalink($course->id) ?>">
44
+ <div class="course-title">
45
+ <?php echo $course->post->post_title; ?>
46
+ </div>
47
+ </a>
48
+ <?php if ($a['show_desc']): ?>
49
+ <div class="course-description"><?php
50
+ $the_content = $course->post->post_content;
51
+ $the_content = get_extended($the_content);
52
+ echo $the_content['main'];
53
+ ?></div>
54
+ <?php endif; ?>
55
+ <div class="course-meta-data">
56
+ <div class="section section-1">
57
+ <?php if ($a['show_price']): ?>
58
+ <div
59
+ class="course-price
60
+ <?php if (lp_is_paid_course($course->id)) {
61
+ echo 'paid';
62
+ } else {
63
+ echo 'free';
64
+ };
65
+ ?>">
66
+ <?php
67
+ $paid = lp_is_paid_course($course->id);
68
+ if (!$paid) {
69
+ esc_html_e('Free', 'learnpress');
70
+ } else {
71
+ $price = get_post_meta($course->id, '_lp_price', true);
72
+ echo learn_press_format_price($price, true);
73
+ }
74
+ ?>
75
+ </div>
76
+ <?php endif; ?>
77
+ </div>
78
+ <div class="section section-2">
79
+ <?php if ($a['show_enrolled_students']): ?>
80
+ <div class="course-student-number meta-field">
81
+ <?php
82
+ $students = $course->get_users_enrolled();
83
+ echo $students;
84
+ if (intval($students) > 1) {
85
+ _e(' students', 'learnpress');
86
+ } else {
87
+ _e(' student', 'learnpress');
88
+ }
89
+
90
+ ?>
91
+ </div>
92
+ <?php endif; ?>
93
+ <?php if ($a['show_lesson']): ?>
94
+
95
+ <div class="course-lesson-number meta-field">
96
+ <?php
97
+ $lessons = sizeof($course->get_lessons());
98
+ echo $lessons;
99
+ if (intval($lessons) > 1) {
100
+ _e(' lessons', 'learnpress');
101
+ } else {
102
+ _e(' lesson', 'learnpress');
103
+ }
104
+
105
+ ?>
106
+ </div>
107
+ </div>
108
+ <?php endif; ?>
109
+ <?php if ($a['show_teacher']): ?>
110
+ <div class="section section-3">
111
+ <div class="course-teacher">
112
+ <small>
113
+ <?php _e('instructor: ', 'learnpress'); ?>
114
+ <?php echo $course->get_instructor_html(); ?>
115
+ </small>
116
+ </div>
117
+ </div>
118
+ <?php endif; ?>
119
+ </div>
120
+ </div>
121
+ </div>
122
+ </div>
123
+ <?php endforeach; ?>
124
+ </div>
125
+ </div>
126
+ <div class="collection-footer">
127
+ <?php if ($page_count > 1): ?>
128
+ <?php endif; ?>
129
+ </div>
130
+ </div>
131
+ <div class="clearfix"></div>
inc/{widgets/course-filters/tmpl → shortcodes/featured-courses/templates}/index.php RENAMED
File without changes
inc/shortcodes/featured-courses/templates/list.php ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //template script
3
+ $template_script = get_site_url() . '/' . LP_WP_CONTENT . '/plugins/learnpress/assets/js/frontend/shortcodes.js';
4
+ ?>
5
+
6
+ <div class="<?php echo 'archive-course-collection-outer recent ' . $a['template'] . ' ' . $a["css_class"] ?>">
7
+ <?php if (!empty($a['title'])): ?>
8
+ <h3 class="title"><?php echo $a['title'] ?></h3>
9
+ <?php endif; ?>
10
+ <div class="collection-holder">
11
+ <div class="owl-carousel owl-theme"
12
+ data-items="<?php echo (empty($a['items']))?'1':$a['items']; ?>"
13
+ data-itemsdesktop="<?php echo (empty($a['items_desktop']))?'1':$a['items_desktop']; ?>"
14
+ data-itemsdesktopsmall="<?php echo (empty($a['items_desktop_small']))?'1':$a['items_desktop_small']; ?>"
15
+ data-itemsTablet="<?php echo (empty($a['items_tablet']))?'1':$a['items_tablet']; ?>"
16
+ data-itemsTabletSmall="<?php echo (empty($a['items_tablet_small']))?'1':$a['items_tablet_small']; ?>"
17
+ data-itemsmobile="<?php echo (empty($a['items_mobile']))?'1':$a['items_mobile']; ?>"
18
+ data-singleitem="<?php echo (empty($a['single_item']))?'false':$a['single_item']; ?>"
19
+ data-itemscaleup="<?php echo (empty($a['item_scale_up']))?'true':$a['item_scale_up']; ?>"
20
+ data-slidespeed="<?php echo (empty($a['slide_speed']))?'200':$a['slide_speed']; ?>"
21
+ data-paginationspeed="<?php echo (empty($a['pagination_speed']))?'800':$a['pagination_speed']; ?>"
22
+ data-rewindspeed="<?php echo (empty($a['rewind_speed']))?'1000':$a['rewind_speed']; ?>"
23
+ data-autoplay="<?php echo (empty($a['auto_play']))?'false':$a['auto_play']; ?>"
24
+ data-stoponhover="<?php echo (empty($a['stop_on_hover']))?'true':$a['stop_on_hover']; ?>"
25
+ data-navigation="<?php echo (empty($a['navigation']))?'true':$a['navigation']; ?>"
26
+ data-navigationtextnext="<?php echo $a['navigation_text_next']; ?>"
27
+ data-navigationtextprev="<?php echo $a['navigation_text_prev']; ?>"
28
+ data-scrollperpage="<?php echo $a['scroll_per_page']; ?>"
29
+ data-pagination="<?php echo $a['pagination']; ?>"
30
+ data-autoheight="<?php echo $a['auto_height']; ?>"
31
+ >
32
+ <?php for ($page = 1; $page <= $page_count; $page++): ?>
33
+ <?php $the_course_index = ($page - 1)*$a['display']; ?>
34
+ <div class="item" >
35
+ <div class="collection-body">
36
+ <?php $page_courses = array_slice($courses, $the_course_index, $a['display']); ?>
37
+ <?php foreach ($page_courses as $course): ?>
38
+ <div class="course-entry">
39
+ <?php if ($a['show_thumbnail']): ?>
40
+ <div class="course-cover">
41
+ <a href="<?php echo get_the_permalink($course->id) ?>">
42
+ <?php echo get_the_post_thumbnail($course->id) ?>
43
+ </a>
44
+ </div>
45
+ <?php endif; ?>
46
+ <div class="course-detail">
47
+ <a href="<?php echo get_the_permalink($course->id) ?>">
48
+ <div class="course-title">
49
+ <?php echo $course->post->post_title; ?>
50
+ </div>
51
+ </a>
52
+ <?php if ($a['show_desc']):?>
53
+ <div class="course-description"><?php
54
+ $the_content = $course->post->post_content;
55
+ $the_content = get_extended( $the_content);
56
+ echo $the_content['main'];
57
+ ?></div>
58
+ <?php endif; ?>
59
+ <div class="course-meta-data">
60
+ <div class="section section-1">
61
+ <?php if($a['show_price']): ?>
62
+ <div
63
+ class="course-price
64
+ <?php if(lp_is_paid_course($course->id)) {
65
+ echo 'paid';
66
+ } else{
67
+ echo 'free';
68
+ };
69
+ ?>">
70
+ <?php
71
+ $paid = lp_is_paid_course($course->id);
72
+ if(! $paid){
73
+ esc_html_e('Free', 'learnpress');
74
+ } else{
75
+ $price = get_post_meta( $course->id, '_lp_price', true);
76
+ echo learn_press_format_price($price, true);
77
+ }
78
+ ?>
79
+ </div>
80
+ <?php endif; ?>
81
+ </div>
82
+ <div class="section section-2 inline">
83
+ <?php if ($a['show_enrolled_students']): ?>
84
+ <div class="course-student-number meta-field">
85
+ <?php
86
+ $students = $course->get_users_enrolled();
87
+ echo $students;
88
+ if (intval($students) > 1) {
89
+ _e(' students', 'learnpress');
90
+ } else {
91
+ _e(' student', 'learnpress');
92
+ }
93
+
94
+ ?>
95
+ </div>
96
+ <?php endif; ?>
97
+ <?php if ($a['show_lesson']): ?>
98
+
99
+ <div class="course-lesson-number meta-field">
100
+ <?php
101
+ $lessons = sizeof($course->get_lessons());
102
+ echo $lessons;
103
+ if (intval($lessons) > 1) {
104
+ _e(' lessons', 'learnpress');
105
+ } else {
106
+ _e(' lesson', 'learnpress');
107
+ }
108
+
109
+ ?>
110
+ </div>
111
+ </div>
112
+ <?php endif; ?>
113
+ <?php if ($a['show_teacher']): ?>
114
+ <div class="section section-3">
115
+ <div class="course-teacher">
116
+ <small>
117
+ <?php _e('instructor: ', 'learnpress'); ?>
118
+ <?php echo $course->get_instructor_html(); ?>
119
+ </small>
120
+ </div>
121
+ </div>
122
+ <?php endif; ?>
123
+ </div>
124
+ </div>
125
+ </div>
126
+ <?php endforeach; ?>
127
+ </div>
128
+ </div>
129
+ <?php endfor; ?>
130
+ </div>
131
+ </div>
132
+ <div class="collection-footer">
133
+ <?php if ($page_count > 1): ?>
134
+ <?php endif; ?>
135
+ </div>
136
+ </div>
137
+ <div class="clearfix"></div>
inc/shortcodes/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden.
inc/shortcodes/popular-courses/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden.
inc/shortcodes/popular-courses/popular-course.php ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once LP_PLUGIN_PATH."/inc/shortcodes/class-lp-abstract-archive-shortcode.php";
3
+
4
+
5
+
6
+ /**
7
+ * Shortcode to display collection of most popular courses
8
+ * ------GENERAL SYNTAX----------
9
+ * [recent_course
10
+ * title=""
11
+ * limit="10"
12
+ * display="5"
13
+ * show_desc="true"
14
+ * show_thumbnail="true"
15
+ * show_enrolled_students="true"
16
+ * show_teacher="true"
17
+ * css_class=""
18
+ * template = "list"
19
+ *
20
+ * items=""
21
+ * items_desktop="", //null or number
22
+ * items_desktop_small="",
23
+ * itemsTablet= "",
24
+ * items_tablet_small="",
25
+ * items_mobile= "",
26
+ * single_item= "false",
27
+ * items_scale_up= "true",
28
+ * slide_speed= "200",
29
+ * pagination_Speed= "800",
30
+ * rewind_speed= "1000",
31
+ * auto_play= "false",
32
+ * stop_on_hover= "true",
33
+ * navigation= "true",
34
+ * navigation_text_next= "&rarr;",
35
+ * navigation_text_prev= "&larr;",
36
+ * scroll_per_age= "false",
37
+ * pagination= "false",
38
+ * auto_height= "false"
39
+ * ]
40
+ *
41
+ */
42
+
43
+ /**
44
+ * -----OPTIONS-------
45
+ * -Title:
46
+ * the title of collection
47
+ * empty by default
48
+ *
49
+ * -Limit:
50
+ * number, limit of the records will be queried by get_courses function
51
+ *
52
+ * -Display:
53
+ * number of items display on each carousel item
54
+ * only used in list template
55
+ *
56
+ * -show_thumbnail:
57
+ * set whether show course cover picture or not
58
+ * "true" by default
59
+ *
60
+ * -show_desc
61
+ * set whether show course description
62
+ * "false" by default
63
+ *
64
+ * -show_enrolled_students
65
+ * set whether show course's enrolled students
66
+ * "true" by default
67
+ *
68
+ * -show_teacher:
69
+ * set whether show course's instructor
70
+ * "true" by default
71
+ *
72
+ * -css_class:
73
+ * additional custom css class
74
+ *
75
+ * -Templates:
76
+ * there are 3 standard templates is list, grids and cards (list by default)
77
+ * you can also add your custom template by adding php file into templates folder
78
+ *
79
+ * - options for owl carousel (from items to the end)
80
+ * shortcode support some owl carousel slider options
81
+ *
82
+ * please take a look to owl-carousel docs to understand
83
+ * documentation: http://owlgraphic.com/owlcarousel/#customizing
84
+ *
85
+ * the responsive options (items to mobile_items) use short code parameters as the second
86
+ * element of owl carousel option array
87
+ * navigation_text_prev and navigation_text_next is options for navigation button's content
88
+ * by default is left arrow and right arrow
89
+ * -----USAGE----------
90
+ * [popular_course title="Recent courses" template="cards" show_desc="false" limit="20" display="8"]
91
+ */
92
+
93
+ if ( !class_exists( 'LP_Popular_Courses_Shortcode' ) ) {
94
+ /**
95
+ * Class LP_Popular_Courses_Shortcode
96
+ */
97
+ class LP_Popular_Courses_Shortcode extends LP_Archive_Courses_Shortcode
98
+ {
99
+ protected static $name = "popular_course";
100
+
101
+ public static function get_courses($a)
102
+ {
103
+ global $wpdb;
104
+ $posts = $wpdb->get_results(
105
+ $wpdb->prepare(
106
+ "SELECT DISTINCT ID, (meta_value + st) AS value
107
+ FROM wp_posts p
108
+ LEFT JOIN wp_postmeta as pmeta
109
+ ON p.ID=pmeta.post_id
110
+ AND pmeta.meta_key='_lp_max_students'
111
+ LEFT JOIN ( SELECT course_id , COUNT(user_id) AS st
112
+ FROM `wp_learnpress_user_courses`
113
+ WHERE 1
114
+ GROUP BY course_id) puser
115
+ ON p.ID=puser.course_id
116
+ WHERE p.post_type = %s
117
+ AND p.post_status = %s
118
+ ORDER BY value
119
+ LIMIT %d",
120
+ LP_COURSE_CPT,
121
+ 'publish',
122
+ (int)$a['limit']
123
+ )
124
+ );
125
+
126
+ $courses = array_map(array(get_called_class(), 'get_lp_course'), $posts);
127
+ return $courses;
128
+ }
129
+ }
130
+
131
+ LP_Popular_Courses_Shortcode::init();
132
+ }
inc/shortcodes/popular-courses/popular-courses.php ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once LP_PLUGIN_PATH . "/inc/shortcodes/class-lp-abstract-archive-shortcode.php";
3
+
4
+
5
+ /**
6
+ * Shortcode to display collection of most popular courses
7
+ * ------GENERAL SYNTAX----------
8
+ * [recent_course
9
+ * title=""
10
+ * limit="10"
11
+ * display="5"
12
+ * show_desc="true"
13
+ * show_thumbnail="true"
14
+ * show_enrolled_students="true"
15
+ * show_teacher="true"
16
+ * css_class=""
17
+ * template = "list"
18
+ *
19
+ * items=""
20
+ * items_desktop="", //null or number
21
+ * items_desktop_small="",
22
+ * itemsTablet= "",
23
+ * items_tablet_small="",
24
+ * items_mobile= "",
25
+ * single_item= "false",
26
+ * items_scale_up= "true",
27
+ * slide_speed= "200",
28
+ * pagination_Speed= "800",
29
+ * rewind_speed= "1000",
30
+ * auto_play= "false",
31
+ * stop_on_hover= "true",
32
+ * navigation= "true",
33
+ * navigation_text_next= "&rarr;",
34
+ * navigation_text_prev= "&larr;",
35
+ * scroll_per_age= "false",
36
+ * pagination= "false",
37
+ * auto_height= "false"
38
+ * ]
39
+ *
40
+ */
41
+
42
+ /**
43
+ * -----OPTIONS-------
44
+ * -Title:
45
+ * the title of collection
46
+ * empty by default
47
+ *
48
+ * -Limit:
49
+ * number, limit of the records will be queried by get_courses function
50
+ *
51
+ * -Display:
52
+ * number of items display on each carousel item
53
+ * only used in list template
54
+ *
55
+ * -show_thumbnail:
56
+ * set whether show course cover picture or not
57
+ * "true" by default
58
+ *
59
+ * -show_desc
60
+ * set whether show course description
61
+ * "false" by default
62
+ *
63
+ * -show_enrolled_students
64
+ * set whether show course's enrolled students
65
+ * "true" by default
66
+ *
67
+ * -show_teacher:
68
+ * set whether show course's instructor
69
+ * "true" by default
70
+ *
71
+ * -css_class:
72
+ * additional custom css class
73
+ *
74
+ * -Templates:
75
+ * there are 3 standard templates is list, grids and cards (list by default)
76
+ * you can also add your custom template by adding php file into templates folder
77
+ *
78
+ * - options for owl carousel (from items to the end)
79
+ * shortcode support some owl carousel slider options
80
+ *
81
+ * please take a look to owl-carousel docs to understand
82
+ * documentation: http://owlgraphic.com/owlcarousel/#customizing
83
+ *
84
+ * the responsive options (items to mobile_items) use short code parameters as the second
85
+ * element of owl carousel option array
86
+ * navigation_text_prev and navigation_text_next is options for navigation button's content
87
+ * by default is left arrow and right arrow
88
+ * -----USAGE----------
89
+ * [popular_course title="Recent courses" template="cards" show_desc="false" limit="20" display="8"]
90
+ */
91
+
92
+ if ( !class_exists( 'LP_Popular_Courses_Shortcode' ) ) {
93
+ /**
94
+ * Class LP_Popular_Courses_Shortcode
95
+ */
96
+ class LP_Popular_Courses_Shortcode extends LP_Archive_Courses_Shortcode {
97
+ protected $name = "popular-courses";
98
+
99
+ public function get_courses( $a ) {
100
+ global $wpdb;
101
+ $posts = $wpdb->get_results(
102
+ $wpdb->prepare(
103
+ "SELECT DISTINCT ID, (meta_value + st) AS value
104
+ FROM wp_posts p
105
+ LEFT JOIN wp_postmeta as pmeta
106
+ ON p.ID=pmeta.post_id
107
+ AND pmeta.meta_key='_lp_max_students'
108
+ LEFT JOIN ( SELECT course_id , COUNT(user_id) AS st
109
+ FROM `wp_learnpress_user_courses`
110
+ WHERE 1
111
+ GROUP BY course_id) puser
112
+ ON p.ID=puser.course_id
113
+ WHERE p.post_type = %s
114
+ AND p.post_status = %s
115
+ ORDER BY value
116
+ LIMIT %d",
117
+ LP_COURSE_CPT,
118
+ 'publish',
119
+ (int) $a['limit']
120
+ )
121
+ );
122
+
123
+ $courses = array_map( array( $this, 'get_lp_course' ), $posts );
124
+ return $courses;
125
+ }
126
+ }
127
+
128
+ }
129
+ return new LP_Popular_Courses_Shortcode();
inc/shortcodes/popular-courses/templates/cards.php ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //template script
3
+ $template_script = get_site_url() . '/' . LP_WP_CONTENT . '/plugins/learnpress/assets/js/frontend/shortcodes.js';
4
+ ?>
5
+
6
+ <div class="<?php echo 'archive-course-collection-outer recent ' . $a['template'] . ' ' . $a["css_class"] ?>">
7
+ <?php if (!empty($a['title'])): ?>
8
+ <h3 class="title"><?php echo $a['title'] ?></h3>
9
+ <?php endif; ?>
10
+ <div class="collection-body">
11
+ <div class="owl-carousel owl-theme"
12
+ data-items="<?php echo (empty($a['items']))?'3':$a['items']; ?>"
13
+ data-itemsdesktop="<?php echo (empty($a['items_desktop']))?'2':$a['items_desktop']; ?>"
14
+ data-itemsdesktopsmall="<?php echo (empty($a['items_desktop_small']))?'2':$a['items_desktop_small']; ?>"
15
+ data-itemsTablet="<?php echo (empty($a['items_tablet']))?'1':$a['items_tablet']; ?>"
16
+ data-itemsTabletSmall="<?php echo (empty($a['items_tablet_small']))?'1':$a['items_tablet_small']; ?>"
17
+ data-itemsmobile="<?php echo (empty($a['items_mobile']))?'1':$a['items_mobile']; ?>"
18
+ data-singleitem="<?php echo (empty($a['single_item']))?'false':$a['single_item']; ?>"
19
+ data-itemscaleup="<?php echo (empty($a['item_scale_up']))?'true':$a['item_scale_up']; ?>"
20
+ data-slidespeed="<?php echo (empty($a['slide_speed']))?'200':$a['slide_speed']; ?>"
21
+ data-paginationspeed="<?php echo (empty($a['pagination_speed']))?'800':$a['pagination_speed']; ?>"
22
+ data-rewindspeed="<?php echo (empty($a['rewind_speed']))?'1000':$a['rewind_speed']; ?>"
23
+ data-autoplay="<?php echo (empty($a['auto_play']))?'false':$a['auto_play']; ?>"
24
+ data-stoponhover="<?php echo (empty($a['stop_on_hover']))?'true':$a['stop_on_hover']; ?>"
25
+ data-navigation="<?php echo (empty($a['navigation']))?'true':$a['navigation']; ?>"
26
+ data-navigationtextnext="<?php echo $a['navigation_text_next']; ?>"
27
+ data-navigationtextprev="<?php echo $a['navigation_text_prev']; ?>"
28
+ data-scrollperpage="<?php echo $a['scroll_per_page']; ?>"
29
+ data-pagination="<?php echo $a['pagination']; ?>"
30
+ data-autoheight="<?php echo $a['auto_height']; ?>"
31
+ >
32
+ <?php foreach ($courses as $course): ?>
33
+ <div class="item">
34
+ <a href="<?php echo get_the_permalink($course->id) ?>" class="course-entry">
35
+ <div class="course-cover">
36
+ <?php if ($a['show_thumbnail']): ?>
37
+ <?php echo get_the_post_thumbnail($course->id) ?>
38
+ <?php endif; ?>
39
+ <div class="course-detail">
40
+ <?php if ($a['show_desc']): ?>
41
+ <div class="course-description"><?php
42
+ $the_content = $course->post->post_content;
43
+ $the_content = get_extended($the_content);
44
+ echo $the_content['main'];
45
+ ?></div>
46
+ <?php endif; ?>
47
+ <div class="course-meta-data">
48
+ <div class="section section-1">
49
+ <?php if ($a['show_price']): ?>
50
+ <div
51
+ class="course-price
52
+ <?php if (lp_is_paid_course($course->id)) {
53
+ echo 'paid';
54
+ } else {
55
+ echo 'free';
56
+ };
57
+ ?>">
58
+ <?php
59
+ $paid = lp_is_paid_course($course->id);
60
+ if (!$paid) {
61
+ esc_html_e('Free', 'learnpress');
62
+ } else {
63
+ $price = get_post_meta($course->id, '_lp_price', true);
64
+ echo learn_press_format_price($price, true);
65
+ }
66
+ ?>
67
+ </div>
68
+ <?php endif; ?>
69
+ </div>
70
+ <div class="section section-2">
71
+ <?php if ($a['show_enrolled_students']): ?>
72
+ <div class="course-student-number meta-field">
73
+ <?php
74
+ $students = $course->get_users_enrolled();
75
+ echo $students;
76
+ if (intval($students) > 1) {
77
+ _e(' students', 'learnpress');
78
+ } else {
79
+ _e(' student', 'learnpress');
80
+ }
81
+
82
+ ?>
83
+ </div>
84
+ <?php endif; ?>
85
+ <?php if ($a['show_lesson']): ?>
86
+
87
+ <div class="course-lesson-number meta-field">
88
+ <?php
89
+ $lessons = sizeof($course->get_lessons());
90
+ echo $lessons;
91
+ if (intval($lessons) > 1) {
92
+ _e(' lessons', 'learnpress');
93
+ } else {
94
+ _e(' lesson', 'learnpress');
95
+ }
96
+
97
+ ?>
98
+ </div>
99
+ </div>
100
+ <?php endif; ?>
101
+ <?php if ($a['show_teacher']): ?>
102
+ <div class="section section-3">
103
+ <div class="course-teacher">
104
+ <small>
105
+ <?php _e('instructor: ', 'learnpress'); ?>
106
+ <?php echo $course->get_instructor(); ?>
107
+ </small>
108
+ </div>
109
+ </div>
110
+ <?php endif; ?>
111
+ </div>
112
+ </div>
113
+ </div>
114
+ <div class="course-title">
115
+ <?php echo $course->post->post_title; ?>
116
+ </div>
117
+ </a>
118
+ </div>
119
+ <?php endforeach; ?>
120
+ </div>
121
+ </div>
122
+ <div class="collection-footer">
123
+ <?php if ($page_count > 1): ?>
124
+ <?php endif; ?>
125
+ </div>
126
+ </div>
127
+ <div class="clearfix"></div>
inc/shortcodes/popular-courses/templates/grids.php ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //template script
3
+ $template_script = get_site_url() . '/' . LP_WP_CONTENT . '/plugins/learnpress/assets/js/frontend/shortcodes.js';
4
+ ?>
5
+
6
+ <div class="<?php echo 'archive-course-collection-outer recent ' . $a['template'] . ' ' . $a["css_class"] ?>">
7
+ <?php if (!empty($a['title'])): ?>
8
+ <h3 class="title"><?php echo $a['title'] ?></h3>
9
+ <?php endif; ?>
10
+ <div class="collection-body">
11
+ <div class="owl-carousel owl-theme"
12
+ data-items="<?php echo (empty($a['items']))?'4':$a['items']; ?>"
13
+ data-itemsdesktop="<?php echo (empty($a['items_desktop']))?'4':$a['items_desktop']; ?>"
14
+ data-itemsdesktopsmall="<?php echo (empty($a['items_desktop_small']))?'3':$a['items_desktop_small']; ?>"
15
+ data-itemsTablet="<?php echo (empty($a['items_tablet']))?'3':$a['items_tablet']; ?>"
16
+ data-itemsTabletSmall="<?php echo (empty($a['items_tablet_small']))?'2':$a['items_tablet_small']; ?>"
17
+ data-itemsmobile="<?php echo (empty($a['items_mobile']))?'1':$a['items_mobile']; ?>"
18
+ data-singleitem="<?php echo (empty($a['single_item']))?'false':$a['single_item']; ?>"
19
+ data-itemscaleup="<?php echo (empty($a['item_scale_up']))?'true':$a['item_scale_up']; ?>"
20
+ data-slidespeed="<?php echo (empty($a['slide_speed']))?'200':$a['slide_speed']; ?>"
21
+ data-paginationspeed="<?php echo (empty($a['pagination_speed']))?'800':$a['pagination_speed']; ?>"
22
+ data-rewindspeed="<?php echo (empty($a['rewind_speed']))?'1000':$a['rewind_speed']; ?>"
23
+ data-autoplay="<?php echo (empty($a['auto_play']))?'false':$a['auto_play']; ?>"
24
+ data-stoponhover="<?php echo (empty($a['stop_on_hover']))?'true':$a['stop_on_hover']; ?>"
25
+ data-navigation="<?php echo (empty($a['navigation']))?'true':$a['navigation']; ?>"
26
+ data-navigationtextnext="<?php echo $a['navigation_text_next']; ?>"
27
+ data-navigationtextprev="<?php echo $a['navigation_text_prev']; ?>"
28
+ data-scrollperpage="<?php echo $a['scroll_per_page']; ?>"
29
+ data-pagination="<?php echo $a['pagination']; ?>"
30
+ data-autoheight="<?php echo $a['auto_height']; ?>"
31
+ >
32
+ <?php foreach ($courses as $course): ?>
33
+ <div class="item">
34
+ <div class="course-entry">
35
+ <?php if ($a['show_thumbnail']): ?>
36
+ <div class="course-cover">
37
+ <a class="img-link" href="<?php echo get_the_permalink($course->id) ?>">
38
+ <?php echo get_the_post_thumbnail($course->id) ?>
39
+ </a>
40
+ </div>
41
+ <?php endif; ?>
42
+ <div class="course-detail">
43
+ <a href="<?php echo get_the_permalink($course->id) ?>">
44
+ <div class="course-title">
45
+ <?php echo $course->post->post_title; ?>
46
+ </div>
47
+ </a>
48
+ <?php if ($a['show_desc']): ?>
49
+ <div class="course-description"><?php
50
+ $the_content = $course->post->post_content;
51
+ $the_content = get_extended($the_content);
52
+ echo $the_content['main'];
53
+ ?></div>
54
+ <?php endif; ?>
55
+ <div class="course-meta-data">
56
+ <div class="section section-1">
57
+ <?php if ($a['show_price']): ?>
58
+ <div
59
+ class="course-price
60
+ <?php if (lp_is_paid_course($course->id)) {
61
+ echo 'paid';
62
+ } else {
63
+ echo 'free';
64
+ };
65
+ ?>">
66
+ <?php
67
+ $paid = lp_is_paid_course($course->id);
68
+ if (!$paid) {
69
+ esc_html_e('Free', 'learnpress');
70
+ } else {
71
+ $price = get_post_meta($course->id, '_lp_price', true);
72
+ echo learn_press_format_price($price, true);
73
+ }
74
+ ?>
75
+ </div>
76
+ <?php endif; ?>
77
+ </div>
78
+ <div class="section section-2">
79
+ <?php if ($a['show_enrolled_students']): ?>
80
+ <div class="course-student-number meta-field">
81
+ <?php
82
+ $students = $course->get_users_enrolled();
83
+ echo $students;
84
+ if (intval($students) > 1) {
85
+ _e(' students', 'learnpress');
86
+ } else {
87
+ _e(' student', 'learnpress');
88
+ }
89
+
90
+ ?>
91
+ </div>
92
+ <?php endif; ?>
93
+ <?php if ($a['show_lesson']): ?>
94
+
95
+ <div class="course-lesson-number meta-field">
96
+ <?php
97
+ $lessons = sizeof($course->get_lessons());
98
+ echo $lessons;
99
+ if (intval($lessons) > 1) {
100
+ _e(' lessons', 'learnpress');
101
+ } else {
102
+ _e(' lesson', 'learnpress');
103
+ }
104
+
105
+ ?>
106
+ </div>
107
+ </div>
108
+ <?php endif; ?>
109
+ <?php if ($a['show_teacher']): ?>
110
+ <div class="section section-3">
111
+ <div class="course-teacher">
112
+ <small>
113
+ <?php _e('instructor: ', 'learnpress'); ?>
114
+ <?php echo $course->get_instructor_html(); ?>
115
+ </small>
116
+ </div>
117
+ </div>
118
+ <?php endif; ?>
119
+ </div>
120
+ </div>
121
+ </div>
122
+ </div>
123
+ <?php endforeach; ?>
124
+ </div>
125
+ </div>
126
+ <div class="collection-footer">
127
+ <?php if ($page_count > 1): ?>
128
+ <?php endif; ?>
129
+ </div>
130
+ </div>
131
+ <div class="clearfix"></div>
inc/shortcodes/popular-courses/templates/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden.
inc/shortcodes/popular-courses/templates/list.php ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //template script
3
+ $template_script = get_site_url() . '/' . LP_WP_CONTENT . '/plugins/learnpress/assets/js/frontend/shortcodes.js';
4
+ ?>
5
+
6
+ <div class="<?php echo 'archive-course-collection-outer recent ' . $a['template'] . ' ' . $a["css_class"] ?>">
7
+ <?php if (!empty($a['title'])): ?>
8
+ <h3 class="title"><?php echo $a['title'] ?></h3>
9
+ <?php endif; ?>
10
+ <div class="collection-holder">
11
+ <div class="owl-carousel owl-theme"
12
+ data-items="<?php echo (empty($a['items']))?'1':$a['items']; ?>"
13
+ data-itemsdesktop="<?php echo (empty($a['items_desktop']))?'1':$a['items_desktop']; ?>"
14
+ data-itemsdesktopsmall="<?php echo (empty($a['items_desktop_small']))?'1':$a['items_desktop_small']; ?>"
15
+ data-itemsTablet="<?php echo (empty($a['items_tablet']))?'1':$a['items_tablet']; ?>"
16
+ data-itemsTabletSmall="<?php echo (empty($a['items_tablet_small']))?'1':$a['items_tablet_small']; ?>"
17
+ data-itemsmobile="<?php echo (empty($a['items_mobile']))?'1':$a['items_mobile']; ?>"
18
+ data-singleitem="<?php echo (empty($a['single_item']))?'false':$a['single_item']; ?>"
19
+ data-itemscaleup="<?php echo (empty($a['item_scale_up']))?'true':$a['item_scale_up']; ?>"
20
+ data-slidespeed="<?php echo (empty($a['slide_speed']))?'200':$a['slide_speed']; ?>"
21
+ data-paginationspeed="<?php echo (empty($a['pagination_speed']))?'800':$a['pagination_speed']; ?>"
22
+ data-rewindspeed="<?php echo (empty($a['rewind_speed']))?'1000':$a['rewind_speed']; ?>"
23
+ data-autoplay="<?php echo (empty($a['auto_play']))?'false':$a['auto_play']; ?>"
24
+ data-stoponhover="<?php echo (empty($a['stop_on_hover']))?'true':$a['stop_on_hover']; ?>"
25
+ data-navigation="<?php echo (empty($a['navigation']))?'true':$a['navigation']; ?>"
26
+ data-navigationtextnext="<?php echo $a['navigation_text_next']; ?>"
27
+ data-navigationtextprev="<?php echo $a['navigation_text_prev']; ?>"
28
+ data-scrollperpage="<?php echo $a['scroll_per_page']; ?>"
29
+ data-pagination="<?php echo $a['pagination']; ?>"
30
+ data-autoheight="<?php echo $a['auto_height']; ?>"
31
+ >
32
+ <?php for ($page = 1; $page <= $page_count; $page++): ?>
33
+ <?php $the_course_index = ($page - 1)*$a['display']; ?>
34
+ <div class="item" >
35
+ <div class="collection-body">
36
+ <?php $page_courses = array_slice($courses, $the_course_index, $a['display']); ?>
37
+ <?php foreach ($page_courses as $course): ?>
38
+ <div class="course-entry">
39
+ <?php if ($a['show_thumbnail']): ?>
40
+ <div class="course-cover">
41
+ <a href="<?php echo get_the_permalink($course->id) ?>">
42
+ <?php echo get_the_post_thumbnail($course->id) ?>
43
+ </a>
44
+ </div>
45
+ <?php endif; ?>
46
+ <div class="course-detail">
47
+ <a href="<?php echo get_the_permalink($course->id) ?>">
48
+ <div class="course-title">
49
+ <?php echo $course->post->post_title; ?>
50
+ </div>
51
+ </a>
52
+ <?php if ($a['show_desc']):?>
53
+ <div class="course-description"><?php
54
+ $the_content = $course->post->post_content;
55
+ $the_content = get_extended( $the_content);
56
+ echo $the_content['main'];
57
+ ?></div>
58
+ <?php endif; ?>
59
+ <div class="course-meta-data">
60
+ <div class="section section-1">
61
+ <?php if($a['show_price']): ?>
62
+ <div
63
+ class="course-price
64
+ <?php if(lp_is_paid_course($course->id)) {
65
+ echo 'paid';
66
+ } else{
67
+ echo 'free';
68
+ };
69
+ ?>">
70
+ <?php
71
+ $paid = lp_is_paid_course($course->id);
72
+ if(! $paid){
73
+ esc_html_e('Free', 'learnpress');
74
+ } else{
75
+ $price = get_post_meta( $course->id, '_lp_price', true);
76
+ echo learn_press_format_price($price, true);
77
+ }
78
+ ?>
79
+ </div>
80
+ <?php endif; ?>
81
+ </div>
82
+ <div class="section section-2 inline">
83
+ <?php if ($a['show_enrolled_students']): ?>
84
+ <div class="course-student-number meta-field">
85
+ <?php
86
+ $students = $course->get_users_enrolled();
87
+ echo $students;
88
+ if (intval($students) > 1) {
89
+ _e(' students', 'learnpress');
90
+ } else {
91
+ _e(' student', 'learnpress');
92
+ }
93
+
94
+ ?>
95
+ </div>
96
+ <?php endif; ?>
97
+ <?php if ($a['show_lesson']): ?>
98
+
99
+ <div class="course-lesson-number meta-field">
100
+ <?php
101
+ $lessons = sizeof($course->get_lessons());
102
+ echo $lessons;
103
+ if (intval($lessons) > 1) {
104
+ _e(' lessons', 'learnpress');
105
+ } else {
106
+ _e(' lesson', 'learnpress');
107
+ }
108
+
109
+ ?>
110
+ </div>
111
+ </div>
112
+ <?php endif; ?>
113
+ <?php if ($a['show_teacher']): ?>
114
+ <div class="section section-3">
115
+ <div class="course-teacher">
116
+ <small>
117
+ <?php _e('instructor: ', 'learnpress'); ?>
118
+ <?php echo $course->get_instructor_html(); ?>
119
+ </small>
120
+ </div>
121
+ </div>
122
+ <?php endif; ?>
123
+ </div>
124
+ </div>
125
+ </div>
126
+ <?php endforeach; ?>
127
+ </div>
128
+ </div>
129
+ <?php endfor; ?>
130
+ </div>
131
+ </div>
132
+ <div class="collection-footer">
133
+ <?php if ($page_count > 1): ?>
134
+ <?php endif; ?>
135
+ </div>
136
+ </div>
137
+ <div class="clearfix"></div>
inc/shortcodes/recent-courses/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden.
inc/shortcodes/recent-courses/recent-courses.php ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once LP_PLUGIN_PATH . "/inc/shortcodes/class-lp-abstract-archive-shortcode.php";
3
+
4
+ /**
5
+ * Shortcode to display collection of recent courses
6
+ * ------GENERAL SYNTAX----------
7
+ * [recent_course
8
+ * title=""
9
+ * limit="10"
10
+ * display="5"
11
+ * show_desc="true"
12
+ * show_thumbnail="true"
13
+ * show_enrolled_students="true"
14
+ * show_teacher="true"
15
+ * css_class=""
16
+ * template = "list"
17
+ *
18
+ * items=""
19
+ * items_desktop="", //null or number
20
+ * items_desktop_small="",
21
+ * itemsTablet= "",
22
+ * items_tablet_small="",
23
+ * items_mobile= "",
24
+ * single_item= "false",
25
+ * items_scale_up= "true",
26
+ * slide_speed= "200",
27
+ * pagination_Speed= "800",
28
+ * rewind_speed= "1000",
29
+ * auto_play= "false",
30
+ * stop_on_hover= "true",
31
+ * navigation= "true",
32
+ * navigation_text_next= "&rarr;",
33
+ * navigation_text_prev= "&larr;",
34
+ * scroll_per_age= "false",
35
+ * pagination= "false",
36
+ * auto_height= "false"
37
+ * ]
38
+ *
39
+ */
40
+
41
+ /**
42
+ * -----OPTIONS-------
43
+ * -Title:
44
+ * the title of collection
45
+ * empty by default
46
+ *
47
+ * -Limit:
48
+ * number, limit of the records will be queried by get_courses function
49
+ *
50
+ * -Display:
51
+ * number of items display on each carousel item
52
+ * only used in list template
53
+ *
54
+ * -show_thumbnail:
55
+ * set whether show course cover picture or not
56
+ * "true" by default
57
+ *
58
+ * -show_desc
59
+ * set whether show course description
60
+ * "false" by default
61
+ *
62
+ * -show_enrolled_students
63
+ * set whether show course's enrolled students
64
+ * "true" by default
65
+ *
66
+ * -show_teacher:
67
+ * set whether show course's instructor
68
+ * "true" by default
69
+ *
70
+ * -css_class:
71
+ * additional custom css class
72
+ *
73
+ * -Templates:
74
+ * there are 3 standard templates is list, grids and cards (list by default)
75
+ * you can also add your custom template by adding php file into templates folder
76
+ *
77
+ * - options for owl carousel (from items to the end)
78
+ * shortcode support some owl carousel slider options
79
+ *
80
+ * please take a look to owl-carousel docs to understand
81
+ * documentation: http://owlgraphic.com/owlcarousel/#customizing
82
+ *
83
+ * the responsive options (items to mobile_items) use short code parameters as the second
84
+ * element of owl carousel option array
85
+ * navigation_text_prev and navigation_text_next is options for navigation button's content
86
+ * by default is left arrow and right arrow
87
+ * -----USAGE----------
88
+ * [recent_course title="Recent courses" template="cards" show_desc="false" limit="20" display="8"]
89
+ */
90
+
91
+
92
+ if ( !class_exists( 'LP_Recent_Courses_Shortcode' ) ) {
93
+ /**
94
+ * Class LP_Recent_Courses_Shortcode
95
+ */
96
+ class LP_Recent_Courses_Shortcode extends LP_Archive_Courses_Shortcode {
97
+ protected $name = "recent-courses";
98
+
99
+ public function get_courses( $a ) {
100
+ global $wpdb;
101
+ $posts = $wpdb->get_results(
102
+ $wpdb->prepare(
103
+ "SELECT DISTINCT ID FROM $wpdb->posts AS p
104
+ WHERE p.post_type = %s
105
+ AND p.post_status = %s
106
+ ORDER BY p.post_date DESC
107
+ LIMIT %d",
108
+ LP_COURSE_CPT,
109
+ 'publish',
110
+ (int) $a['limit']
111
+ )
112
+ );
113
+
114
+ $courses = array_map( array( $this, 'get_lp_course' ), $posts );
115
+
116
+ return $courses;
117
+
118
+ }
119
+ }
120
+ }
121
+ return new LP_Recent_Courses_Shortcode();
inc/shortcodes/recent-courses/templates/cards.php ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //template script
3
+ $template_script = get_site_url() . '/' . LP_WP_CONTENT . '/plugins/learnpress/assets/js/frontend/shortcodes.js';
4
+ ?>
5
+
6
+ <div class="<?php echo 'archive-course-collection-outer recent ' . $a['template'] . ' ' . $a["css_class"] ?>">
7
+ <?php if (!empty($a['title'])): ?>
8
+ <h3 class="title"><?php echo $a['title'] ?></h3>
9
+ <?php endif; ?>
10
+ <div class="collection-body">
11
+ <div class="owl-carousel owl-theme"
12
+ data-items="<?php echo (empty($a['items']))?'3':$a['items']; ?>"
13
+ data-itemsdesktop="<?php echo (empty($a['items_desktop']))?'2':$a['items_desktop']; ?>"
14
+ data-itemsdesktopsmall="<?php echo (empty($a['items_desktop_small']))?'2':$a['items_desktop_small']; ?>"
15
+ data-itemsTablet="<?php echo (empty($a['items_tablet']))?'1':$a['items_tablet']; ?>"
16
+ data-itemsTabletSmall="<?php echo (empty($a['items_tablet_small']))?'1':$a['items_tablet_small']; ?>"
17
+ data-itemsmobile="<?php echo (empty($a['items_mobile']))?'1':$a['items_mobile']; ?>"
18
+ data-singleitem="<?php echo (empty($a['single_item']))?'false':$a['single_item']; ?>"
19
+ data-itemscaleup="<?php echo (empty($a['item_scale_up']))?'true':$a['item_scale_up']; ?>"
20
+ data-slidespeed="<?php echo (empty($a['slide_speed']))?'200':$a['slide_speed']; ?>"
21
+ data-paginationspeed="<?php echo (empty($a['pagination_speed']))?'800':$a['pagination_speed']; ?>"
22
+ data-rewindspeed="<?php echo (empty($a['rewind_speed']))?'1000':$a['rewind_speed']; ?>"
23
+ data-autoplay="<?php echo (empty($a['auto_play']))?'false':$a['auto_play']; ?>"
24
+ data-stoponhover="<?php echo (empty($a['stop_on_hover']))?'true':$a['stop_on_hover']; ?>"
25
+ data-navigation="<?php echo (empty($a['navigation']))?'true':$a['navigation']; ?>"
26
+ data-navigationtextnext="<?php echo $a['navigation_text_next']; ?>"
27
+ data-navigationtextprev="<?php echo $a['navigation_text_prev']; ?>"
28
+ data-scrollperpage="<?php echo $a['scroll_per_page']; ?>"
29
+ data-pagination="<?php echo $a['pagination']; ?>"
30
+ data-autoheight="<?php echo $a['auto_height']; ?>"
31
+ >
32
+ <?php foreach ($courses as $course): ?>
33
+ <div class="item">
34
+ <a href="<?php echo get_the_permalink($course->id) ?>" class="course-entry">
35
+ <div class="course-cover">
36
+ <?php if ($a['show_thumbnail']): ?>
37
+ <?php echo get_the_post_thumbnail($course->id) ?>
38
+ <?php endif; ?>
39
+ <div class="course-detail">
40
+ <?php if ($a['show_desc']): ?>
41
+ <div class="course-description"><?php
42
+ $the_content = $course->post->post_content;
43
+ $the_content = get_extended($the_content);
44
+ echo $the_content['main'];
45
+ ?></div>
46
+ <?php endif; ?>
47
+ <div class="course-meta-data">
48
+ <div class="section section-1">
49
+ <?php if ($a['show_price']): ?>
50
+ <div
51
+ class="course-price
52
+ <?php if (lp_is_paid_course($course->id)) {
53
+ echo 'paid';
54
+ } else {
55
+ echo 'free';
56
+ };
57
+ ?>">
58
+ <?php
59
+ $paid = lp_is_paid_course($course->id);
60
+ if (!$paid) {
61
+ esc_html_e('Free', 'learnpress');
62
+ } else {
63
+ $price = get_post_meta($course->id, '_lp_price', true);
64
+ echo learn_press_format_price($price, true);
65
+ }
66
+ ?>
67
+ </div>
68
+ <?php endif; ?>
69
+ </div>
70
+ <div class="section section-2">
71
+ <?php if ($a['show_enrolled_students']): ?>
72
+ <div class="course-student-number meta-field">
73
+ <?php
74
+ $students = $course->get_users_enrolled();
75
+ echo $students;
76
+ if (intval($students) > 1) {
77
+ _e(' students', 'learnpress');
78
+ } else {
79
+ _e(' student', 'learnpress');
80
+ }
81
+
82
+ ?>
83
+ </div>
84
+ <?php endif; ?>
85
+ <?php if ($a['show_lesson']): ?>
86
+
87
+ <div class="course-lesson-number meta-field">
88
+ <?php
89
+ $lessons = sizeof($course->get_lessons());
90
+ echo $lessons;
91
+ if (intval($lessons) > 1) {
92
+ _e(' lessons', 'learnpress');
93
+ } else {
94
+ _e(' lesson', 'learnpress');
95
+ }
96
+
97
+ ?>
98
+ </div>
99
+ </div>
100
+ <?php endif; ?>
101
+ <?php if ($a['show_teacher']): ?>
102
+ <div class="section section-3">
103
+ <div class="course-teacher">
104
+ <small>
105
+ <?php _e('instructor: ', 'learnpress'); ?>
106
+ <?php echo $course->get_instructor(); ?>
107
+ </small>
108
+ </div>
109
+ </div>
110
+ <?php endif; ?>
111
+ </div>
112
+ </div>
113
+ </div>
114
+ <div class="course-title">
115
+ <?php echo $course->post->post_title; ?>
116
+ </div>
117
+ </a>
118
+ </div>
119
+ <?php endforeach; ?>
120
+ </div>
121
+ </div>
122
+ <div class="collection-footer">
123
+ <?php if ($page_count > 1): ?>
124
+ <?php endif; ?>
125
+ </div>
126
+ </div>
127
+ <div class="clearfix"></div>
inc/shortcodes/recent-courses/templates/grids.php ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //template script
3
+ $template_script = get_site_url() . '/' . LP_WP_CONTENT . '/plugins/learnpress/assets/js/frontend/shortcodes.js';
4
+ ?>
5
+
6
+ <div class="<?php echo 'archive-course-collection-outer recent ' . $a['template'] . ' ' . $a["css_class"] ?>">
7
+ <?php if (!empty($a['title'])): ?>
8
+ <h3 class="title"><?php echo $a['title'] ?></h3>
9
+ <?php endif; ?>
10
+ <div class="collection-body">
11
+ <div class="owl-carousel owl-theme"
12
+ data-items="<?php echo (empty($a['items']))?'4':$a['items']; ?>"
13
+ data-itemsdesktop="<?php echo (empty($a['items_desktop']))?'4':$a['items_desktop']; ?>"
14
+ data-itemsdesktopsmall="<?php echo (empty($a['items_desktop_small']))?'3':$a['items_desktop_small']; ?>"
15
+ data-itemsTablet="<?php echo (empty($a['items_tablet']))?'3':$a['items_tablet']; ?>"
16
+ data-itemsTabletSmall="<?php echo (empty($a['items_tablet_small']))?'2':$a['items_tablet_small']; ?>"
17
+ data-itemsmobile="<?php echo (empty($a['items_mobile']))?'1':$a['items_mobile']; ?>"
18
+ data-singleitem="<?php echo (empty($a['single_item']))?'false':$a['single_item']; ?>"
19
+ data-itemscaleup="<?php echo (empty($a['item_scale_up']))?'true':$a['item_scale_up']; ?>"
20
+ data-slidespeed="<?php echo (empty($a['slide_speed']))?'200':$a['slide_speed']; ?>"
21
+ data-paginationspeed="<?php echo (empty($a['pagination_speed']))?'800':$a['pagination_speed']; ?>"
22
+ data-rewindspeed="<?php echo (empty($a['rewind_speed']))?'1000':$a['rewind_speed']; ?>"
23
+ data-autoplay="<?php echo (empty($a['auto_play']))?'false':$a['auto_play']; ?>"
24
+ data-stoponhover="<?php echo (empty($a['stop_on_hover']))?'true':$a['stop_on_hover']; ?>"
25
+ data-navigation="<?php echo (empty($a['navigation']))?'true':$a['navigation']; ?>"
26
+ data-navigationtextnext="<?php echo $a['navigation_text_next']; ?>"
27
+ data-navigationtextprev="<?php echo $a['navigation_text_prev']; ?>"
28
+ data-scrollperpage="<?php echo $a['scroll_per_page']; ?>"
29
+ data-pagination="<?php echo $a['pagination']; ?>"
30
+ data-autoheight="<?php echo $a['auto_height']; ?>"
31
+ >
32
+ <?php foreach ($courses as $course): ?>
33
+ <div class="item">
34
+ <div class="course-entry">
35
+ <?php if ($a['show_thumbnail']): ?>
36
+ <div class="course-cover">
37
+ <a class="img-link" href="<?php echo get_the_permalink($course->id) ?>">
38
+ <?php echo get_the_post_thumbnail($course->id) ?>
39
+ </a>
40
+ </div>
41
+ <?php endif; ?>
42
+ <div class="course-detail">
43
+ <a href="<?php echo get_the_permalink($course->id) ?>">
44
+ <div class="course-title">
45
+ <?php echo $course->post->post_title; ?>
46
+ </div>
47
+ </a>
48
+ <?php if ($a['show_desc']): ?>
49
+ <div class="course-description"><?php
50
+ $the_content = $course->post->post_content;
51
+ $the_content = get_extended($the_content);
52
+ echo $the_content['main'];
53
+ ?></div>
54
+ <?php endif; ?>
55
+ <div class="course-meta-data">
56
+ <div class="section section-1">
57
+ <?php if ($a['show_price']): ?>
58
+ <div
59
+ class="course-price
60
+ <?php if (lp_is_paid_course($course->id)) {
61
+ echo 'paid';
62
+ } else {
63
+ echo 'free';
64
+ };
65
+ ?>">
66
+ <?php
67
+ $paid = lp_is_paid_course($course->id);
68
+ if (!$paid) {
69
+ esc_html_e('Free', 'learnpress');
70
+ } else {
71
+ $price = get_post_meta($course->id, '_lp_price', true);
72
+ echo learn_press_format_price($price, true);
73
+ }
74
+ ?>
75
+ </div>
76
+ <?php endif; ?>
77
+ </div>
78
+ <div class="section section-2">
79
+ <?php if ($a['show_enrolled_students']): ?>
80
+ <div class="course-student-number meta-field">
81
+ <?php
82
+ $students = $course->get_users_enrolled();
83
+ echo $students;
84
+ if (intval($students) > 1) {
85
+ _e(' students', 'learnpress');
86
+ } else {
87
+ _e(' student', 'learnpress');
88
+ }
89
+
90
+ ?>
91
+ </div>
92
+ <?php endif; ?>
93
+ <?php if ($a['show_lesson']): ?>
94
+
95
+ <div class="course-lesson-number meta-field">
96
+ <?php
97
+ $lessons = sizeof($course->get_lessons());
98
+ echo $lessons;
99
+ if (intval($lessons) > 1) {
100
+ _e(' lessons', 'learnpress');
101
+ } else {
102
+ _e(' lesson', 'learnpress');
103
+ }
104
+
105
+ ?>
106
+ </div>
107
+ </div>
108
+ <?php endif; ?>
109
+ <?php if ($a['show_teacher']): ?>
110
+ <div class="section section-3">
111
+ <div class="course-teacher">
112
+ <small>
113
+ <?php _e('instructor: ', 'learnpress'); ?>
114
+ <?php echo $course->get_instructor_html(); ?>
115
+ </small>
116
+ </div>
117
+ </div>
118
+ <?php endif; ?>
119
+ </div>
120
+ </div>
121
+ </div>
122
+ </div>
123
+ <?php endforeach; ?>
124
+ </div>
125
+ </div>
126
+ <div class="collection-footer">
127
+ <?php if ($page_count > 1): ?>
128
+ <?php endif; ?>
129
+ </div>
130
+ </div>
131
+ <div class="clearfix"></div>
inc/shortcodes/recent-courses/templates/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden.
inc/shortcodes/recent-courses/templates/list.php ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $template_script = get_site_url() . '/' . LP_WP_CONTENT . '/plugins/learnpress/assets/js/frontend/shortcodes.js';
3
+ ?>
4
+
5
+ <div class="<?php echo 'archive-course-collection-outer recent ' . $a['template'] . ' ' . $a["css_class"] ?>">
6
+ <?php if (!empty($a['title'])): ?>
7
+ <h3 class="title"><?php echo $a['title'] ?></h3>
8
+ <?php endif; ?>
9
+ <div class="collection-holder">
10
+ <div class="owl-carousel owl-theme"
11
+ data-items="<?php echo (empty($a['items']))?'1':$a['items']; ?>"
12
+ data-itemsdesktop="<?php echo (empty($a['items_desktop']))?'1':$a['items_desktop']; ?>"
13
+ data-itemsdesktopsmall="<?php echo (empty($a['items_desktop_small']))?'1':$a['items_desktop_small']; ?>"
14
+ data-itemsTablet="<?php echo (empty($a['items_tablet']))?'1':$a['items_tablet']; ?>"
15
+ data-itemsTabletSmall="<?php echo (empty($a['items_tablet_small']))?'1':$a['items_tablet_small']; ?>"
16
+ data-itemsmobile="<?php echo (empty($a['items_mobile']))?'1':$a['items_mobile']; ?>"
17
+ data-singleitem="<?php echo (empty($a['single_item']))?'false':$a['single_item']; ?>"
18
+ data-itemscaleup="<?php echo (empty($a['item_scale_up']))?'true':$a['item_scale_up']; ?>"
19
+ data-slidespeed="<?php echo (empty($a['slide_speed']))?'200':$a['slide_speed']; ?>"
20
+ data-paginationspeed="<?php echo (empty($a['pagination_speed']))?'800':$a['pagination_speed']; ?>"
21
+ data-rewindspeed="<?php echo (empty($a['rewind_speed']))?'1000':$a['rewind_speed']; ?>"
22
+ data-autoplay="<?php echo (empty($a['auto_play']))?'false':$a['auto_play']; ?>"
23
+ data-stoponhover="<?php echo (empty($a['stop_on_hover']))?'true':$a['stop_on_hover']; ?>"
24
+ data-navigation="<?php echo (empty($a['navigation']))?'true':$a['navigation']; ?>"
25
+ data-navigationtextnext="<?php echo $a['navigation_text_next']; ?>"
26
+ data-navigationtextprev="<?php echo $a['navigation_text_prev']; ?>"
27
+ data-scrollperpage="<?php echo $a['scroll_per_page']; ?>"
28
+ data-pagination="<?php echo $a['pagination']; ?>"
29
+ data-autoheight="<?php echo $a['auto_height']; ?>"
30
+ >
31
+ <?php for ($page = 1; $page <= $page_count; $page++): ?>
32
+ <?php $the_course_index = ($page - 1)*$a['display']; ?>
33
+ <div class="item" >
34
+ <div class="collection-body">
35
+ <?php $page_courses = array_slice($courses, $the_course_index, $a['display']); ?>
36
+ <?php foreach ($page_courses as $course): ?>
37
+ <div class="course-entry">
38
+ <?php if ($a['show_thumbnail']): ?>
39
+ <div class="course-cover">
40
+ <a href="<?php echo get_the_permalink($course->id) ?>">
41
+ <?php echo get_the_post_thumbnail($course->id) ?>
42
+ </a>
43
+ </div>
44
+ <?php endif; ?>
45
+ <div class="course-detail">
46
+ <a href="<?php echo get_the_permalink($course->id) ?>">
47
+ <div class="course-title">
48
+ <?php echo $course->post->post_title; ?>
49
+ </div>
50
+ </a>
51
+ <?php if ($a['show_desc']):?>
52
+ <div class="course-description"><?php
53
+ $the_content = $course->post->post_content;
54
+ $the_content = get_extended( $the_content);
55
+ echo $the_content['main'];
56
+ ?></div>
57
+ <?php endif; ?>
58
+ <div class="course-meta-data">
59
+ <div class="section section-1">
60
+ <?php if($a['show_price']): ?>
61
+ <div
62
+ class="course-price
63
+ <?php if(lp_is_paid_course($course->id)) {
64
+ echo 'paid';
65
+ } else{
66
+ echo 'free';
67
+ };
68
+ ?>">
69
+ <?php
70
+ $paid = lp_is_paid_course($course->id);
71
+ if(! $paid){
72
+ esc_html_e('Free', 'learnpress');
73
+ } else{
74
+ $price = get_post_meta( $course->id, '_lp_price', true);
75
+ echo learn_press_format_price($price, true);
76
+ }
77
+ ?>
78
+ </div>
79
+ <?php endif; ?>
80
+ </div>
81
+ <div class="section section-2 inline">
82
+ <?php if ($a['show_enrolled_students']): ?>
83
+ <div class="course-student-number meta-field">
84
+ <?php
85
+ $students = $course->get_users_enrolled();
86
+ echo $students;
87
+ if (intval($students) > 1) {
88
+ _e(' students', 'learnpress');
89
+ } else {
90
+ _e(' student', 'learnpress');
91
+ }
92
+
93
+ ?>
94
+ </div>
95
+ <?php endif; ?>
96
+ <?php if ($a['show_lesson']): ?>
97
+
98
+ <div class="course-lesson-number meta-field">
99
+ <?php
100
+ $lessons = sizeof($course->get_lessons());
101
+ echo $lessons;
102
+ if (intval($lessons) > 1) {
103
+ _e(' lessons', 'learnpress');
104
+ } else {
105
+ _e(' lesson', 'learnpress');
106
+ }
107
+
108
+ ?>
109
+ </div>
110
+ </div>
111
+ <?php endif; ?>
112
+ <?php if ($a['show_teacher']): ?>
113
+ <div class="section section-3">
114
+ <div class="course-teacher">
115
+ <small>
116
+ <?php _e('instructor: ', 'learnpress'); ?>
117
+ <?php echo $course->get_instructor_html(); ?>
118
+ </small>
119
+ </div>
120
+ </div>
121
+ <?php endif; ?>
122
+ </div>
123
+ </div>
124
+ </div>
125
+ <?php endforeach; ?>
126
+ </div>
127
+ </div>
128
+ <?php endfor; ?>
129
+ </div>
130
+ </div>
131
+ <div class="collection-footer">
132
+ <?php if ($page_count > 1): ?>
133
+ <?php endif; ?>
134
+ </div>
135
+ </div>
136
+ <div class="clearfix"></div>
inc/updates/09/script.js CHANGED
@@ -58,13 +58,14 @@
58
  var $doc = $(document);
59
 
60
  function parseJSON(response) {
61
- var matches = response.match(/<-- LP_AJAX_START -->(.*)<-- LP_AJAX_END -->/),
62
  json = {};
63
 
64
  if (matches && matches[1]) {
65
  try {
66
  json = JSON.parse(matches[1]);
67
  } catch (e) {
 
68
  }
69
  }
70
  return json;
58
  var $doc = $(document);
59
 
60
  function parseJSON(response) {
61
+ var matches = response.match(/<!-- LP_AJAX_START -->(.*)<!-- LP_AJAX_END -->/),
62
  json = {};
63
 
64
  if (matches && matches[1]) {
65
  try {
66
  json = JSON.parse(matches[1]);
67
  } catch (e) {
68
+ LP.log(e);
69
  }
70
  }
71
  return json;
inc/user/abstract-lp-user.php CHANGED
@@ -11,6 +11,10 @@
11
  defined( 'ABSPATH' ) || exit();
12
 
13
  class LP_Abstract_User {
 
 
 
 
14
 
15
  /**
16
  * @var int
@@ -57,8 +61,6 @@ class LP_Abstract_User {
57
  */
58
  protected $_course_items = array();
59
 
60
- protected static $_users = array();
61
-
62
  /**
63
  * Constructor
64
  *
@@ -67,20 +69,12 @@ class LP_Abstract_User {
67
  * @throws Exception
68
  */
69
  public function __construct( $the_user = 0 ) {
70
- $deleted = in_array( $the_user, LP_User_Factory::$_deleted_users );
71
- $user = !$deleted ? get_user_by( 'id', $the_user ) : false;
72
-
73
- if ( !$user ) {
74
- $user = (object) array(
75
- 'ID' => 0
76
- );
77
- if ( !$deleted ) {
78
- LP_User_Factory::$_deleted_users[] = $the_user;
79
- }
80
  }
81
-
82
- $this->user = $user;
83
- $this->id = $user->ID;
84
  if ( empty( self::$_lessons[$this->id] ) ) {
85
  self::$_lessons[$this->id] = array();
86
  }
@@ -292,7 +286,7 @@ class LP_Abstract_User {
292
  public function start_quiz( $quiz_id, $course_id = 0 ) {
293
  $course_id = $this->_get_course_id( $course_id );
294
  if ( !apply_filters( 'learn_press_before_user_start_quiz', true, $quiz_id, $course_id, $this->id ) ) {
295
- return false;
296
  }
297
  $history = $this->get_quiz_history( $quiz_id, $course_id, null, true );
298
  if ( !$history ) {
@@ -465,9 +459,6 @@ class LP_Abstract_User {
465
  * @return mixed
466
  */
467
  public function finish_quiz( $quiz_id, $course_id, $args = '' ) {
468
- if ( !apply_filters( 'learn_press_before_user_finish_quiz', true, $quiz_id, $course_id, $this->id ) ) {
469
- return false;
470
- }
471
  $course_id = $this->_get_course_id( $course_id );
472
 
473
  $quiz = LP_Quiz::get_quiz( $quiz_id );
@@ -520,9 +511,6 @@ class LP_Abstract_User {
520
  * @throws Exception
521
  */
522
  public function retake_quiz( $quiz_id, $course_id ) {
523
- if ( !apply_filters( 'learn_press_before_user_retake_quiz', true, $quiz_id, $course_id, $this->id ) ) {
524
- return false;
525
- }
526
  $course_id = $this->_get_course_id( $course_id );
527
  $response = false;
528
  $return = learn_press_update_user_item_field(
@@ -1460,12 +1448,11 @@ class LP_Abstract_User {
1460
  * @return bool
1461
  */
1462
  public function has_enrolled_course( $course_id, $force = false ) {
1463
- _learn_press_parse_user_item_statuses( $this->id, $course_id, $force );
1464
  if ( $enrolled = $this->has_purchased_course( $course_id ) ) {
1465
  $item_statuses = LP_Cache::get_item_statuses( false, array() );
1466
  $key = sprintf( '%d-%d-%d', $this->id, $course_id, $course_id );
1467
  $enrolled = false;
1468
-
1469
  if ( !array_key_exists( $key, $item_statuses ) ) {
1470
  $enrolled = $item_statuses[$key] = $this->_has_enrolled_course( $course_id );
1471
  } elseif ( !empty( $item_statuses[$key] ) && $item_statuses[$key] != '' ) {
@@ -2188,9 +2175,6 @@ class LP_Abstract_User {
2188
  */
2189
  private function _parse_item_order_of_course( $course_id ) {
2190
  static $courses_parsed = array();
2191
- if ( !$this->id ) {
2192
- return;
2193
- }
2194
  if ( !empty( $courses_parsed[$this->id . '-' . $course_id] ) ) {
2195
  return true;
2196
  }
@@ -2400,7 +2384,7 @@ class LP_Abstract_User {
2400
  );
2401
  $query .= $where . $order . $limit;
2402
 
2403
- $data = array(
2404
  'rows' => $wpdb->get_results( $query, OBJECT_K )
2405
  );
2406
  $data['count'] = $wpdb->get_var( "SELECT FOUND_ROWS();" );
@@ -2409,8 +2393,6 @@ class LP_Abstract_User {
2409
  $course_ids = array_keys( $data['rows'] );
2410
  learn_press_setup_user_course_data( $this->id, $course_ids );
2411
  learn_press_get_user_courses_info( $this->id, $course_ids );
2412
- _learn_press_count_users_enrolled_courses( $course_ids );
2413
-
2414
  }
2415
  $courses[$key] = $data;
2416
  }
@@ -2486,12 +2468,10 @@ class LP_Abstract_User {
2486
  foreach ( $course_info['items'] as $k => $item ) {
2487
  if ( $item['type'] == 'lp_quiz' ) {
2488
  $result = $this->get_quiz_results( $item['id'], $course_id );
2489
- $passing_grade_type = get_post_meta( $item['id'], '_lp_passing_grade_type', true );
2490
  $course_info['items'][$k] = array_merge(
2491
  $course_info['items'][$k],
2492
  array(
2493
- 'results' => $result ? ( $passing_grade_type == 'point' ? sprintf( '%d/%d', $result->mark, $result->quiz_mark ) : $result->mark_percent . '%' ) : '',
2494
- 'passing_grade_type' => $passing_grade_type
2495
  )
2496
  );
2497
  }
@@ -2685,9 +2665,7 @@ class LP_Abstract_User {
2685
  if ( $curriculum && $curriculum->items ) {
2686
  foreach ( $curriculum->items as $item ) {
2687
  if ( $this->has_completed_item( $item->ID, $course_id, $force ) ) {
2688
- if ( $course->enable_evaluate_item( $item->ID, $this->id ) ) {
2689
- $completed ++;
2690
- }
2691
  }
2692
  }
2693
  }
@@ -2730,27 +2708,23 @@ class LP_Abstract_User {
2730
  * @return mixed|void
2731
  */
2732
  public function get_quiz_graduation( $quiz_id, $course_id = 0, $check_completed = true ) {
 
2733
 
2734
- if ( !$grade = LP_Cache::get_quiz_grade( sprintf( '%d-%d-%d', $this->id, $course_id, $quiz_id ) ) ) {
2735
- $course_id = $this->_get_course_id( $course_id );
2736
- $result = $this->get_quiz_results( $quiz_id, $course_id );
2737
- $grade = '';
2738
- if ( $result && ( ( $check_completed == false ) || $check_completed && $result->status == 'completed' ) ) {
2739
- $quiz = LP_Quiz::get_quiz( $quiz_id );
2740
-
2741
- $grade_type = $quiz->passing_grade_type;
2742
- $passing_grade = $quiz->passing_grade;
2743
- if ( $grade_type == 'point' ) {
2744
- $grade = $passing_grade <= $result->mark;
2745
- } elseif ( $grade_type == 'percentage' ) {
2746
- $grade = $passing_grade <= $result->mark_percent;
2747
- } else {
2748
- $grade = true;
2749
- }
2750
- $grade = $grade ? 'passed' : 'failed';
2751
  }
 
2752
  }
2753
- //echo $quiz_id, ',',LP_Cache::get_quiz_grade( sprintf( '%d-%d-%d', $this->id, $course_id, $quiz_id ));
2754
  return apply_filters( 'learn_press_user_quiz_graduation', $grade, $quiz_id, $course_id );
2755
  }
2756
 
@@ -2764,7 +2738,7 @@ class LP_Abstract_User {
2764
  * @return bool
2765
  */
2766
  public function is_exists() {
2767
- return ( $this->user->ID > 0 ) && ( false !== get_userdata( $this->user->ID ) );
2768
  }
2769
 
2770
  /**
@@ -2879,39 +2853,6 @@ class LP_Abstract_User {
2879
  return apply_filters( 'learn_press_user_can_do_quiz', $can, $quiz_id, $this->id, $course_id );
2880
  }
2881
 
2882
- /**
2883
- * Get user course's grade.
2884
- * Possible values:
2885
- * + passed User has finished and passed course
2886
- * + failed User has finished but failed
2887
- * + in-progress User still is learning course
2888
- * + false All other cases, e.g: not enrolled
2889
- *
2890
- * @param $course_id
2891
- *
2892
- * @return mixed|void
2893
- * @throws Exception
2894
- */
2895
- public function get_course_grade( $course_id ) {
2896
- $course = LP_Course::get_course( $course_id );
2897
- $status = $this->get( 'course-status', $course_id );
2898
- $grade = false;
2899
- if ( $status == 'finished' ) {
2900
- $result = $course->evaluate_course_results( $this->id );
2901
- $current = absint( $result );
2902
- $passing_condition = absint( $course->passing_condition );
2903
- $passed = $current >= $passing_condition;
2904
- if ( $passed ) {
2905
- $grade = 'passed';
2906
- } else {
2907
- $grade = 'failed';
2908
- }
2909
- } else if ( $status && $status != 'finished' ) {
2910
- $grade = 'in-progress';
2911
- }
2912
- return apply_filters( 'learn_press_user_course_grade', $grade, $this->id, $course_id );
2913
- }
2914
-
2915
  public static function get_user() {
2916
  _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '2.0.7', 'LP_User_Factory::get_user' );
2917
  $func_args = func_get_args();
11
  defined( 'ABSPATH' ) || exit();
12
 
13
  class LP_Abstract_User {
14
+ /**
15
+ * @var array
16
+ */
17
+ static protected $_users = array();
18
 
19
  /**
20
  * @var int
61
  */
62
  protected $_course_items = array();
63
 
 
 
64
  /**
65
  * Constructor
66
  *
69
  * @throws Exception
70
  */
71
  public function __construct( $the_user = 0 ) {
72
+ if ( $user = get_user_by( 'id', $the_user ) ) {
73
+ $this->user = $user;
74
+ $this->id = $user->ID;
75
+ } else {
76
+ //throw new Exception( sprintf( __( 'The user with ID = %d is not exists', 'learnpress' ), $the_user ) );
 
 
 
 
 
77
  }
 
 
 
78
  if ( empty( self::$_lessons[$this->id] ) ) {
79
  self::$_lessons[$this->id] = array();
80
  }
286
  public function start_quiz( $quiz_id, $course_id = 0 ) {
287
  $course_id = $this->_get_course_id( $course_id );
288
  if ( !apply_filters( 'learn_press_before_user_start_quiz', true, $quiz_id, $course_id, $this->id ) ) {
289
+ //return false;
290
  }
291
  $history = $this->get_quiz_history( $quiz_id, $course_id, null, true );
292
  if ( !$history ) {
459
  * @return mixed
460
  */
461
  public function finish_quiz( $quiz_id, $course_id, $args = '' ) {
 
 
 
462
  $course_id = $this->_get_course_id( $course_id );
463
 
464
  $quiz = LP_Quiz::get_quiz( $quiz_id );
511
  * @throws Exception
512
  */
513
  public function retake_quiz( $quiz_id, $course_id ) {
 
 
 
514
  $course_id = $this->_get_course_id( $course_id );
515
  $response = false;
516
  $return = learn_press_update_user_item_field(
1448
  * @return bool
1449
  */
1450
  public function has_enrolled_course( $course_id, $force = false ) {
1451
+
1452
  if ( $enrolled = $this->has_purchased_course( $course_id ) ) {
1453
  $item_statuses = LP_Cache::get_item_statuses( false, array() );
1454
  $key = sprintf( '%d-%d-%d', $this->id, $course_id, $course_id );
1455
  $enrolled = false;
 
1456
  if ( !array_key_exists( $key, $item_statuses ) ) {
1457
  $enrolled = $item_statuses[$key] = $this->_has_enrolled_course( $course_id );
1458
  } elseif ( !empty( $item_statuses[$key] ) && $item_statuses[$key] != '' ) {
2175
  */
2176
  private function _parse_item_order_of_course( $course_id ) {
2177
  static $courses_parsed = array();
 
 
 
2178
  if ( !empty( $courses_parsed[$this->id . '-' . $course_id] ) ) {
2179
  return true;
2180
  }
2384
  );
2385
  $query .= $where . $order . $limit;
2386
 
2387
+ $data = array(
2388
  'rows' => $wpdb->get_results( $query, OBJECT_K )
2389
  );
2390
  $data['count'] = $wpdb->get_var( "SELECT FOUND_ROWS();" );
2393
  $course_ids = array_keys( $data['rows'] );
2394
  learn_press_setup_user_course_data( $this->id, $course_ids );
2395
  learn_press_get_user_courses_info( $this->id, $course_ids );
 
 
2396
  }
2397
  $courses[$key] = $data;
2398
  }
2468
  foreach ( $course_info['items'] as $k => $item ) {
2469
  if ( $item['type'] == 'lp_quiz' ) {
2470
  $result = $this->get_quiz_results( $item['id'], $course_id );
 
2471
  $course_info['items'][$k] = array_merge(
2472
  $course_info['items'][$k],
2473
  array(
2474
+ 'results' => $result ? $result->mark_percent : 0
 
2475
  )
2476
  );
2477
  }
2665
  if ( $curriculum && $curriculum->items ) {
2666
  foreach ( $curriculum->items as $item ) {
2667
  if ( $this->has_completed_item( $item->ID, $course_id, $force ) ) {
2668
+ $completed ++;
 
 
2669
  }
2670
  }
2671
  }
2708
  * @return mixed|void
2709
  */
2710
  public function get_quiz_graduation( $quiz_id, $course_id = 0, $check_completed = true ) {
2711
+ $course_id = $this->_get_course_id( $course_id );
2712
 
2713
+ $result = $this->get_quiz_results( $quiz_id, $course_id );
2714
+ $grade = '';
2715
+ if ( $result && ( ( $check_completed == false ) || $check_completed && $result->status == 'completed' ) ) {
2716
+ $quiz = LP_Quiz::get_quiz( $quiz_id );
2717
+ $grade_type = $quiz->passing_grade_type;
2718
+ $passing_grade = $quiz->passing_grade;
2719
+ if ( $grade_type == 'point' ) {
2720
+ $grade = $passing_grade <= $result->mark;
2721
+ } elseif ( $grade_type == 'percentage' ) {
2722
+ $grade = $passing_grade <= $result->mark_percent;
2723
+ } else {
2724
+ $grade = true;
 
 
 
 
 
2725
  }
2726
+ $grade = $grade ? 'passed' : 'failed';
2727
  }
 
2728
  return apply_filters( 'learn_press_user_quiz_graduation', $grade, $quiz_id, $course_id );
2729
  }
2730
 
2738
  * @return bool
2739
  */
2740
  public function is_exists() {
2741
+ return $this->user->ID > 0;
2742
  }
2743
 
2744
  /**
2853
  return apply_filters( 'learn_press_user_can_do_quiz', $can, $quiz_id, $this->id, $course_id );
2854
  }
2855
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2856
  public static function get_user() {
2857
  _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '2.0.7', 'LP_User_Factory::get_user' );
2858
  $func_args = func_get_args();
inc/user/class-lp-profile.php DELETED
@@ -1,114 +0,0 @@
1
- <?php
2
- if ( !defined( 'ABSPATH' ) ) {
3
- exit; // Exit if accessed directly
4
- }
5
-
6
- if ( !class_exists( 'LP_Profile' ) ) {
7
- /**
8
- * Class LP_Profile
9
- *
10
- * Main class to controls the profile of a user
11
- */
12
- class LP_Profile {
13
- /**
14
- * The instances of all users has initialed a profile
15
- *
16
- * @var array
17
- */
18
- protected static $_instances = array();
19
-
20
- /**
21
- * @var LP_User
22
- */
23
- protected $_user = false;
24
-
25
- /**
26
- * Constructor
27
- */
28
- public function __construct( $user ) {
29
- $this->_user = $user;
30
- $this->get_user();
31
- }
32
-
33
- public function get_user() {
34
- if ( is_numeric( $this->_user ) ) {
35
- $this->_user = learn_press_get_user( $this->_user );
36
- } elseif ( empty( $this->_user ) ) {
37
- $this->_user = learn_press_get_current_user();
38
- }
39
- return $this->_user;
40
- }
41
-
42
- public function get_tabs() {
43
- $course_endpoint = LP()->settings->get( 'profile_endpoints.profile-courses' );
44
- if ( !$course_endpoint ) {
45
- $course_endpoint = 'profile-courses';
46
- }
47
-
48
- $quiz_endpoint = LP()->settings->get( 'profile_endpoints.profile-quizzes' );
49
- if ( !$quiz_endpoint ) {
50
- $quiz_endpoint = 'profile-quizzes';
51
- }
52
-
53
- $order_endpoint = LP()->settings->get( 'profile_endpoints.profile-orders' );
54
- if ( !$order_endpoint ) {
55
- $order_endpoint = 'profile-orders';
56
- }
57
-
58
- $view_order_endpoint = LP()->settings->get( 'profile_endpoints' );
59
- if ( !$view_order_endpoint ) {
60
- $view_order_endpoint = 'order';
61
- }
62
-
63
- $defaults = array(
64
- $course_endpoint => array(
65
- 'title' => __( 'Courses', 'learnpress' ),
66
- 'callback' => 'learn_press_profile_tab_courses_content'
67
- ),
68
- /*$quiz_endpoint => array(
69
- 'title' => __( 'Quiz Results', 'learnpress' ),
70
- 'callback' => 'learn_press_profile_tab_quizzes_content'
71
- )*/
72
- );
73
-
74
- if ( $this->_user->id == get_current_user_id() ) {
75
- $defaults[$order_endpoint] = array(
76
- 'title' => __( 'Orders', 'learnpress' ),
77
- 'callback' => 'learn_press_profile_tab_orders_content'
78
- );
79
- }
80
-
81
- $tabs = apply_filters( 'learn_press_user_profile_tabs', $defaults, $this->_user );
82
- if ( $this->_user->id == get_current_user_id() ) {
83
- $tabs['edit'] = array(
84
- 'title' => apply_filters( 'learn_press_user_profile_tab_edit_title', __( 'Edit', 'learnpress' ) ),
85
- 'callback' => 'learn_press_profile_tab_edit_content'
86
- );
87
- }
88
-
89
- foreach ( $tabs as $slug => $opt ) {
90
- if ( !empty( $defaults[$slug] ) ) {
91
- continue;
92
- }
93
- LP()->query_vars[$slug] = $slug;
94
- add_rewrite_endpoint( $slug, EP_PAGES );
95
- }
96
-
97
- return $tabs;
98
- }
99
-
100
- /**
101
- * Get an instance of LP_Profile for a user id
102
- *
103
- * @param $user_id
104
- *
105
- * @return LP_Profile mixed
106
- */
107
- public static function instance( $user_id ) {
108
- if ( empty( self::$_instances[$user_id] ) ) {
109
- self::$_instances[$user_id] = new self( $user_id );
110
- }
111
- return self::$_instances[$user_id];
112
- }
113
- }
114
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/user/class-lp-user-factory.php CHANGED
@@ -16,8 +16,6 @@ class LP_User_Factory {
16
  */
17
  protected static $_guest_transient = 0;
18
 
19
- public static $_deleted_users = array();
20
-
21
  /**
22
  *
23
  */
@@ -113,17 +111,16 @@ class LP_User_Factory {
113
  * @return LP_Abstract_User
114
  */
115
  public static function get_user( $the_user, $force = false ) {
116
- $the_id = 0;
117
  if ( is_numeric( $the_user ) ) {
118
  $the_id = $the_user;
119
  } elseif ( $the_user instanceof LP_Abstract_User ) {
120
  $the_id = $the_user->id;
121
  } elseif ( isset( $the_user->ID ) ) {
122
  $the_id = $the_user->ID;
123
- } elseif ( null === $the_user ) {
 
124
  $the_id = get_current_user_id();
125
  }
126
-
127
  $user_class = self::get_user_class( $the_id );
128
  if ( empty( self::$_users[$the_id] ) || $force ) {
129
  self::$_users[$the_id] = new $user_class( $the_id );
@@ -140,22 +137,9 @@ class LP_User_Factory {
140
  * @return mixed|void
141
  */
142
  public static function get_user_class( $the_id = 0 ) {
143
- $deleted = in_array( $the_id, self::$_deleted_users );
144
- $exists_user = !$deleted ? get_userdata( $the_id ) : false;
145
- if ( $exists_user ) {
146
  $class = 'LP_User';
147
  } else {
148
- if ( !$deleted ) {
149
- self::$_deleted_users[] = $the_id;
150
- /**
151
- * Prevent loading user does not exists in database
152
- */
153
- $user = new LP_User_Guest( $the_id );
154
- wp_cache_add( $the_id, $user, 'users' );
155
- wp_cache_add( '', $the_id, 'userlogins' );
156
- wp_cache_add( '', $the_id, 'useremail' );
157
- wp_cache_add( '', $the_id, 'userslugs' );
158
- }
159
  $is_logged_in = function_exists( 'is_user_logged_in' ) && is_user_logged_in();
160
  $class = $is_logged_in ? 'LP_User' : 'LP_User_Guest';
161
  }
@@ -224,12 +208,8 @@ class LP_User_Factory {
224
  if ( get_user_by( 'id', $user_id ) ) {
225
  return;
226
  }
227
- if ( !$item ) {
228
- return;
229
- }
230
- $item_id = !empty( $item->user_item_id ) ? $item->user_item_id : $item->history_id;
231
- learn_press_add_user_item_meta( $item_id, 'temp_user_id', 'yes' );
232
- learn_press_add_user_item_meta( $item_id, 'temp_user_time', date( 'Y-m-d H:i:s', time() ) );
233
  }
234
  }
235
 
16
  */
17
  protected static $_guest_transient = 0;
18
 
 
 
19
  /**
20
  *
21
  */
111
  * @return LP_Abstract_User
112
  */
113
  public static function get_user( $the_user, $force = false ) {
 
114
  if ( is_numeric( $the_user ) ) {
115
  $the_id = $the_user;
116
  } elseif ( $the_user instanceof LP_Abstract_User ) {
117
  $the_id = $the_user->id;
118
  } elseif ( isset( $the_user->ID ) ) {
119
  $the_id = $the_user->ID;
120
+ }
121
+ if ( empty( $the_id ) ) {
122
  $the_id = get_current_user_id();
123
  }
 
124
  $user_class = self::get_user_class( $the_id );
125
  if ( empty( self::$_users[$the_id] ) || $force ) {
126
  self::$_users[$the_id] = new $user_class( $the_id );
137
  * @return mixed|void
138
  */
139
  public static function get_user_class( $the_id = 0 ) {
140
+ if ( $the_id && get_userdata( $the_id ) ) {
 
 
141
  $class = 'LP_User';
142
  } else {
 
 
 
 
 
 
 
 
 
 
 
143
  $is_logged_in = function_exists( 'is_user_logged_in' ) && is_user_logged_in();
144
  $class = $is_logged_in ? 'LP_User' : 'LP_User_Guest';
145
  }
208
  if ( get_user_by( 'id', $user_id ) ) {
209
  return;
210
  }
211
+ learn_press_add_user_item_meta( $item->user_item_id, 'temp_user_id', 'yes' );
212
+ learn_press_add_user_item_meta( $item->user_item_id, 'temp_user_time', date( 'Y-m-d H:i:s', time() ) );
 
 
 
 
213
  }
214
  }
215
 
inc/user/lp-user-functions.php CHANGED
@@ -59,7 +59,7 @@ function learn_press_get_current_user_id() {
59
  * @return LP_User
60
  */
61
  function learn_press_get_current_user( $user_id = 0 ) {
62
- return LP_User_Factory::get_user( $user_id ? $user_id : get_current_user_id() );
63
  }
64
 
65
  /**
@@ -903,19 +903,9 @@ function learn_press_user_profile_picture_upload_dir( $width_user = true ) {
903
  if ( $width_user ) {
904
  $subdir .= '/' . get_current_user_id();
905
  }
906
- $subdir = '/' . $subdir;
907
-
908
- if ( !empty( $upload_dir['subdir'] ) ) {
909
- $u_subdir = str_replace( '\\', '/', $upload_dir['subdir'] );
910
- $u_path = str_replace( '\\', '/', $upload_dir['path'] );
911
-
912
- $upload_dir['path'] = str_replace( $u_subdir, $subdir, $u_path );
913
- $upload_dir['url'] = str_replace( $u_subdir, $subdir, $upload_dir['url'] );
914
- } else {
915
- $upload_dir['path'] = $upload_dir['path'] . $subdir;
916
- $upload_dir['url'] = $upload_dir['url'] . $subdir;
917
- }
918
-
919
  $upload_dir['subdir'] = $subdir;
920
 
921
  // Point path/url to main site if we are in multisite
@@ -998,12 +988,9 @@ function _learn_press_redirect_logout_redirect() {
998
  $admin_url = admin_url();
999
  $pos = strpos( $redirect_to, $admin_url );
1000
  if ( $pos === false ) {
1001
- $page_id = LP()->settings->get( 'logout_redirect_page_id' );
1002
- $page_url = get_page_link( $page_id );
1003
- if ( $page_id && $page_url ) {
1004
- wp_redirect( $page_url );
1005
- exit();
1006
- }
1007
  }
1008
  }
1009
 
@@ -1263,89 +1250,69 @@ function learn_press_get_avatar_thumb_size() {
1263
  */
1264
  function learn_press_get_user_courses_info( $user_id, $course_ids ) {
1265
  global $wpdb;
1266
- $user_course_info = LP_Cache::get_course_info( false, array() );
1267
 
1268
- if ( $user_id ) {
1269
- settype( $course_ids, 'array' );
1270
- $format = array( $user_id );
1271
- $format = array_merge( $format, $course_ids, array( 'lp_course' ) );
1272
- $in = array_fill( 0, sizeof( $course_ids ), '%d' );
1273
- $query = $wpdb->prepare( "
1274
- SELECT uc.*
1275
- FROM {$wpdb->prefix}learnpress_user_items uc
1276
- INNER JOIN {$wpdb->posts} o ON o.ID = uc.item_id
1277
- WHERE uc.user_id = %d AND uc.status IS NOT NULL
1278
- AND uc.item_id IN(" . join( ',', $in ) . ") AND uc.item_type = %s
1279
- ORDER BY user_item_id DESC
1280
- ", $format );
1281
- if ( empty( $user_course_info[$user_id] ) ) {
1282
- $user_course_info[$user_id] = array();
1283
- }
1284
 
1285
- if ( $result = $wpdb->get_results( $query ) ) {
1286
- foreach ( $result as $row ) {
1287
- $course_id = $row->item_id;
1288
- if ( !empty( $user_course_info[$user_id][$course_id]['history_id'] ) ) {
1289
- continue;
1290
- }
1291
- //$row = $result;
1292
- $info = array(
1293
- 'history_id' => 0,
1294
- 'start' => null,
1295
- 'end' => null,
1296
- 'status' => null
1297
- );
1298
- $course = learn_press_get_course( $course_id );
1299
- $info['history_id'] = $row->user_item_id;
1300
- $info['start'] = $row->start_time;
1301
- $info['end'] = $row->end_time;
1302
- $info['status'] = $row->status;
1303
- $info['results'] = $course->evaluate_course_results( $user_id );
1304
- $info['items'] = $course->get_items_params( $user_id );
1305
- $user_course_info[$user_id][$course_id] = $info;
1306
- }
1307
- }
1308
- // Set default data if a course is not existing in database
1309
- foreach ( $course_ids as $cid ) {
1310
- if ( isset( $user_course_info[$user_id], $user_course_info[$user_id][$cid] ) ) {
1311
  continue;
1312
  }
1313
- $user_course_info[$user_id][$cid] = array(
 
1314
  'history_id' => 0,
1315
  'start' => null,
1316
  'end' => null,
1317
  'status' => null
1318
  );
 
 
 
 
 
 
 
 
1319
  }
1320
- } else {
1321
- // Set default data if a course is not existing in database
1322
- $user_course_info[$user_id] = array();
1323
- foreach ( $course_ids as $cid ) {
1324
- $user_course_info[$user_id][$cid] = array(
1325
- 'history_id' => 0,
1326
- 'start' => null,
1327
- 'end' => null,
1328
- 'status' => null
1329
- );
1330
  }
 
 
 
 
 
 
1331
  }
1332
  LP_Cache::set_course_info( $user_course_info );
1333
  return $user_course_info[$user_id];
1334
  }
1335
 
 
1336
  function learn_press_set_user_cookie_for_guest() {
1337
- if ( learn_press_is_course() ) {
1338
- $guest_key = 'wordpress_logged_in_' . md5( 'guest' );
1339
- if ( is_user_logged_in() ) {
1340
- if ( !empty( $_COOKIE[$guest_key] ) ) {
1341
- setcookie( 'wordpress_logged_in_' . md5( 'guest' ), md5( time() ), - 10000 );
1342
- }
1343
- } else {
1344
- if ( empty( $_COOKIE[$guest_key] ) ) {
1345
- setcookie( 'wordpress_logged_in_' . md5( 'guest' ), md5( time() ), time() + 3600 );
1346
- }
1347
- }
1348
  }
1349
- }
1350
-
1351
- add_action( 'wp', 'learn_press_set_user_cookie_for_guest' );
59
  * @return LP_User
60
  */
61
  function learn_press_get_current_user( $user_id = 0 ) {
62
+ return LP_User_Factory::get_user( $user_id );
63
  }
64
 
65
  /**
903
  if ( $width_user ) {
904
  $subdir .= '/' . get_current_user_id();
905
  }
906
+ $subdir = '/' . $subdir;
907
+ $upload_dir['path'] = str_replace( $upload_dir['subdir'], $subdir, $upload_dir['path'] );
908
+ $upload_dir['url'] = str_replace( $upload_dir['subdir'], $subdir, $upload_dir['url'] );
 
 
 
 
 
 
 
 
 
 
909
  $upload_dir['subdir'] = $subdir;
910
 
911
  // Point path/url to main site if we are in multisite
988
  $admin_url = admin_url();
989
  $pos = strpos( $redirect_to, $admin_url );
990
  if ( $pos === false ) {
991
+ $redirect = learn_press_get_page_link( 'profile' );
992
+ wp_redirect( $redirect );
993
+ exit();
 
 
 
994
  }
995
  }
996
 
1250
  */
1251
  function learn_press_get_user_courses_info( $user_id, $course_ids ) {
1252
  global $wpdb;
1253
+ settype( $course_ids, 'array' );
1254
 
1255
+ $format = array( $user_id );
1256
+ $format = array_merge( $format, $course_ids, array( 'lp_course' ) );
1257
+ $in = array_fill( 0, sizeof( $course_ids ), '%d' );
1258
+ $user_course_info = LP_Cache::get_course_info( false, array() );
1259
+ $query = $wpdb->prepare( "
1260
+ SELECT uc.*
1261
+ FROM {$wpdb->prefix}learnpress_user_items uc
1262
+ INNER JOIN {$wpdb->posts} o ON o.ID = uc.item_id
1263
+ WHERE uc.user_id = %d AND uc.status IS NOT NULL
1264
+ AND uc.item_id IN(" . join( ',', $in ) . ") AND uc.item_type = %s
1265
+ ORDER BY user_item_id DESC
1266
+ ", $format );//$this->id, $course_id, 'lp_course' );
1267
+ //$course_id = reset( $course_ids );
1268
+ if ( empty( $user_course_info[$user_id] ) ) {
1269
+ $user_course_info[$user_id] = array();
1270
+ }
1271
 
1272
+ if ( $result = $wpdb->get_results( $query ) ) {
1273
+ foreach ( $result as $row ) {
1274
+ $course_id = $row->item_id;
1275
+ if ( !empty( $user_course_info[$user_id][$course_id]['history_id'] ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1276
  continue;
1277
  }
1278
+ //$row = $result;
1279
+ $info = array(
1280
  'history_id' => 0,
1281
  'start' => null,
1282
  'end' => null,
1283
  'status' => null
1284
  );
1285
+ $course = learn_press_get_course( $course_id );
1286
+ $info['history_id'] = $row->user_item_id;
1287
+ $info['start'] = $row->start_time;
1288
+ $info['end'] = $row->end_time;
1289
+ $info['status'] = $row->status;
1290
+ $info['results'] = $course->evaluate_course_results( $user_id );
1291
+ $info['items'] = $course->get_items_params( $user_id );
1292
+ $user_course_info[$user_id][$course_id] = $info;
1293
  }
1294
+ }
1295
+ // Set default data if a course is not existing in database
1296
+ foreach ( $course_ids as $cid ) {
1297
+ if ( isset( $user_course_info[$user_id], $user_course_info[$user_id][$cid] ) ) {
1298
+ continue;
 
 
 
 
 
1299
  }
1300
+ $user_course_info[$user_id][$cid] = array(
1301
+ 'history_id' => 0,
1302
+ 'start' => null,
1303
+ 'end' => null,
1304
+ 'status' => null
1305
+ );
1306
  }
1307
  LP_Cache::set_course_info( $user_course_info );
1308
  return $user_course_info[$user_id];
1309
  }
1310
 
1311
+ add_action( 'init', 'learn_press_set_user_cookie_for_guest' );
1312
  function learn_press_set_user_cookie_for_guest() {
1313
+ if ( is_user_logged_in() ) {
1314
+ setcookie( 'wordpress_logged_in_' . md5( 'guest' ), md5( time() ), - 10000 );
1315
+ return;
 
 
 
 
 
 
 
 
1316
  }
1317
+ setcookie( 'wordpress_logged_in_' . md5( 'guest' ), md5( time() ), time() + 3600 );
1318
+ }
 
inc/widgets/course-attributes/course-attributes.php DELETED
@@ -1,31 +0,0 @@
1
- <?php
2
- if ( !class_exists( 'LP_Widget_Course_Attributes' ) ) {
3
- /**
4
- * Class LP_Widget_Course_Attribute
5
- */
6
- class LP_Widget_Course_Attributes extends LP_Widget {
7
- public function __construct() {
8
- $prefix = '';
9
- $this->options = array(
10
- array(
11
- 'name' => __( 'Title', 'learnpress' ),
12
- 'id' => "{$prefix}title",
13
- 'type' => 'text',
14
- 'std' => __( 'Course attributes', 'learnpress' )
15
- )
16
- );
17
- parent::__construct();
18
- add_filter( 'learn_press_widget_display_content-' . $this->id_base, 'learn_press_is_course' );
19
-
20
- }
21
-
22
- public function show() {
23
- $postId = get_the_ID();
24
- $attributes = learn_press_get_course_attributes( $postId );
25
- if ( !$attributes ) {
26
- return;
27
- }
28
- include learn_press_locate_widget_template( $this->get_slug() );
29
- }
30
- }
31
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/widgets/course-attributes/tmpl/default.php DELETED
@@ -1,23 +0,0 @@
1
- <?php
2
- $output = '<ul class="lp-course-attributes course-attributes">';
3
-
4
- $object_terms = array();
5
-
6
- foreach ( $attributes as $attribute ) {
7
- $object_terms[] = LP_COURSE_ATTRIBUTE . '-' . $attribute['name'];
8
- }
9
- $object_terms = ( wp_get_object_terms( $postId, $object_terms ) );
10
- foreach ( $attributes as $attribute ) {
11
- $taxonomy = get_term_by( 'slug', $attribute['name'], LP_COURSE_ATTRIBUTE );
12
- $output .= '<li><h4>' . $taxonomy->name . '</h4>';
13
- $output .= '<ul class="lp-course-attribute-values">';
14
- foreach ( $object_terms as $value ) {
15
- if ( $value->taxonomy != LP_COURSE_ATTRIBUTE . '-' . $attribute['name'] ) {
16
- continue;
17
- }
18
- $output .= '<li>' . $value->name . '</li>';
19
- }
20
- $output .= '</ul></li>';
21
- }
22
- $output .= '</ul>';
23
- echo $output;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/widgets/course-filters/course-filters.php DELETED
@@ -1,178 +0,0 @@
1
- <?php
2
- if ( !class_exists( 'LP_Widget_Course_Filters' ) ) {
3
- /**
4
- * Class LP_Widget_Course_Filters
5
- */
6
- class LP_Widget_Course_Filters extends LP_Widget {
7
- public function __construct() {
8
- $prefix = '';
9
- $this->options = array(
10
- 'title' => array(
11
- 'name' => __( 'Title', 'learnpress' ),
12
- 'id' => "{$prefix}title",
13
- 'type' => 'text',
14
- 'std' => __( 'Course filters', 'learnpress' )
15
- ),
16
- 'filter_by' => array(
17
- 'name' => __( 'Filter by', 'learnpress' ),
18
- 'id' => "{$prefix}filter_by",
19
- 'type' => 'checkbox_list',
20
- 'std' => '',
21
- 'options' => ''
22
- ),
23
- 'attribute_operation' => array(
24
- 'name' => __( 'Attribute operation', 'learnpress' ),
25
- 'id' => "{$prefix}attribute_operator",
26
- 'type' => 'select',
27
- 'std' => 'and',
28
- 'options' => array(
29
- 'and' => __( 'And', 'learnpress' ),
30
- 'or' => __( 'Or', 'learnpress' )
31
- )
32
- ),
33
- 'value_operation' => array(
34
- 'name' => __( 'Value operation', 'learnpress' ),
35
- 'id' => "{$prefix}value_operator",
36
- 'type' => 'select',
37
- 'std' => 'and',
38
- 'options' => array(
39
- 'and' => __( 'And', 'learnpress' ),
40
- 'or' => __( 'Or', 'learnpress' )
41
- )
42
- ),
43
- 'ajax_filter' => array(
44
- 'name' => __( 'Ajax filter', 'learnpress' ),
45
- 'id' => "{$prefix}ajax_filter",
46
- 'type' => 'checkbox',
47
- 'std' => '0',
48
- 'desc' => __( 'Use ajax to fetch content while filtering', 'learnpress' )
49
- ),
50
- 'button_filter' => array(
51
- 'name' => __( 'Button filter', 'learnpress' ),
52
- 'id' => "{$prefix}button_filter",
53
- 'type' => 'checkbox',
54
- 'std' => '0',
55
- 'desc' => __( 'If checked, user has to click this button to start filtering', 'learnpress' )
56
- )
57
- );
58
- parent::__construct();
59
- add_filter( 'learn_press_widget_display_content-' . $this->id_base, 'learn_press_is_courses' );
60
- if ( !is_admin() ) {
61
- LP_Assets::enqueue_script( 'course-filter', LP_Assets::url( 'js/frontend/course-filters.js' ) );
62
- }
63
- }
64
-
65
- public function normalize_options() {
66
- $this->options['filter_by']['options'] = $this->get_filter_by_options();
67
- return $this->options;
68
- }
69
-
70
- public function get_filter_by_options() {
71
- $options = array();
72
- if ( $attributes = learn_press_get_attributes() ) {
73
- foreach ( $attributes as $attribute ) {
74
- $options[LP_COURSE_ATTRIBUTE . '-' . $attribute->slug] = $attribute->name;
75
- }
76
- }
77
- return $options;
78
- }
79
-
80
- public static function get_main_tax_query() {
81
- global $wp_the_query;
82
-
83
- $tax_query = isset( $wp_the_query->tax_query, $wp_the_query->tax_query->queries ) ? $wp_the_query->tax_query->queries : array();
84
-
85
- return $tax_query;
86
- }
87
-
88
- public static function get_main_meta_query() {
89
- global $wp_the_query;
90
-
91
- $args = $wp_the_query->query_vars;
92
- $meta_query = isset( $args['meta_query'] ) ? $args['meta_query'] : array();
93
-
94
- return $meta_query;
95
- }
96
-
97
- protected function get_filtered_term_course_counts( $term_ids, $taxonomy, $query_type ) {
98
- global $wpdb;
99
-
100
- $tax_query = $this->get_main_tax_query();
101
- $meta_query = $this->get_main_meta_query();
102
- settype( $taxonomy, 'array' );
103
- if ( 'or' === $query_type ) {
104
- foreach ( $tax_query as $key => $query ) {
105
- if ( in_array( $query['taxonomy'], $taxonomy ) ) {//} === $query['taxonomy'] ) {
106
- unset( $tax_query[$key] );
107
- }
108
- }
109
- }
110
-
111
- $meta_query = new WP_Meta_Query( $meta_query );
112
- $tax_query = new WP_Tax_Query( $tax_query );
113
- $meta_query_sql = $meta_query->get_sql( 'post', $wpdb->posts, 'ID' );
114
- $tax_query_sql = $tax_query->get_sql( $wpdb->posts, 'ID' );
115
-
116
- $query = array();
117
- $query['select'] = "SELECT COUNT( DISTINCT {$wpdb->posts}.ID ) as term_count, terms.term_id as term_count_id";
118
- $query['from'] = "FROM {$wpdb->posts}";
119
- $query['join'] = "
120
- INNER JOIN {$wpdb->term_relationships} AS term_relationships ON {$wpdb->posts}.ID = term_relationships.object_id
121
- INNER JOIN {$wpdb->term_taxonomy} AS term_taxonomy USING( term_taxonomy_id )
122
- INNER JOIN {$wpdb->terms} AS terms USING( term_id )
123
- " . $tax_query_sql['join'] . $meta_query_sql['join'];
124
-
125
- $query['where'] = "
126
- WHERE {$wpdb->posts}.post_type IN ( 'lp_course' )
127
- AND {$wpdb->posts}.post_status = 'publish'
128
- " . $tax_query_sql['where'] . $meta_query_sql['where'] . "
129
- AND terms.term_id IN (" . implode( ',', array_map( 'absint', $term_ids ) ) . ")
130
- ";
131
-
132
- if ( $search = $this->get_main_search_query_sql() ) {
133
- $query['where'] .= ' AND ' . $search;
134
- }
135
- $query['group_by'] = "GROUP BY terms.term_id";
136
- $query = apply_filters( 'learn_press_get_filtered_term_course_counts_query', $query );
137
- $query = implode( ' ', $query );
138
- $results = $wpdb->get_results( $query );
139
-
140
- return wp_list_pluck( $results, 'term_count', 'term_count_id' );
141
- }
142
-
143
- /**
144
- * Based on WP_Query::parse_search
145
- */
146
- public static function get_main_search_query_sql() {
147
- global $wp_the_query, $wpdb;
148
-
149
- $args = $wp_the_query->query_vars;
150
- $search_terms = isset( $args['search_terms'] ) ? $args['search_terms'] : array();
151
- $sql = array();
152
-
153
- foreach ( $search_terms as $term ) {
154
- $include = '-' !== substr( $term, 0, 1 );
155
- if ( $include ) {
156
- $like_op = 'LIKE';
157
- $andor_op = 'OR';
158
- } else {
159
- $like_op = 'NOT LIKE';
160
- $andor_op = 'AND';
161
- $term = substr( $term, 1 );
162
- }
163
- $like = '%' . $wpdb->esc_like( $term ) . '%';
164
- $sql[] = $wpdb->prepare( "(($wpdb->posts.post_title $like_op %s) $andor_op ($wpdb->posts.post_excerpt $like_op %s) $andor_op ($wpdb->posts.post_content $like_op %s))", $like, $like, $like );
165
- }
166
-
167
- if ( !empty( $sql ) && !is_user_logged_in() ) {
168
- $sql[] = "($wpdb->posts.post_password = '')";
169
- }
170
-
171
- return implode( ' AND ', $sql );
172
- }
173
-
174
- public function show() {
175
- include learn_press_locate_widget_template( $this->get_slug() );
176
- }
177
- }
178
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/widgets/course-filters/tmpl/default.php DELETED
@@ -1,90 +0,0 @@
1
- <?php
2
- $attributes = learn_press_get_attributes();
3
-
4
- $in = !empty( $this->instance['filter_by'] ) ? $this->instance['filter_by'] : false;
5
- if ( !$attributes ) {
6
- return;
7
- }
8
- global $lp_tax_query;
9
-
10
- $attribute_ids = wp_list_pluck( $attributes, 'term_id' );
11
- $attribute_values = learn_press_get_attribute_terms( $attribute_ids );
12
- $taxonomies = wp_list_pluck( $attributes, 'slug' );
13
- foreach ( $taxonomies as $k => $v ) {
14
- $taxonomies[$k] = LP_COURSE_ATTRIBUTE . '-' . $v;
15
- }
16
- $term_counts = $this->get_filtered_term_course_counts( wp_list_pluck( $attribute_values, 'term_id' ), $taxonomies, $this->instance['value_operator'] );
17
- $has_filtered = false;
18
- ?>
19
- <ul class="lp-course-attributes course-filters" data-ajax="<?php echo !empty( $this->instance['ajax_filter'] ) ? 'yes' : 'no'; ?>">
20
- <?php foreach ( $attributes as $attribute ) {
21
- if ( !( false === $in || in_array( LP_COURSE_ATTRIBUTE . '-' . $attribute->slug, $in ) ) ) {
22
- continue;
23
- }
24
- $values = learn_press_get_attribute_terms( $attribute->term_id );
25
- if ( !$values ) {
26
- continue;
27
- }
28
- $has_attribute_values = false;
29
- ob_start();
30
- ?>
31
- <li data-attribute="filter_<?php echo $attribute->slug; ?>">
32
- <h4 class="lp-course-attribute-name"><?php echo $attribute->name; ?></h4>
33
- <?php
34
- //$term_counts = $this->get_filtered_term_course_counts( wp_list_pluck( $values, 'term_id' ), LP_COURSE_ATTRIBUTE . '-' . $attribute->slug, $this->instance['value_operator'] );
35
- $tax = false;
36
- if ( $lp_tax_query )
37
- foreach ( $lp_tax_query as $k => $_tax ) {
38
- $tax = false;
39
- if ( $k === 'relation' ) {
40
- continue;
41
- }
42
- if ( $_tax['taxonomy'] == LP_COURSE_ATTRIBUTE . '-' . $attribute->slug ) {
43
- $tax = $_tax;
44
- break;
45
- }
46
- }
47
- ?>
48
- <ul class="lp-course-attribute-values">
49
- <?php foreach ( $values as $value ) {
50
- if ( !$value->count ) {
51
- continue;
52
- }
53
- $count = isset( $term_counts[$value->term_id] ) ? $term_counts[$value->term_id] : 0;
54
- if ( !$count ) {
55
- continue;
56
- }
57
- $classes = array( 'lp-course-attribute-value' );
58
- if ( $tax && in_array( $value->slug, $tax['terms'] ) ) {
59
- $classes[] = "active";
60
- $has_filtered = true;
61
- }
62
- $has_attribute_values = true;
63
- ?>
64
- <li class="<?php echo join( ' ', $classes ); ?>" data-value="<?php echo $value->slug; ?>">
65
- <a href=""><?php echo $value->name; ?></a>
66
- <span>(<?php echo $count; ?>)</span>
67
- </li>
68
- <?php } ?>
69
- </ul>
70
-
71
- </li>
72
- <?php
73
- $output = ob_get_clean();
74
- if ( $has_attribute_values ) {
75
- echo $output;
76
- }
77
- ?>
78
- <?php } ?>
79
- </ul>
80
- <input type="hidden" name="attribute_operation" value="<?php echo empty( $this->instance['attribute_operation'] ) || strtolower( $this->instance['attribute_operation'] ) == 'and' ? 'and' : 'or'; ?>">
81
- <input type="hidden" name="value_operation" value="<?php echo empty( $this->instance['value_operation'] ) || strtolower( $this->instance['value_operation'] ) == 'and' ? 'and' : 'or'; ?>">
82
- <?php if ( !empty( $this->instance['button_filter'] ) ) { ?>
83
- <button type="button" class="lp-button-filter" disabled="disabled"><?php _e( 'Filter', 'learnpress' ); ?></button>
84
- <?php } ?>
85
- <button type="button" class="lp-button-reset-filter" <?php echo $has_filtered ? '' : 'disabled="disabled"'; ?>"><?php _e( 'Reset', 'learnpress' ); ?></button>
86
- <script type="text/javascript">
87
- jQuery(document).ready(function ($) {
88
- $('#<?php echo $this->args['widget_id'];?>').courseFilters(<?php echo wp_json_encode( $this->instance );?>);
89
- });
90
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/widgets/featured-courses/featured-course-widget.php ADDED
@@ -0,0 +1,197 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Widget to display featured courses
4
+ */
5
+
6
+ defined( 'ABSPATH' ) || exit();
7
+
8
+ include LP_PLUGIN_PATH . 'inc/widgets/lp-widget-util.php';
9
+
10
+ /**
11
+ * @class LP_Featured_Course_Widget
12
+ * Widget to display featured courses
13
+ */
14
+ class LP_Featured_Course_Widget extends WP_Widget {
15
+ /**
16
+ * @var null|string widget location
17
+ */
18
+ private $widget_path = null;
19
+
20
+ /**
21
+ * @var string $template_dir template folder location
22
+ */
23
+ private $template_dir = null;
24
+
25
+ /**
26
+ * @var tring $template_file_name template filename
27
+ */
28
+ private $template_file_name = null;
29
+
30
+ /**
31
+ * @var [array] $templates null
32
+ * template list
33
+ */
34
+ private $templates = null;
35
+
36
+ /**
37
+ * @var array|null default instance
38
+ */
39
+ private $default_attributes = null;
40
+
41
+ /**
42
+ * Sets up the widgets name etc
43
+ */
44
+ public function __construct() {
45
+ $widget_ops = array(
46
+ 'classname' => 'featured-courses-widget',
47
+ 'description' => 'Display featured courses',
48
+ );
49
+
50
+ $this->widget_path = LP_PLUGIN_PATH . '/inc/widgets/featured-courses';
51
+
52
+ $this->template_dir = $this->widget_path . '/templates/';
53
+
54
+ $this->template_file_name = 'default.php';
55
+
56
+ $this->templates = scandir( $this->template_dir );
57
+ $this->templates = array_filter( $this->templates, 'lp_php_file_filter' );
58
+ array_walk( $this->templates, 'lp_trim_file_extension' );
59
+
60
+ $this->default_attributes = array(
61
+ 'show_teacher' => 'true',
62
+ 'show_lesson' => 'true',
63
+ 'show_thumbnail' => 'true',
64
+ 'limit' => '1',
65
+ 'title' => __( 'Featured courses', 'learnpress' ),
66
+ 'show_desc' => '',
67
+ 'desc_length' => '10',
68
+ 'show_enrolled_students' => 'true',
69
+ 'show_price' => '',
70
+ 'template' => 'default',
71
+ 'css_class' => '',
72
+ 'bottom_link' => '',
73
+ 'bottom_link_text' => ''
74
+ );
75
+
76
+ parent::__construct( 'featured-courses-widget', __( 'LearnPress - Featured Courses', 'learnpress' ), $widget_ops );
77
+ }
78
+
79
+ /**
80
+ * get template file name from options
81
+ *
82
+ * @param WP_Widget $instance widget instance
83
+ *
84
+ * @return string Template filename
85
+ */
86
+ private function get_template_file( &$instance ) {
87
+ $template_file_name = $instance['template'] . '.php';
88
+ if ( !file_exists( $this->template_dir . $template_file_name ) ) {
89
+ $template_file_name = 'default.php';
90
+ }
91
+ $this->template_file_name = $template_file_name;
92
+
93
+ return $template_file_name;
94
+ }
95
+
96
+ /**
97
+ * render widget template
98
+ *
99
+ * @param array $courses array of course
100
+ * @param array widget args
101
+ * @param WP_Widget $instance widget instance
102
+ */
103
+ private function render( $courses, $args, $a ) {
104
+ //include template file
105
+ include $this->template_dir . $this->template_file_name;
106
+ }
107
+
108
+ /**
109
+ * get learn press course from wordpress post object
110
+ *
111
+ * @param object -reference $post wordpress post object
112
+ *
113
+ * @return LP_Course course
114
+ */
115
+ public function get_lp_course( $post ) {
116
+ $id = $post->ID;
117
+ $course = null;
118
+ if ( !empty( $id ) ) {
119
+ $course = new LP_Course( $id );
120
+ }
121
+
122
+ return $course;
123
+ }
124
+
125
+ /**
126
+ * get courses
127
+ * @return array|null array of course
128
+ */
129
+ private function get_courses( $instance ) {
130
+ global $wpdb;
131
+ $posts = $wpdb->get_results(
132
+ $wpdb->prepare( "
133
+ SELECT DISTINCT *
134
+ FROM {$wpdb->posts} p
135
+ LEFT JOIN {$wpdb->postmeta} as pmeta ON p.ID=pmeta.post_id AND pmeta.meta_key = %s
136
+ WHERE p.post_type = %s
137
+ AND p.post_status = %s
138
+ AND meta_value = %s
139
+ ORDER BY p.post_date
140
+ LIMIT %d
141
+ ", '_lp_featured', LP_COURSE_CPT, 'publish', 'yes', (int) $instance['limit']
142
+ )
143
+ );
144
+ $courses = array_map( array( $this, 'get_lp_course' ), $posts );
145
+ return $courses;
146
+ }
147
+
148
+
149
+ /**
150
+ * Outputs the content of the widget
151
+ *
152
+ * @param array $args
153
+ * @param array $instance
154
+ */
155
+ public function widget( $args, $instance ) {
156
+ $instance = wp_parse_args( $instance, $this->default_attributes );
157
+ $this->get_template_file( $instance );
158
+ $courses = $this->get_courses( $instance );
159
+
160
+ echo $args['before_widget'];
161
+ $this->render( $courses, $args, $instance );
162
+ echo $args['after_widget'];
163
+ }
164
+
165
+ /**
166
+ * Outputs the options form on admin
167
+ *
168
+ * @param array $instance The widget options
169
+ *
170
+ * @return void
171
+ */
172
+ public function form( $instance ) {
173
+ $instance = wp_parse_args( ( array ) $instance, $this->default_attributes );
174
+ require $this->widget_path . '/form.php';
175
+ }
176
+
177
+ /**
178
+ * Processing widget options on save
179
+ *
180
+ * @param array $new_instance The new options
181
+ * @param array $old_instance The previous options
182
+ *
183
+ * @return array widget instance to save to db
184
+ */
185
+ public function update( $new_instance, $old_instance ) {
186
+ $instance = wp_parse_args( $new_instance, $this->default_attributes );
187
+
188
+ return $instance;
189
+ }
190
+ }
191
+
192
+ // register widget
193
+ function register_featured_course_widget() {
194
+ register_widget( 'LP_Featured_Course_Widget' );
195
+ }
196
+
197
+ add_action( 'lp_widgets_init', 'register_featured_course_widget' );
inc/widgets/featured-courses/featured-courses.php DELETED
@@ -1,139 +0,0 @@
1
- <?php
2
- /**
3
- * Widget to display featured courses
4
- */
5
-
6
- if ( ! class_exists( 'LP_Widget_Featured_Courses' ) ) {
7
-
8
- /**
9
- * Class LP_Widget_Featured_Courses
10
- */
11
- class LP_Widget_Featured_Courses extends LP_Widget {
12
-
13
- private $courses = array();
14
-
15
- public function __construct () {
16
- $prefix = '';
17
- $this->options = array(
18
- 'title' => array(
19
- 'name' => __( 'Title', 'learnpress' ),
20
- 'id' => "{$prefix}title",
21
- 'type' => 'text',
22
- 'std' => __( 'Featured Courses', 'learnpress' )
23
- ),
24
- 'show_teacher' => array(
25
- 'name' => __( 'Show teacher', 'learpnress' ),
26
- 'id' => "{$prefix}show_teacher",
27
- 'type' => 'checkbox',
28
- 'std' => 1
29
- ),
30
- 'show_lesson' => array(
31
- 'name' => __( 'Show lesson', 'learpnress' ),
32
- 'id' => "{$prefix}show_lesson",
33
- 'type' => 'checkbox',
34
- 'std' => 1
35
- ),
36
- 'show_thumbnail' => array(
37
- 'name' => __( 'Show Thumbnail', 'learpnress' ),
38
- 'id' => "{$prefix}show_thumbnail",
39
- 'type' => 'checkbox',
40
- 'std' => 1
41
- ),
42
- 'limit' => array(
43
- 'name' => __( 'Limit', 'learpnress' ),
44
- 'id' => "{$prefix}limit",
45
- 'type' => 'number',
46
- 'min' => 1,
47
- 'std' => 4
48
- ),
49
- 'desc_length' => array(
50
- 'name' => __( 'Description Length', 'learpnress' ),
51
- 'id' => "{$prefix}desc_length",
52
- 'type' => 'number',
53
- 'min' => 0,
54
- 'std' => 10
55
- ),
56
- 'show_enrolled_students' => array(
57
- 'name' => __( 'Show Enrolled Students', 'learpnress' ),
58
- 'id' => "{$prefix}show_enrolled_students",
59
- 'type' => 'checkbox',
60
- 'std' => 1
61
- ),
62
- 'show_price' => array(
63
- 'name' => __( 'Show Price', 'learpnress' ),
64
- 'id' => "{$prefix}show_price",
65
- 'type' => 'checkbox',
66
- 'std' => 1
67
- ),
68
- 'css_class' => array(
69
- 'name' => __( 'CSS Class', 'learpnress' ),
70
- 'id' => "{$prefix}css_class",
71
- 'type' => 'text',
72
- 'std' => ''
73
- ),
74
- 'bottom_link_text' => array(
75
- 'name' => __( 'Go to Courses', 'learpnress' ),
76
- 'id' => "{$prefix}bottom_link_text",
77
- 'type' => 'text',
78
- 'std' => 'LP Courses'
79
- )
80
- );
81
- parent::__construct();
82
- add_filter( 'learn_press_widget_display_content-' . $this->id_base, 'learn_press_is_course' );
83
-
84
- }
85
-
86
- /**
87
- * get learn press course from wordpress post object
88
- *
89
- * @param object -reference $post wordpress post object
90
- *
91
- * @return LP_Course course
92
- */
93
- public function get_lp_course( $post ) {
94
- $id = $post->ID;
95
- $course = null;
96
- if ( !empty( $id ) ) {
97
- $course = new LP_Course( $id );
98
- }
99
-
100
- return $course;
101
- }
102
-
103
- /**
104
- * get courses
105
- * @return array|null array of course
106
- */
107
- private function get_courses () {
108
-
109
- if ( empty( $this->instance ) ) {
110
- return array();
111
- }
112
-
113
- global $wpdb;
114
-
115
- $posts = $wpdb->get_results(
116
- $wpdb->prepare( "
117
- SELECT DISTINCT *
118
- FROM {$wpdb->posts} p
119
- LEFT JOIN {$wpdb->postmeta} as pmeta ON p.ID=pmeta.post_id AND pmeta.meta_key = %s
120
- WHERE p.post_type = %s
121
- AND p.post_status = %s
122
- AND meta_value = %s
123
- ORDER BY p.post_date
124
- LIMIT %d
125
- ", '_lp_featured', LP_COURSE_CPT, 'publish', 'yes', (int)$this->instance['limit']
126
- )
127
- );
128
- $courses = array_map( array( $this, 'get_lp_course' ), $posts );
129
-
130
- return $courses;
131
- }
132
-
133
- public function show () {
134
- $this->courses = $this->get_courses();
135
- include learn_press_locate_widget_template( $this->get_slug() );
136
- }
137
-
138
- }
139
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/widgets/featured-courses/form.php ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="upw-tabs">
2
+ <a class="upw-tab-item active" data-toggle="upw-tab-general">General</a>
3
+ <a class="upw-tab-item" data-toggle="upw-tab-display">Display</a>
4
+ <a class="upw-tab-item" data-toggle="upw-tab-actions">Actions</a>
5
+ </div>
6
+ <div class="upw-tab upw-tab-general upw-show">
7
+ <p>
8
+ <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e('Title:' , 'learnpress' ); ?></label>
9
+ <input
10
+ class="widefat"
11
+ id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"
12
+ name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>"
13
+ type="text"
14
+ value="<?php echo esc_attr( $instance['title'] ); ?>">
15
+ </p>
16
+ <p>
17
+ <label for="<?php echo esc_attr( $this->get_field_id( 'limit' ) ); ?>"><?php _e( 'Number of posts:', 'learnpress' ) ; ?></label>
18
+ <input
19
+ class="widefat"
20
+ id="<?php echo esc_attr( $this->get_field_id( 'limit' ) ); ?>"
21
+ name="<?php echo esc_attr( $this->get_field_name( 'limit' ) ); ?>"
22
+ type="number"
23
+ value="<?php echo esc_attr( $instance['limit'] ); ?>">
24
+ </p>
25
+ <p>
26
+ <label for="<?php echo esc_attr( $this->get_field_id( 'css_class' ) ); ?>"><?php _e( 'CSS class:', 'learnpress' ) ; ?></label>
27
+ <input
28
+ class="widefat"
29
+ id="<?php echo esc_attr( $this->get_field_id( 'css_class' ) ); ?>"
30
+ name="<?php echo esc_attr( $this->get_field_name( 'css_class' ) ); ?>"
31
+ type="text"
32
+ value="<?php echo esc_attr( $instance['css_class'] ); ?>">
33
+ </p>
34
+ <p>
35
+ <label for="<?php echo esc_attr( $this->get_field_id( 'template' ) ); ?>"><?php _e( 'Choose template: ', 'learnpress' ); ?>&nbsp;</label>
36
+ <select id="<?php echo esc_attr( $this->get_field_id( 'template' ) ); ?>"
37
+ name="<?php echo esc_attr( $this->get_field_name( 'template' ) ); ?>" >
38
+ <?php foreach ($this->templates as $template): ?>
39
+ <option
40
+ <?php if ($template == $instance['template']) echo 'selected'; ?>
41
+ value="<?php echo $template ?>" >
42
+ <?php echo $template ?>
43
+ </option>
44
+ <?php endforeach; ?>
45
+ </select>
46
+ </p>
47
+ </div>
48
+ <div class="upw-tab upw-tab-display upw-hide">
49
+ <p>
50
+ <label for="<?php echo esc_attr( $this->get_field_id( 'show_desc' ) ); ?>"><?php _e( 'Show description: ' , 'learnpress' ); ?>&nbsp;</label>
51
+ <input type="checkbox"
52
+ <?php if($instance['show_desc']) echo 'checked' ?>
53
+ class="widefat"
54
+ id="<?php echo esc_attr( $this->get_field_id( 'show_desc' ) ); ?>"
55
+ name="<?php echo esc_attr( $this->get_field_name( 'show_desc' ) ); ?>" >
56
+ </p>
57
+ <p>
58
+ <label for="<?php echo esc_attr( $this->get_field_id( 'desc_length' ) ); ?>"><?php _e( 'Description max length:' , 'learnpress' ); ?></label>
59
+ <input
60
+ class="widefat"
61
+ id="<?php echo esc_attr( $this->get_field_id( 'desc_length' ) ); ?>"
62
+ name="<?php echo esc_attr( $this->get_field_name( 'desc_length' ) ); ?>"
63
+ type="number"
64
+ value="<?php echo esc_attr( $instance['desc_length'] ); ?>">
65
+ </p>
66
+ <p>
67
+ <label for="<?php echo esc_attr( $this->get_field_id( 'show_thumbnail' ) ); ?>"><?php _e( 'Show thumbnail: ' , 'learnpress'); ?>&nbsp;</label>
68
+ <input type="checkbox"
69
+ <?php if($instance['show_thumbnail']) echo 'checked' ?>
70
+ <?php checked( $instance['show_thumbnail'] ) ?>
71
+ class="widefat"
72
+ id="<?php echo esc_attr( $this->get_field_id( 'show_thumbnail' ) ); ?>"
73
+ name="<?php echo esc_attr( $this->get_field_name( 'show_thumbnail' ) ); ?>" >
74
+ </p>
75
+ <p>
76
+ <label for="<?php echo esc_attr( $this->get_field_id( 'show_teacher' ) ); ?>"><?php _e( 'Show Teacher name: ', 'learnpress' ); ?>&nbsp;</label>
77
+ <input type="checkbox"
78
+ <?php if($instance['show_teacher']) echo 'checked' ?>
79
+ class="widefat"
80
+ id="<?php echo esc_attr( $this->get_field_id( 'show_teacher' ) ); ?>"
81
+ name="<?php echo esc_attr( $this->get_field_name( 'show_teacher' ) ); ?>" >
82
+ </p>
83
+ <p>
84
+ <label for="<?php echo esc_attr( $this->get_field_id( 'show_lesson' ) ); ?>"><?php _e( 'Show number of lessons: ', 'learnpress' ); ?>&nbsp;</label>
85
+ <input type="checkbox"
86
+ <?php if($instance['show_lesson']) echo 'checked' ?>
87
+ class="widefat"
88
+ id="<?php echo esc_attr( $this->get_field_id( 'show_lesson' ) ); ?>"
89
+ name="<?php echo esc_attr( $this->get_field_name( 'show_lesson' ) ); ?>" >
90
+ </p>
91
+ <p>
92
+ <label for="<?php echo esc_attr( $this->get_field_id( 'show_enrolled_students' ) ); ?>"><?php _e( 'Show enrolled number: ' , 'learnpress' ); ?>&nbsp;</label>
93
+ <input type="checkbox"
94
+ <?php if ($instance['show_enrolled_students']) echo 'checked' ?>
95
+ class="widefat"
96
+ id="<?php echo esc_attr( $this->get_field_id( 'show_enrolled_students' ) ); ?>"
97
+ name="<?php echo esc_attr( $this->get_field_name( 'show_enrolled_students' ) ); ?>" >
98
+ </p>
99
+ <p>
100
+ <label for="<?php echo esc_attr( $this->get_field_id( 'show_price' ) ); ?>"><?php _e( 'Show price: ', 'learnpress' ); ?>&nbsp;</label>
101
+ <input type="checkbox"
102
+ <?php if ($instance['show_price']) echo 'checked' ?>
103
+ class="widefat"
104
+ id="<?php echo esc_attr( $this->get_field_id( 'show_price' ) ); ?>"
105
+ name="<?php echo esc_attr( $this->get_field_name( 'show_price' ) ); ?>" >
106
+ </p>
107
+ </div>
108
+ <div class="upw-tab upw-tab-actions upw-hide">
109
+ <p>
110
+ <label for="<?php echo esc_attr( $this->get_field_id( 'bottom_link' ) ); ?>"><?php _e( 'Bottom link: ' ,'learnpress'); ?>&nbsp;</label>
111
+ <select
112
+ class="widefat"
113
+ id="<?php echo esc_attr( $this->get_field_id( 'bottom_link' ) ); ?>"
114
+ name="<?php echo esc_attr( $this->get_field_name( 'bottom_link' ) ); ?>">
115
+ <option
116
+ value=""><?php _e('hide bottom link', 'learnpress') ?></option>
117
+ <option
118
+ <?php if($instance['bottom_link'] == 'all_course'){ echo 'selected'; } ?>
119
+ value="all_course"><?php _e('all courses', 'learnpress'); ?>
120
+ </option>
121
+ </select>
122
+ </p>
123
+ <p>
124
+ <label for="<?php echo esc_attr( $this->get_field_id( 'bottom_link_text' ) ); ?>"><?php _e('Bottom link text: ' , 'learnpress'); ?>&nbsp;</label>
125
+ <input
126
+ type="text"
127
+ class="widefat"
128
+ id="<?php echo esc_attr( $this->get_field_id( 'bottom_link_text' ) ); ?>"
129
+ name="<?php echo esc_attr( $this->get_field_name( 'bottom_link_text' ) ); ?>"
130
+ value="<?php echo $instance['bottom_link_text'] ?>" >
131
+ </p>
132
+ </div>
inc/widgets/featured-courses/index.php CHANGED
@@ -1,7 +1 @@
1
- <?php
2
- /**
3
- * Created by PhpStorm.
4
- * User: MinhMinh
5
- * Date: 2/24/2017
6
- * Time: 1:41 PM
7
- */
1
+ <?php // Silence is golden.
 
 
 
 
 
 
inc/widgets/featured-courses/templates/default.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="<?php echo 'archive-course-widget-outer ' . $a['template'] . ' ' . $a["css_class"] ?>">
2
+ <?php if ( !empty( $a['title'] ) ) {
3
+ echo $args['before_title'] . apply_filters( 'widget_title', $a['title'] ) . $args['after_title'];
4
+ }
5
+ ?>
6
+ <div class="widget-body">
7
+ <?php foreach ( $courses as $course ): ?>
8
+ <div class="course-entry">
9
+ <?php if ( $a['show_thumbnail'] ): ?>
10
+ <div class="course-cover">
11
+ <a href="<?php echo get_the_permalink( $course->id ); ?>">
12
+ <?php echo get_the_post_thumbnail( $course->id, 'medium' ); ?>
13
+ </a>
14
+ </div>
15
+ <?php endif; ?>
16
+ <div class="course-detail">
17
+ <a href="<?php echo get_the_permalink( $course->id ) ?>">
18
+ <h3 class="course-title">
19
+ <?php echo $course->get_course_data()->post_title; ?>
20
+ </h3>
21
+ </a>
22
+ <?php if ( $a['show_desc'] ): ?>
23
+ <div class="course-description"><?php
24
+ $content_length = intval( $a['desc_length'] );
25
+ $the_content = $course->get_course_data()->post_content;
26
+ $the_content = wp_trim_words( $the_content, $content_length, __( '...', 'learnpress' ) );
27
+ echo $the_content;
28
+ ?></div>
29
+ <?php endif; ?>
30
+ <div class="course-meta-data">
31
+ <?php if ( $a['show_price'] ): ?>
32
+ <div class="course-meta-field">
33
+ <?php
34
+ echo $course->get_price_html();
35
+ ?>
36
+ </div>
37
+ <?php endif; ?>
38
+ <?php if ( $a['show_enrolled_students'] ): ?>
39
+ <div class="course-student-number course-meta-field">
40
+ <?php
41
+ $students = $course->get_users_enrolled();
42
+ echo intval( $students ) > 1 ? sprintf( __( '%d students', 'learnpress' ), $students ) : sprintf( __( '%d student', 'learnpress' ), $students );
43
+ ?>
44
+ </div>
45
+ <?php endif; ?>
46
+ <?php if ( $a['show_lesson'] ): ?>
47
+ <div class="course-lesson-number course-meta-field">
48
+ <?php
49
+ $lessons = sizeof( $course->get_lessons() );
50
+ echo intval( $lessons ) > 1 ? sprintf( __( '%d lessons', 'learnpress' ), $lessons ) : sprintf( __( '%d lesson', 'learnpress' ), $lessons );
51
+ ?>
52
+ </div>
53
+ <?php endif; ?>
54
+ <?php if ( $a['show_teacher'] ): ?>
55
+ <div class="course-meta-field">
56
+ <?php echo $course->get_instructor_html(); ?>
57
+ </div>
58
+ <?php endif; ?>
59
+ </div>
60
+ </div>
61
+ </div>
62
+ <?php endforeach; ?>
63
+ </div>
64
+ <div class="widget-footer">
65
+ <?php if ( $a['bottom_link'] == 'all_course' ):
66
+ $page_id = get_option( 'learn_press_courses_page_id' );
67
+ $link = get_page_link( $page_id );
68
+ $title = get_the_title( $page_id );
69
+ ?>
70
+ <a class="pull-right" href="<?php echo $link ?>">
71
+ <?php
72
+ echo( !empty( $a['bottom_link_text'] ) ? $a['bottom_link_text'] : $title );
73
+ ?>
74
+ </a>
75
+ <?php endif; ?>
76
+ </div>
77
+ </div>
78
+ <div class="clearfix"></div>
inc/widgets/featured-courses/templates/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden.
inc/widgets/featured-courses/tmpl/default.php DELETED
@@ -1,75 +0,0 @@
1
- <?php
2
- $instance = $this->instance;
3
- ?>
4
- <div class="<?php echo 'archive-course-widget-outer ' . esc_attr($instance["css_class"]); ?>">
5
- <div class="widget-body">
6
- <?php foreach ( $this->courses as $course ): ?>
7
- <div class="course-entry">
8
- <?php if ( ! empty( $instance['show_thumbnail'] ) ): ?>
9
- <div class="course-cover">
10
- <a href="<?php echo get_the_permalink( $course->id ); ?>">
11
- <?php echo get_the_post_thumbnail( $course->id, 'medium' ); ?>
12
- </a>
13
- </div>
14
- <?php endif; ?>
15
- <div class="course-detail">
16
- <a href="<?php echo get_the_permalink( $course->id ) ?>">
17
- <h3 class="course-title">
18
- <?php echo $course->get_course_data()->post_title; ?>
19
- </h3>
20
- </a>
21
- <?php if ( ! empty( $instance['desc_length'] ) && intval( $instance['desc_length'] ) > 0 ): ?>
22
- <div class="course-description"><?php
23
- $content_length = intval( $instance['desc_length'] );
24
- $the_content = $course->get_course_data()->post_content;
25
- $the_content = wp_trim_words( $the_content, $content_length, __( '...', 'learnpress' ) );
26
- echo $the_content;
27
- ?></div>
28
- <?php endif; ?>
29
- <div class="course-meta-data">
30
- <?php if ( ! empty( $instance['show_price'] ) ): ?>
31
- <div class="course-meta-field">
32
- <?php
33
- echo $course->get_price_html();
34
- ?>
35
- </div>
36
- <?php endif; ?>
37
- <?php if ( ! empty( $instance['show_enrolled_students'] ) ): ?>
38
- <div class="course-student-number course-meta-field">
39
- <?php
40
- $students = $course->get_users_enrolled();
41
- echo intval( $students ) > 1 ? sprintf( __( '%d students', 'learnpress' ), $students ) : sprintf( __( '%d student', 'learnpress' ), $students );
42
- ?>
43
- </div>
44
- <?php endif; ?>
45
- <?php if ( ! empty( $instance['show_lesson'] ) ): ?>
46
- <div class="course-lesson-number course-meta-field">
47
- <?php
48
- $lessons = sizeof( $course->get_lessons() );
49
- echo intval( $lessons ) > 1 ? sprintf( __( '%d lessons', 'learnpress' ), $lessons ) : sprintf( __( '%d lesson', 'learnpress' ), $lessons );
50
- ?>
51
- </div>
52
- <?php endif; ?>
53
- <?php if ( ! empty( $instance['show_teacher'] ) ): ?>
54
- <div class="course-meta-field">
55
- <?php echo $course->get_instructor_html(); ?>
56
- </div>
57
- <?php endif; ?>
58
- </div>
59
- </div>
60
- </div>
61
- <?php endforeach; ?>
62
- </div>
63
- <div class="widget-footer">
64
- <?php if ( !empty($instance['bottom_link_text'])):
65
- $page_id = get_option( 'learn_press_courses_page_id' );
66
- $link = get_page_link( $page_id );
67
- $title = get_the_title( $page_id );
68
- ?>
69
- <a class="pull-right" href="<?php echo $link ?>">
70
- <?php echo wp_kses_post($instance['bottom_link_text']) ; ?>
71
- </a>
72
- <?php endif; ?>
73
- </div>
74
- </div>
75
- <div class="clearfix"></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/widgets/featured-courses/tmpl/index.php DELETED
@@ -1,7 +0,0 @@
1
- <?php
2
- /**
3
- * Created by PhpStorm.
4
- * User: MinhMinh
5
- * Date: 2/23/2017
6
- * Time: 2:51 PM
7
- */
 
 
 
 
 
 
 
inc/widgets/lp-widget-util.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * define common functions for widgets
4
+ */
5
+
6
+ defined( 'ABSPATH' ) || exit();
7
+
8
+ if ( !defined( 'LP_WIDGETS_DIR' ) ) {
9
+ define( 'LP_WIDGETS_DIR', LP_PLUGIN_PATH . "/inc/widgets" );
10
+ }
11
+
12
+ if ( !function_exists( 'lp_php_file_filter' ) ) {
13
+ function lp_php_file_filter( $file_name ) {
14
+ $file_ext = pathinfo( $file_name, PATHINFO_EXTENSION );
15
+ return ( $file_ext == "php" );
16
+ }
17
+ }
18
+
19
+ if ( !function_exists( 'lp_trim_file_extension' ) ) {
20
+ function lp_trim_file_extension( &$file_name ) {
21
+ $file_name = pathinfo( $file_name, PATHINFO_FILENAME );
22
+ return 1;
23
+ }
24
+ }
25
+
26
+ if ( !function_exists( 'lp_is_paid_course' ) ) {
27
+ function lp_is_paid_course( $course_id ) {
28
+ $meta_value = get_post_meta( $course_id, '_lp_payment', true );
29
+ $bool_value = filter_var( $meta_value, FILTER_VALIDATE_BOOLEAN );
30
+ return $bool_value;
31
+ }
32
+ }
inc/widgets/popular-courses/form.php ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="upw-tabs">
2
+ <a class="upw-tab-item active" data-toggle="upw-tab-general">General</a>
3
+ <a class="upw-tab-item" data-toggle="upw-tab-display">Display</a>
4
+ <a class="upw-tab-item" data-toggle="upw-tab-actions">Actions</a>
5
+ </div>
6
+ <div class="upw-tab upw-tab-general upw-show">
7
+ <p>
8
+ <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e('Title:' , 'learnpress' ); ?></label>
9
+ <input
10
+ class="widefat"
11
+ id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"
12
+ name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>"
13
+ type="text"
14
+ value="<?php echo esc_attr( $instance['title'] ); ?>">
15
+ </p>
16
+ <p>
17
+ <label for="<?php echo esc_attr( $this->get_field_id( 'limit' ) ); ?>"><?php _e( 'Number of posts:', 'learnpress' ) ; ?></label>
18
+ <input
19
+ class="widefat"
20
+ id="<?php echo esc_attr( $this->get_field_id( 'limit' ) ); ?>"
21
+ name="<?php echo esc_attr( $this->get_field_name( 'limit' ) ); ?>"
22
+ type="number"
23
+ value="<?php echo esc_attr( $instance['limit'] ); ?>">
24
+ </p>
25
+ <p>
26
+ <label for="<?php echo esc_attr( $this->get_field_id( 'css_class' ) ); ?>"><?php _e( 'CSS class:', 'learnpress' ) ; ?></label>
27
+ <input
28
+ class="widefat"
29
+ id="<?php echo esc_attr( $this->get_field_id( 'css_class' ) ); ?>"
30
+ name="<?php echo esc_attr( $this->get_field_name( 'css_class' ) ); ?>"
31
+ type="text"
32
+ value="<?php echo esc_attr( $instance['css_class'] ); ?>">
33
+ </p>
34
+ <p>
35
+ <label for="<?php echo esc_attr( $this->get_field_id( 'template' ) ); ?>"><?php _e( 'Choose template: ', 'learnpress' ); ?>&nbsp;</label>
36
+ <select id="<?php echo esc_attr( $this->get_field_id( 'template' ) ); ?>"
37
+ name="<?php echo esc_attr( $this->get_field_name( 'template' ) ); ?>" >
38
+ <?php foreach ($this->templates as $template): ?>
39
+ <option
40
+ <?php if ($template == $instance['template']) echo 'selected'; ?>
41
+ value="<?php echo $template ?>" >
42
+ <?php echo $template ?>
43
+ </option>
44
+ <?php endforeach; ?>
45
+ </select>
46
+ </p>
47
+ </div>
48
+ <div class="upw-tab upw-tab-display upw-hide">
49
+ <p>
50
+ <label for="<?php echo esc_attr( $this->get_field_id( 'show_desc' ) ); ?>"><?php _e( 'Show description: ' , 'learnpress' ); ?>&nbsp;</label>
51
+ <input type="checkbox"
52
+ <?php if($instance['show_desc']) echo 'checked' ?>
53
+ class="widefat"
54
+ id="<?php echo esc_attr( $this->get_field_id( 'show_desc' ) ); ?>"
55
+ name="<?php echo esc_attr( $this->get_field_name( 'show_desc' ) ); ?>" >
56
+ </p>
57
+ <p>
58
+ <label for="<?php echo esc_attr( $this->get_field_id( 'desc_length' ) ); ?>"><?php _e( 'Description max length:' , 'learnpress' ); ?></label>
59
+ <input
60
+ class="widefat"
61
+ id="<?php echo esc_attr( $this->get_field_id( 'desc_length' ) ); ?>"
62
+ name="<?php echo esc_attr( $this->get_field_name( 'desc_length' ) ); ?>"
63
+ type="number"
64
+ value="<?php echo esc_attr( $instance['desc_length'] ); ?>">
65
+ </p>
66
+ <p>
67
+ <label for="<?php echo esc_attr( $this->get_field_id( 'show_thumbnail' ) ); ?>"><?php _e( 'Show thumbnail: ' , 'learnpress'); ?>&nbsp;</label>
68
+ <input type="checkbox"
69
+ <?php if($instance['show_thumbnail']) echo 'checked' ?>
70
+ <?php checked( $instance['show_thumbnail'] ) ?>
71
+ class="widefat"
72
+ id="<?php echo esc_attr( $this->get_field_id( 'show_thumbnail' ) ); ?>"
73
+ name="<?php echo esc_attr( $this->get_field_name( 'show_thumbnail' ) ); ?>" >
74
+ </p>
75
+ <p>
76
+ <label for="<?php echo esc_attr( $this->get_field_id( 'show_teacher' ) ); ?>"><?php _e( 'Show Teacher name: ', 'learnpress' ); ?>&nbsp;</label>
77
+ <input type="checkbox"
78
+ <?php if($instance['show_teacher']) echo 'checked' ?>
79
+ class="widefat"
80
+ id="<?php echo esc_attr( $this->get_field_id( 'show_teacher' ) ); ?>"
81
+ name="<?php echo esc_attr( $this->get_field_name( 'show_teacher' ) ); ?>" >
82
+ </p>
83
+ <p>
84
+ <label for="<?php echo esc_attr( $this->get_field_id( 'show_lesson' ) ); ?>"><?php _e( 'Show number of lessons: ', 'learnpress' ); ?>&nbsp;</label>
85
+ <input type="checkbox"
86
+ <?php if($instance['show_lesson']) echo 'checked' ?>
87
+ class="widefat"
88
+ id="<?php echo esc_attr( $this->get_field_id( 'show_lesson' ) ); ?>"
89
+ name="<?php echo esc_attr( $this->get_field_name( 'show_lesson' ) ); ?>" >
90
+ </p>
91
+ <p>
92
+ <label for="<?php echo esc_attr( $this->get_field_id( 'show_enrolled_students' ) ); ?>"><?php _e( 'Show enrolled number: ' , 'learnpress' ); ?>&nbsp;</label>
93
+ <input type="checkbox"
94
+ <?php if ($instance['show_enrolled_students']) echo 'checked' ?>
95
+ class="widefat"
96
+ id="<?php echo esc_attr( $this->get_field_id( 'show_enrolled_students' ) ); ?>"
97
+ name="<?php echo esc_attr( $this->get_field_name( 'show_enrolled_students' ) ); ?>" >
98
+ </p>
99
+ <p>
100
+ <label for="<?php echo esc_attr( $this->get_field_id( 'show_price' ) ); ?>"><?php _e( 'Show price: ', 'learnpress' ); ?>&nbsp;</label>
101
+ <input type="checkbox"
102
+ <?php if ($instance['show_price']) echo 'checked' ?>
103
+ class="widefat"
104
+ id="<?php echo esc_attr( $this->get_field_id( 'show_price' ) ); ?>"
105
+ name="<?php echo esc_attr( $this->get_field_name( 'show_price' ) ); ?>" >
106
+ </p>
107
+ </div>
108
+ <div class="upw-tab upw-tab-actions upw-hide">
109
+ <p>
110
+ <label for="<?php echo esc_attr( $this->get_field_id( 'bottom_link' ) ); ?>"><?php _e( 'Bottom link: ' ,'learnpress'); ?>&nbsp;</label>
111
+ <select
112
+ class="widefat"
113
+ id="<?php echo esc_attr( $this->get_field_id( 'bottom_link' ) ); ?>"
114
+ name="<?php echo esc_attr( $this->get_field_name( 'bottom_link' ) ); ?>">
115
+ <option
116
+ value=""><?php _e('hide bottom link', 'learnpress') ?></option>
117
+ <option
118
+ <?php if($instance['bottom_link'] == 'all_course'){ echo 'selected'; } ?>
119
+ value="all_course"><?php _e('all courses', 'learnpress'); ?>
120
+ </option>
121
+ </select>
122
+ </p>
123
+ <p>
124
+ <label for="<?php echo esc_attr( $this->get_field_id( 'bottom_link_text' ) ); ?>"><?php _e('Bottom link text: ' , 'learnpress'); ?>&nbsp;</label>
125
+ <input
126
+ type="text"
127
+ class="widefat"
128
+ id="<?php echo esc_attr( $this->get_field_id( 'bottom_link_text' ) ); ?>"
129
+ name="<?php echo esc_attr( $this->get_field_name( 'bottom_link_text' ) ); ?>"
130
+ value="<?php echo $instance['bottom_link_text'] ?>" >
131
+ </p>
132
+ </div>
inc/widgets/popular-courses/index.php CHANGED
@@ -1,7 +1 @@
1
- <?php
2
- /**
3
- * Created by PhpStorm.
4
- * User: MinhMinh
5
- * Date: 2/24/2017
6
- * Time: 1:40 PM
7
- */
1
+ <?php // Silence is golden.
 
 
 
 
 
 
inc/widgets/popular-courses/popular-course-widget.php ADDED
@@ -0,0 +1,206 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Widget to display popular courses
4
+ */
5
+
6
+ defined( 'ABSPATH' ) || exit();
7
+
8
+ include LP_PLUGIN_PATH . 'inc/widgets/lp-widget-util.php';
9
+
10
+ /**
11
+ * @class LP_Popular_Course_Widget
12
+ * Widget to display popular courses
13
+ */
14
+ class LP_Popular_Course_Widget extends WP_Widget {
15
+ /**
16
+ * @var null|string widget location
17
+ */
18
+ private $widget_path = null;
19
+
20
+ /**
21
+ * @var string $template_dir template folder location
22
+ */
23
+ private $template_dir = null;
24
+
25
+ /**
26
+ * @var tring $template_file_name template filename
27
+ */
28
+ private $template_file_name = null;
29
+
30
+ /**
31
+ * @var [array] $templates null
32
+ * template list
33
+ */
34
+ private $templates = null;
35
+
36
+ /**
37
+ * @var array|null default instance
38
+ */
39
+ private $default_attributes = null;
40
+
41
+ /**
42
+ * Sets up the widgets name etc
43
+ */
44
+ public function __construct() {
45
+ $widget_ops = array(
46
+ 'classname' => 'popular-courses-widget',
47
+ 'description' => 'Display most popular courses',
48
+ );
49
+
50
+ $this->widget_path = LP_PLUGIN_PATH . '/inc/widgets/popular-courses';
51
+
52
+ $this->template_dir = $this->widget_path . '/templates/';
53
+
54
+ $this->template_file_name = 'default.php';
55
+
56
+ $this->templates = scandir( $this->template_dir );
57
+ $this->templates = array_filter( $this->templates, 'lp_php_file_filter' );
58
+ array_walk( $this->templates, 'lp_trim_file_extension' );
59
+
60
+ $this->default_attributes = array(
61
+ 'show_teacher' => 'true',
62
+ 'show_lesson' => 'true',
63
+ 'show_thumbnail' => 'true',
64
+ 'limit' => '5',
65
+ 'title' => __( 'Popular courses', 'learnpress' ),
66
+ 'show_desc' => '',
67
+ 'desc_length' => '10',
68
+ 'show_enrolled_students' => 'true',
69
+ 'show_price' => '',
70
+ 'template' => 'default',
71
+ 'css_class' => '',
72
+ 'bottom_link' => '',
73
+ 'bottom_link_text' => ''
74
+ );
75
+
76
+ parent::__construct( 'popular-courses-widget', __( 'LearnPress - Popular Courses', 'learnpress' ), $widget_ops );
77
+ }
78
+
79
+ /**
80
+ * get template file name from options
81
+ *
82
+ * @param WP_Widget $instance widget instance
83
+ *
84
+ * @return string Template filename
85
+ */
86
+ private function get_template_file( &$instance ) {
87
+ $template_file_name = $instance['template'] . '.php';
88
+ if ( !file_exists( $this->template_dir . $template_file_name ) ) {
89
+ $template_file_name = 'default.php';
90
+ }
91
+ $this->template_file_name = $template_file_name;
92
+
93
+ return $template_file_name;
94
+ }
95
+
96
+ /**
97
+ * render widget template
98
+ *
99
+ * @param array $courses array of course
100
+ * @param array widget args
101
+ * @param WP_Widget $instance widget instance
102
+ */
103
+ private function render( $courses, $args, $a ) {
104
+ //include template file
105
+ include $this->template_dir . $this->template_file_name;
106
+ }
107
+
108
+ /**
109
+ * get learn press course from wordpress post object
110
+ *
111
+ * @param object -reference $post wordpress post object
112
+ *
113
+ * @return LP_Course course
114
+ */
115
+ public function get_lp_course( $post ) {
116
+ $id = $post->ID;
117
+ $course = null;
118
+ if ( !empty( $id ) ) {
119
+ $course = new LP_Course( $id );
120
+ }
121
+
122
+ return $course;
123
+ }
124
+
125
+ /**
126
+ * get courses
127
+ * @return array|null array of course
128
+ */
129
+ private function get_courses( $instance ) {
130
+ global $wpdb;
131
+ $query = $wpdb->prepare(
132
+ "SELECT DISTINCT ID, (meta_value + if(st, CAST(st AS UNSIGNED), 0)) AS value
133
+ FROM {$wpdb->posts} p
134
+ LEFT JOIN {$wpdb->postmeta} as pmeta ON p.ID=pmeta.post_id AND pmeta.meta_key='_lp_max_students'
135
+ LEFT JOIN ( SELECT item_id , COUNT(user_id) AS st
136
+ FROM {$wpdb->prefix}learnpress_user_items
137
+ WHERE 1
138
+ GROUP BY item_id
139
+ ) puser
140
+ ON p.ID=puser.item_id
141
+ WHERE p.post_type = %s
142
+ AND p.post_status = %s
143
+ ORDER BY value
144
+ LIMIT %d",
145
+ LP_COURSE_CPT,
146
+ 'publish',
147
+ (int) $instance['limit']
148
+ );
149
+ $posts = $wpdb->get_results(
150
+ $query
151
+ );
152
+
153
+ $courses = array_map( array( $this, 'get_lp_course' ), $posts );
154
+ return $courses;
155
+ }
156
+
157
+
158
+ /**
159
+ * Outputs the content of the widget
160
+ *
161
+ * @param array $args
162
+ * @param array $instance
163
+ */
164
+ public function widget( $args, $instance ) {
165
+ $instance = wp_parse_args( $instance, $this->default_attributes );
166
+ $this->get_template_file( $instance );
167
+ $courses = $this->get_courses( $instance );
168
+
169
+ echo $args['before_widget'];
170
+ $this->render( $courses, $args, $instance );
171
+ echo $args['after_widget'];
172
+ }
173
+
174
+ /**
175
+ * Outputs the options form on admin
176
+ *
177
+ * @param array $instance The widget options
178
+ *
179
+ * @return void
180
+ */
181
+ public function form( $instance ) {
182
+ $instance = wp_parse_args( ( array ) $instance, $this->default_attributes );
183
+ require $this->widget_path . '/form.php';
184
+ }
185
+
186
+ /**
187
+ * Processing widget options on save
188
+ *
189
+ * @param array $new_instance The new options
190
+ * @param array $old_instance The previous options
191
+ *
192
+ * @return array widget instance to save to db
193
+ */
194
+ public function update( $new_instance, $old_instance ) {
195
+ $instance = wp_parse_args( $new_instance, $this->default_attributes );
196
+
197
+ return $instance;
198
+ }
199
+ }
200
+
201
+ // register widget
202
+ function register_popular_course_widget() {
203
+ register_widget( 'LP_Popular_Course_Widget' );
204
+ }
205
+
206
+ add_action( 'lp_widgets_init', 'register_popular_course_widget' );
inc/widgets/popular-courses/popular-courses.php DELETED
@@ -1,149 +0,0 @@
1
- <?php
2
- /**
3
- * Widget to display popular courses
4
- */
5
-
6
- defined( 'ABSPATH' ) || exit();
7
-
8
- if ( ! class_exists( 'LP_Widget_Popular_Courses' ) ) {
9
-
10
- /**
11
- * Class LP_Widget_Popular_Courses
12
- */
13
- class LP_Widget_Popular_Courses extends LP_Widget {
14
-
15
- private $courses = array();
16
-
17
- /**
18
- * Sets up the widgets name etc
19
- */
20
- public function __construct() {
21
- $prefix = '';
22
- $this->options = array(
23
- 'title' => array(
24
- 'name' => __( 'Title', 'learnpress' ),
25
- 'id' => "{$prefix}title",
26
- 'type' => 'text',
27
- 'std' => __( 'Popular Courses', 'learnpress' )
28
- ),
29
- 'show_teacher' => array(
30
- 'name' => __( 'Show teacher', 'learpnress' ),
31
- 'id' => "{$prefix}show_teacher",
32
- 'type' => 'checkbox',
33
- 'std' => 1
34
- ),
35
- 'show_lesson' => array(
36
- 'name' => __( 'Show lesson', 'learpnress' ),
37
- 'id' => "{$prefix}show_lesson",
38
- 'type' => 'checkbox',
39
- 'std' => 1
40
- ),
41
- 'show_thumbnail' => array(
42
- 'name' => __( 'Show Thumbnail', 'learpnress' ),
43
- 'id' => "{$prefix}show_thumbnail",
44
- 'type' => 'checkbox',
45
- 'std' => 1
46
- ),
47
- 'limit' => array(
48
- 'name' => __( 'Limit', 'learpnress' ),
49
- 'id' => "{$prefix}limit",
50
- 'type' => 'number',
51
- 'min' => 1,
52
- 'std' => 5
53
- ),
54
- 'desc_length' => array(
55
- 'name' => __( 'Description Length', 'learpnress' ),
56
- 'id' => "{$prefix}desc_length",
57
- 'type' => 'number',
58
- 'min' => 0,
59
- 'std' => 10
60
- ),
61
- 'show_enrolled_students' => array(
62
- 'name' => __( 'Show Enrolled Students', 'learpnress' ),
63
- 'id' => "{$prefix}show_enrolled_students",
64
- 'type' => 'checkbox',
65
- 'std' => 0
66
- ),
67
- 'show_price' => array(
68
- 'name' => __( 'Show Price', 'learpnress' ),
69
- 'id' => "{$prefix}show_price",
70
- 'type' => 'checkbox',
71
- 'std' => 1
72
- ),
73
- 'css_class' => array(
74
- 'name' => __( 'CSS Class', 'learpnress' ),
75
- 'id' => "{$prefix}css_class",
76
- 'type' => 'text',
77
- 'std' => ''
78
- ),
79
- 'bottom_link_text' => array(
80
- 'name' => __( 'Go to Courses', 'learpnress' ),
81
- 'id' => "{$prefix}bottom_link_text",
82
- 'type' => 'text',
83
- 'std' => 'LP Courses'
84
- )
85
- );
86
-
87
- parent::__construct();
88
- add_filter( 'learn_press_widget_display_content-' . $this->id_base, 'learn_press_is_course' );
89
- }
90
-
91
- /**
92
- * get learn press course from wordpress post object
93
- *
94
- * @param object -reference $post wordpress post object
95
- *
96
- * @return LP_Course course
97
- */
98
- public function get_lp_course( $post ) {
99
- $id = $post->ID;
100
- $course = null;
101
- if ( !empty( $id ) ) {
102
- $course = new LP_Course( $id );
103
- }
104
-
105
- return $course;
106
- }
107
-
108
- /**
109
- * get courses
110
- * @return array|null array of course
111
- */
112
- private function get_courses() {
113
-
114
- if ( empty( $this->instance ) ) {
115
- return array();
116
- }
117
-
118
- global $wpdb;
119
- $query = $wpdb->prepare(
120
- "SELECT po.*, count(*) as number_enrolled
121
- FROM {$wpdb->prefix}learnpress_user_items ui
122
- INNER JOIN {$wpdb->posts} po ON po.ID = ui.item_id
123
- WHERE ui.item_type = %s
124
- AND ( ui.status = %s OR ui.status = %s )
125
- AND po.post_status = %s
126
- GROUP BY ui.item_id
127
- ORDER BY ui.item_id DESC
128
- LIMIT %d
129
- ",
130
- LP_COURSE_CPT,
131
- 'enrolled',
132
- 'finished',
133
- 'publish',
134
- (int) $this->instance['limit']
135
- );
136
- $posts = $wpdb->get_results(
137
- $query
138
- );
139
- $courses = array_map( array( $this, 'get_lp_course' ), $posts );
140
- return $courses;
141
- }
142
-
143
- public function show () {
144
- $this->courses = $this->get_courses();
145
- include learn_press_locate_widget_template( $this->get_slug() );
146
- }
147
- }
148
-
149
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/widgets/popular-courses/templates/default.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="<?php echo 'archive-course-widget-outer ' . $a['template'] . ' ' . $a["css_class"] ?>">
2
+ <?php if ( !empty( $a['title'] ) ) {
3
+ echo $args['before_title'] . apply_filters( 'widget_title', $a['title'] ) . $args['after_title'];
4
+ }
5
+ ?>
6
+ <div class="widget-body">
7
+ <?php foreach ( $courses as $course ): ?>
8
+ <div class="course-entry">
9
+ <?php if ( $a['show_thumbnail'] ): ?>
10
+ <div class="course-cover">
11
+ <a href="<?php echo get_the_permalink( $course->id ); ?>">
12
+ <?php echo get_the_post_thumbnail( $course->id, 'medium' ); ?>
13
+ </a>
14
+ </div>
15
+ <?php endif; ?>
16
+ <div class="course-detail">
17
+ <a href="<?php echo get_the_permalink( $course->id ) ?>">
18
+ <h3 class="course-title">
19
+ <?php echo $course->get_course_data()->post_title; ?>
20
+ </h3>
21
+ </a>
22
+ <?php if ( $a['show_desc'] ): ?>
23
+ <div class="course-description"><?php
24
+ $content_length = intval( $a['desc_length'] );
25
+ $the_content = $course->get_course_data()->post_content;
26
+ $the_content = wp_trim_words( $the_content, $content_length, __( '...', 'learnpress' ) );
27
+ echo $the_content;
28
+ ?></div>
29
+ <?php endif; ?>
30
+ <div class="course-meta-data">
31
+ <?php if ( $a['show_price'] ): ?>
32
+ <div class="course-meta-field">
33
+ <?php
34
+ echo $course->get_price_html();
35
+ ?>
36
+ </div>
37
+ <?php endif; ?>
38
+ <?php if ( $a['show_enrolled_students'] ): ?>
39
+ <div class="course-student-number course-meta-field">
40
+ <?php
41
+ $students = $course->get_users_enrolled();
42
+ echo intval( $students ) > 1 ? sprintf( __( '%d students', 'learnpress' ), $students ) : sprintf( __( '%d student', 'learnpress' ), $students );
43
+ ?>
44
+ </div>
45
+ <?php endif; ?>
46
+ <?php if ( $a['show_lesson'] ): ?>
47
+ <div class="course-lesson-number course-meta-field">
48
+ <?php
49
+ $lessons = sizeof( $course->get_lessons() );
50
+ echo intval( $lessons ) > 1 ? sprintf( __( '%d lessons', 'learnpress' ), $lessons ) : sprintf( __( '%d lesson', 'learnpress' ), $lessons );
51
+ ?>
52
+ </div>
53
+ <?php endif; ?>
54
+ <?php if ( $a['show_teacher'] ): ?>
55
+ <div class="course-meta-field">
56
+ <?php echo $course->get_instructor_html(); ?>
57
+ </div>
58
+ <?php endif; ?>
59
+ </div>
60
+ </div>
61
+ </div>
62
+ <?php endforeach; ?>
63
+ </div>
64
+ <div class="widget-footer">
65
+ <?php if ( $a['bottom_link'] == 'all_course' ):
66
+ $page_id = get_option( 'learn_press_courses_page_id' );
67
+ $link = get_page_link( $page_id );
68
+ $title = get_the_title( $page_id );
69
+ ?>
70
+ <a class="pull-right" href="<?php echo $link ?>">
71
+ <?php
72
+ echo( !empty( $a['bottom_link_text'] ) ? $a['bottom_link_text'] : $title );
73
+ ?>
74
+ </a>
75
+ <?php endif; ?>
76
+ </div>
77
+ </div>
78
+ <div class="clearfix"></div>
inc/widgets/popular-courses/templates/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden.
inc/widgets/popular-courses/tmpl/default.php DELETED
File without changes
inc/widgets/popular-courses/tmpl/index.php DELETED
@@ -1,7 +0,0 @@
1
- <?php
2
- /**
3
- * Created by PhpStorm.
4
- * User: MinhMinh
5
- * Date: 2/24/2017
6
- * Time: 1:19 PM
7
- */
 
 
 
 
 
 
 
inc/widgets/recent-courses/form.php ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="upw-tabs">
2
+ <a class="upw-tab-item active" data-toggle="upw-tab-general">General</a>
3
+ <a class="upw-tab-item" data-toggle="upw-tab-display">Display</a>
4
+ <a class="upw-tab-item" data-toggle="upw-tab-actions">Actions</a>
5
+ </div>
6
+ <div class="upw-tab upw-tab-general upw-show">
7
+ <p>
8
+ <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e('Title:' , 'learnpress' ); ?></label>
9
+ <input
10
+ class="widefat"
11
+ id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"
12
+ name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>"
13
+ type="text"
14
+ value="<?php echo esc_attr( $instance['title'] ); ?>">
15
+ </p>
16
+ <p>
17
+ <label for="<?php echo esc_attr( $this->get_field_id( 'limit' ) ); ?>"><?php _e( 'Number of posts:', 'learnpress' ) ; ?></label>
18
+ <input
19
+ class="widefat"
20
+ id="<?php echo esc_attr( $this->get_field_id( 'limit' ) ); ?>"
21
+ name="<?php echo esc_attr( $this->get_field_name( 'limit' ) ); ?>"
22
+ type="number"
23
+ value="<?php echo esc_attr( $instance['limit'] ); ?>">
24
+ </p>
25
+ <p>
26
+ <label for="<?php echo esc_attr( $this->get_field_id( 'css_class' ) ); ?>"><?php _e( 'CSS class:', 'learnpress' ) ; ?></label>
27
+ <input
28
+ class="widefat"
29
+ id="<?php echo esc_attr( $this->get_field_id( 'css_class' ) ); ?>"
30
+ name="<?php echo esc_attr( $this->get_field_name( 'css_class' ) ); ?>"
31
+ type="text"
32
+ value="<?php echo esc_attr( $instance['css_class'] ); ?>">
33
+ </p>
34
+ <p>
35
+ <label for="<?php echo esc_attr( $this->get_field_id( 'template' ) ); ?>"><?php _e( 'Choose template: ', 'learnpress' ); ?>&nbsp;</label>
36
+ <select id="<?php echo esc_attr( $this->get_field_id( 'template' ) ); ?>"
37
+ name="<?php echo esc_attr( $this->get_field_name( 'template' ) ); ?>" >
38
+ <?php foreach ($this->templates as $template): ?>
39
+ <option
40
+ <?php if ($template == $instance['template']) echo 'selected'; ?>
41
+ value="<?php echo $template ?>" >
42
+ <?php echo $template ?>
43
+ </option>
44
+ <?php endforeach; ?>
45
+ </select>
46
+ </p>
47
+ </div>
48
+ <div class="upw-tab upw-tab-display upw-hide">
49
+ <p>
50
+ <label for="<?php echo esc_attr( $this->get_field_id( 'show_desc' ) ); ?>"><?php _e( 'Show description: ' , 'learnpress' ); ?>&nbsp;</label>
51
+ <input type="checkbox"
52
+ <?php if($instance['show_desc']) echo 'checked' ?>
53
+ class="widefat"
54
+ id="<?php echo esc_attr( $this->get_field_id( 'show_desc' ) ); ?>"
55
+ name="<?php echo esc_attr( $this->get_field_name( 'show_desc' ) ); ?>" >
56
+ </p>
57
+ <p>
58
+ <label for="<?php echo esc_attr( $this->get_field_id( 'desc_length' ) ); ?>"><?php _e( 'Description max length:' , 'learnpress' ); ?></label>
59
+ <input
60
+ class="widefat"
61
+ id="<?php echo esc_attr( $this->get_field_id( 'desc_length' ) ); ?>"
62
+ name="<?php echo esc_attr( $this->get_field_name( 'desc_length' ) ); ?>"
63
+ type="number"
64
+ value="<?php echo esc_attr( $instance['desc_length'] ); ?>">
65
+ </p>
66
+ <p>
67
+ <label for="<?php echo esc_attr( $this->get_field_id( 'show_thumbnail' ) ); ?>"><?php _e( 'Show thumbnail: ' , 'learnpress'); ?>&nbsp;</label>
68
+ <input type="checkbox"
69
+ <?php if($instance['show_thumbnail']) echo 'checked' ?>
70
+ <?php checked( $instance['show_thumbnail'] ) ?>
71
+ class="widefat"
72
+ id="<?php echo esc_attr( $this->get_field_id( 'show_thumbnail' ) ); ?>"
73
+ name="<?php echo esc_attr( $this->get_field_name( 'show_thumbnail' ) ); ?>" >
74
+ </p>
75
+ <p>
76
+ <label for="<?php echo esc_attr( $this->get_field_id( 'show_teacher' ) ); ?>"><?php _e( 'Show Teacher name: ', 'learnpress' ); ?>&nbsp;</label>
77
+ <input type="checkbox"
78
+ <?php if($instance['show_teacher']) echo 'checked' ?>
79
+ class="widefat"
80
+ id="<?php echo esc_attr( $this->get_field_id( 'show_teacher' ) ); ?>"
81
+ name="<?php echo esc_attr( $this->get_field_name( 'show_teacher' ) ); ?>" >
82
+ </p>
83
+ <p>
84
+ <label for="<?php echo esc_attr( $this->get_field_id( 'show_lesson' ) ); ?>"><?php _e( 'Show number of lessons: ', 'learnpress' ); ?>&nbsp;</label>
85
+ <input type="checkbox"
86
+ <?php if($instance['show_lesson']) echo 'checked' ?>
87
+ class="widefat"
88
+ id="<?php echo esc_attr( $this->get_field_id( 'show_lesson' ) ); ?>"
89
+ name="<?php echo esc_attr( $this->get_field_name( 'show_lesson' ) ); ?>" >
90
+ </p>
91
+ <p>
92
+ <label for="<?php echo esc_attr( $this->get_field_id( 'show_enrolled_students' ) ); ?>"><?php _e( 'Show enrolled number: ' , 'learnpress' ); ?>&nbsp;</label>
93
+ <input type="checkbox"
94
+ <?php if ($instance['show_enrolled_students']) echo 'checked' ?>
95
+ class="widefat"
96
+ id="<?php echo esc_attr( $this->get_field_id( 'show_enrolled_students' ) ); ?>"
97
+ name="<?php echo esc_attr( $this->get_field_name( 'show_enrolled_students' ) ); ?>" >
98
+ </p>
99
+ <p>
100
+ <label for="<?php echo esc_attr( $this->get_field_id( 'show_price' ) ); ?>"><?php _e( 'Show price: ', 'learnpress' ); ?>&nbsp;</label>
101
+ <input type="checkbox"
102
+ <?php if ($instance['show_price']) echo 'checked' ?>
103
+ class="widefat"
104
+ id="<?php echo esc_attr( $this->get_field_id( 'show_price' ) ); ?>"
105
+ name="<?php echo esc_attr( $this->get_field_name( 'show_price' ) ); ?>" >
106
+ </p>
107
+ </div>
108
+ <div class="upw-tab upw-tab-actions upw-hide">
109
+ <p>
110
+ <label for="<?php echo esc_attr( $this->get_field_id( 'bottom_link' ) ); ?>"><?php _e( 'Bottom link: ' ,'learnpress'); ?>&nbsp;</label>
111
+ <select
112
+ class="widefat"
113
+ id="<?php echo esc_attr( $this->get_field_id( 'bottom_link' ) ); ?>"
114
+ name="<?php echo esc_attr( $this->get_field_name( 'bottom_link' ) ); ?>">
115
+ <option
116
+ value=""><?php _e('hide bottom link', 'learnpress') ?></option>
117
+ <option
118
+ <?php if($instance['bottom_link'] == 'all_course'){ echo 'selected'; } ?>
119
+ value="all_course"><?php _e('all courses', 'learnpress'); ?>
120
+ </option>
121
+ </select>
122
+ </p>
123
+ <p>
124
+ <label for="<?php echo esc_attr( $this->get_field_id( 'bottom_link_text' ) ); ?>"><?php _e('Bottom link text: ' , 'learnpress'); ?>&nbsp;</label>
125
+ <input
126
+ type="text"
127
+ class="widefat"
128
+ id="<?php echo esc_attr( $this->get_field_id( 'bottom_link_text' ) ); ?>"
129
+ name="<?php echo esc_attr( $this->get_field_name( 'bottom_link_text' ) ); ?>"
130
+ value="<?php echo $instance['bottom_link_text'] ?>" >
131
+ </p>
132
+ </div>
inc/widgets/recent-courses/index.php CHANGED
@@ -1,7 +1 @@
1
- <?php
2
- /**
3
- * Created by PhpStorm.
4
- * User: MinhMinh
5
- * Date: 2/24/2017
6
- * Time: 1:40 PM
7
- */
1
+ <?php // Silence is golden.
 
 
 
 
 
 
inc/widgets/recent-courses/recent-course-widget.php ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Widget to display recent courses
4
+ */
5
+
6
+ defined( 'ABSPATH' ) || exit();
7
+
8
+ include LP_PLUGIN_PATH . 'inc/widgets/lp-widget-util.php';
9
+
10
+ /**
11
+ * @class LP_Recent_Course_Widget
12
+ * Widget to display recent courses
13
+ */
14
+ class LP_Recent_Course_Widget extends WP_Widget {
15
+ /**
16
+ * @var null|string widget location
17
+ */
18
+ private $widget_path = null;
19
+
20
+ /**
21
+ * @var string $template_dir template folder location
22
+ */
23
+ private $template_dir = null;
24
+
25
+ /**
26
+ * @var tring $template_file_name template filename
27
+ */
28
+ private $template_file_name = null;
29
+
30
+ /**
31
+ * @var [array] $templates null
32
+ * template list
33
+ */
34
+ private $templates = null;
35
+
36
+ /**
37
+ * @var array|null default instance
38
+ */
39
+ private $default_attributes = null;
40
+
41
+ /**
42
+ * Sets up the widgets name etc
43
+ */
44
+ public function __construct() {
45
+ $widget_ops = array(
46
+ 'classname' => 'recent-courses-widget',
47
+ 'description' => __( 'Display most recent courses', 'learnpress' )
48
+ );
49
+
50
+ $this->widget_path = LP_PLUGIN_PATH . '/inc/widgets/recent-courses';
51
+
52
+ $this->template_dir = $this->widget_path . '/templates/';
53
+
54
+ $this->template_file_name = 'default.php';
55
+
56
+ $this->templates = scandir( $this->template_dir );
57
+ $this->templates = array_filter( $this->templates, 'lp_php_file_filter' );
58
+ array_walk( $this->templates, 'lp_trim_file_extension' );
59
+
60
+ $this->default_attributes = array(
61
+ 'show_teacher' => 'true',
62
+ 'show_lesson' => 'true',
63
+ 'show_thumbnail' => 'true',
64
+ 'limit' => '5',
65
+ 'title' => __( 'Recent courses', 'learnpress' ),
66
+ 'show_desc' => '',
67
+ 'desc_length' => '10',
68
+ 'show_enrolled_students' => 'true',
69
+ 'show_price' => '',
70
+ 'template' => 'default',
71
+ 'css_class' => '',
72
+ 'bottom_link' => '',
73
+ 'bottom_link_text' => ''
74
+ );
75
+
76
+ parent::__construct( 'recent-courses-widget', __( 'LearnPress - Recent Courses', 'learnpress' ), $widget_ops );
77
+ }
78
+
79
+ /**
80
+ * get template file name from options
81
+ *
82
+ * @param WP_Widget $instance widget instance
83
+ *
84
+ * @return string Template filename
85
+ */
86
+ private function get_template_file( &$instance ) {
87
+ $template_file_name = $instance['template'] . '.php';
88
+ if ( !file_exists( $this->template_dir . $template_file_name ) ) {
89
+ $template_file_name = 'default.php';
90
+ }
91
+ $this->template_file_name = $template_file_name;
92
+
93
+ return $template_file_name;
94
+ }
95
+
96
+ /**
97
+ * render widget template
98
+ *
99
+ * @param array $courses array of course
100
+ * @param array widget args
101
+ * @param WP_Widget $instance widget instance
102
+ */
103
+ private function render( $courses, $args, $a ) {
104
+ //include template file
105
+ include $this->template_dir . $this->template_file_name;
106
+ }
107
+
108
+ /**
109
+ * get learn press course from wordpress post object
110
+ *
111
+ * @param object -reference $post wordpress post object
112
+ *
113
+ * @return LP_Course course
114
+ */
115
+ public function get_lp_course( $post ) {
116
+ $id = $post->ID;
117
+ $course = null;
118
+ if ( !empty( $id ) ) {
119
+ $course = new LP_Course( $id );
120
+ }
121
+
122
+ return $course;
123
+ }
124
+
125
+ /**
126
+ * get courses
127
+ * @return array|null array of course
128
+ */
129
+ private function get_courses( $instance ) {
130
+ global $wpdb;
131
+ $posts = $wpdb->get_results(
132
+ $wpdb->prepare( "
133
+ SELECT DISTINCT ID
134
+ FROM $wpdb->posts AS p
135
+ WHERE p.post_type = %s
136
+ AND p.post_status = %s
137
+ ORDER BY p.post_date DESC
138
+ LIMIT %d", LP_COURSE_CPT, 'publish', (int) $instance['limit']
139
+ )
140
+ );
141
+ $courses = array_map( array( $this, 'get_lp_course' ), $posts );
142
+ return $courses;
143
+ }
144
+
145
+
146
+ /**
147
+ * Outputs the content of the widget
148
+ *
149
+ * @param array $args
150
+ * @param array $instance
151
+ */
152
+ public function widget( $args, $instance ) {
153
+ $instance = wp_parse_args( $instance, $this->default_attributes );
154
+ $this->get_template_file( $instance );
155
+ $courses = $this->get_courses( $instance );
156
+
157
+ echo $args['before_widget'];
158
+ $this->render( $courses, $args, $instance );
159
+ echo $args['after_widget'];
160
+ }
161
+
162
+ /**
163
+ * Outputs the options form on admin
164
+ *
165
+ * @param array $instance The widget options
166
+ *
167
+ * @return void
168
+ */
169
+ public function form( $instance ) {
170
+ $instance = wp_parse_args( ( array ) $instance, $this->default_attributes );
171
+ require $this->widget_path . '/form.php';
172
+ }
173
+
174
+ /**
175
+ * Processing widget options on save
176
+ *
177
+ * @param array $new_instance The new options
178
+ * @param array $old_instance The previous options
179
+ *
180
+ * @return array widget instance to save to db
181
+ */
182
+ public function update( $new_instance, $old_instance ) {
183
+ $instance = wp_parse_args( $new_instance, $this->default_attributes );
184
+
185
+ return $instance;
186
+ }
187
+ }
188
+
189
+ // register widget
190
+ function register_recent_course_widget() {
191
+ register_widget( 'LP_Recent_Course_Widget' );
192
+ }
193
+
194
+ add_action( 'lp_widgets_init', 'register_recent_course_widget' );
inc/widgets/recent-courses/recent-courses.php DELETED
@@ -1,142 +0,0 @@
1
- <?php
2
- /**
3
- * Widget to display recent courses
4
- */
5
-
6
- if ( ! class_exists( 'LP_Widget_Recent_Courses' ) ) {
7
-
8
- /**
9
- * Class LP_Widget_Recent_Courses
10
- */
11
- class LP_Widget_Recent_Courses extends LP_Widget {
12
-
13
- private $courses = array();
14
-
15
- public function __construct () {
16
-
17
- $prefix = '';
18
- $this->options = array(
19
- 'title' => array(
20
- 'name' => __( 'Title', 'learnpress' ),
21
- 'id' => "{$prefix}title",
22
- 'type' => 'text',
23
- 'std' => __( 'Recent Courses', 'learnpress' )
24
- ),
25
- 'show_teacher' => array(
26
- 'name' => __( 'Show teacher', 'learpnress' ),
27
- 'id' => "{$prefix}show_teacher",
28
- 'type' => 'checkbox',
29
- 'std' => 1
30
- ),
31
- 'show_lesson' => array(
32
- 'name' => __( 'Show lesson', 'learpnress' ),
33
- 'id' => "{$prefix}show_lesson",
34
- 'type' => 'checkbox',
35
- 'std' => 1
36
- ),
37
- 'show_thumbnail' => array(
38
- 'name' => __( 'Show Thumbnail', 'learpnress' ),
39
- 'id' => "{$prefix}show_thumbnail",
40
- 'type' => 'checkbox',
41
- 'std' => 1
42
- ),
43
- 'limit' => array(
44
- 'name' => __( 'Limit', 'learpnress' ),
45
- 'id' => "{$prefix}limit",
46
- 'type' => 'number',
47
- 'min' => 1,
48
- 'std' => 4
49
- ),
50
- 'desc_length' => array(
51
- 'name' => __( 'Description Length', 'learpnress' ),
52
- 'id' => "{$prefix}desc_length",
53
- 'type' => 'number',
54
- 'min' => 0,
55
- 'std' => 10
56
- ),
57
- 'show_enrolled_students' => array(
58
- 'name' => __( 'Show Enrolled Students', 'learpnress' ),
59
- 'id' => "{$prefix}show_enrolled_students",
60
- 'type' => 'checkbox',
61
- 'std' => 1
62
- ),
63
- 'show_price' => array(
64
- 'name' => __( 'Show Price', 'learpnress' ),
65
- 'id' => "{$prefix}show_price",
66
- 'type' => 'checkbox',
67
- 'std' => 1
68
- ),
69
- 'css_class' => array(
70
- 'name' => __( 'CSS Class', 'learpnress' ),
71
- 'id' => "{$prefix}css_class",
72
- 'type' => 'text',
73
- 'std' => ''
74
- ),
75
- 'bottom_link_text' => array(
76
- 'name' => __( 'Go to Courses', 'learpnress' ),
77
- 'id' => "{$prefix}bottom_link_text",
78
- 'type' => 'text',
79
- 'std' => 'LP Courses'
80
- )
81
- );
82
- parent::__construct();
83
- add_filter( 'learn_press_widget_display_content-' . $this->id_base, 'learn_press_is_course' );
84
- }
85
-
86
- /**
87
- * get learn press course from wordpress post object
88
- *
89
- * @param object -reference $post wordpress post object
90
- *
91
- * @return LP_Course course
92
- */
93
- public function get_lp_course( $post ) {
94
- $id = $post->ID;
95
- $course = null;
96
- if ( !empty( $id ) ) {
97
- $course = new LP_Course( $id );
98
- }
99
-
100
- return $course;
101
- }
102
-
103
- /**
104
- * get courses
105
- * @return array|null array of course
106
- */
107
- private function get_courses () {
108
-
109
- if ( empty( $this->instance ) ) {
110
- return array();
111
- }
112
-
113
- global $wpdb;
114
-
115
- $posts = $wpdb->get_results(
116
- $wpdb->prepare(
117
- "SELECT DISTINCT p.ID, p.post_date
118
- FROM $wpdb->posts AS p
119
- WHERE p.post_type = %s
120
- AND p.post_status = %s
121
- ORDER BY p.post_date DESC
122
- LIMIT %d
123
- ",
124
- LP_COURSE_CPT,
125
- 'publish',
126
- (int) $this->instance['limit']
127
- )
128
- );
129
-
130
- $courses = array_map( array( $this, 'get_lp_course' ), $posts );
131
-
132
- return $courses;
133
-
134
- }
135
-
136
- public function show () {
137
- $this->courses = $this->get_courses();
138
- include learn_press_locate_widget_template( $this->get_slug() );
139
- }
140
-
141
- }
142
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/widgets/recent-courses/{tmpl → templates}/default.php RENAMED
@@ -1,11 +1,12 @@
1
- <?php
2
- $instance = $this->instance;
3
- ?>
4
- <div class="<?php echo 'archive-course-widget-outer ' . esc_attr($instance["css_class"]); ?>">
 
5
  <div class="widget-body">
6
- <?php foreach ( $this->courses as $course ): ?>
7
  <div class="course-entry">
8
- <?php if ( !empty($instance["show_thumbnail"]) ): ?>
9
  <div class="course-cover">
10
  <a href="<?php echo get_the_permalink( $course->id ); ?>">
11
  <?php echo get_the_post_thumbnail( $course->id, 'medium' ); ?>
@@ -18,23 +19,23 @@ $instance = $this->instance;
18
  <?php echo $course->get_course_data()->post_title; ?>
19
  </h3>
20
  </a>
21
- <?php if ( !empty($instance['desc_length']) && intval( $instance['desc_length'] ) > 0 ): ?>
22
  <div class="course-description"><?php
23
- $content_length = intval( $instance['desc_length'] );
24
  $the_content = $course->get_course_data()->post_content;
25
  $the_content = wp_trim_words( $the_content, $content_length, __( '...', 'learnpress' ) );
26
  echo $the_content;
27
  ?></div>
28
  <?php endif; ?>
29
  <div class="course-meta-data">
30
- <?php if ( !empty($instance['show_price']) ): ?>
31
  <div class="course-meta-field">
32
  <?php
33
  echo $course->get_price_html();
34
  ?>
35
  </div>
36
  <?php endif; ?>
37
- <?php if ( !empty($instance['show_enrolled_students']) ): ?>
38
  <div class="course-student-number course-meta-field">
39
  <?php
40
  $students = $course->get_users_enrolled();
@@ -42,7 +43,7 @@ $instance = $this->instance;
42
  ?>
43
  </div>
44
  <?php endif; ?>
45
- <?php if ( !empty($instance['show_lesson']) ): ?>
46
  <div class="course-lesson-number course-meta-field">
47
  <?php
48
  $lessons = sizeof( $course->get_lessons() );
@@ -50,7 +51,7 @@ $instance = $this->instance;
50
  ?>
51
  </div>
52
  <?php endif; ?>
53
- <?php if ( !empty($instance['show_teacher']) ): ?>
54
  <div class="course-meta-field">
55
  <?php echo $course->get_instructor_html(); ?>
56
  </div>
@@ -61,13 +62,15 @@ $instance = $this->instance;
61
  <?php endforeach; ?>
62
  </div>
63
  <div class="widget-footer">
64
- <?php if ( !empty($instance['bottom_link_text']) ):
65
  $page_id = get_option( 'learn_press_courses_page_id' );
66
  $link = get_page_link( $page_id );
67
  $title = get_the_title( $page_id );
68
  ?>
69
  <a class="pull-right" href="<?php echo $link ?>">
70
- <?php echo $instance['bottom_link_text']; ?>
 
 
71
  </a>
72
  <?php endif; ?>
73
  </div>
1
+ <div class="<?php echo 'archive-course-widget-outer ' . $a['template'] . ' ' . $a["css_class"] ?>">
2
+ <?php if ( !empty( $a['title'] ) ) {
3
+ echo $args['before_title'] . apply_filters( 'widget_title', $a['title'] ) . $args['after_title'];
4
+ }
5
+ ?>
6
  <div class="widget-body">
7
+ <?php foreach ( $courses as $course ): ?>
8
  <div class="course-entry">
9
+ <?php if ( $a['show_thumbnail'] ): ?>
10
  <div class="course-cover">
11
  <a href="<?php echo get_the_permalink( $course->id ); ?>">
12
  <?php echo get_the_post_thumbnail( $course->id, 'medium' ); ?>
19
  <?php echo $course->get_course_data()->post_title; ?>
20
  </h3>
21
  </a>
22
+ <?php if ( $a['show_desc'] ): ?>
23
  <div class="course-description"><?php
24
+ $content_length = intval( $a['desc_length'] );
25
  $the_content = $course->get_course_data()->post_content;
26
  $the_content = wp_trim_words( $the_content, $content_length, __( '...', 'learnpress' ) );
27
  echo $the_content;
28
  ?></div>
29
  <?php endif; ?>
30
  <div class="course-meta-data">
31
+ <?php if ( $a['show_price'] ): ?>
32
  <div class="course-meta-field">
33
  <?php
34
  echo $course->get_price_html();
35
  ?>
36
  </div>
37
  <?php endif; ?>
38
+ <?php if ( $a['show_enrolled_students'] ): ?>
39
  <div class="course-student-number course-meta-field">
40
  <?php
41
  $students = $course->get_users_enrolled();
43
  ?>
44
  </div>
45
  <?php endif; ?>
46
+ <?php if ( $a['show_lesson'] ): ?>
47
  <div class="course-lesson-number course-meta-field">
48
  <?php
49
  $lessons = sizeof( $course->get_lessons() );
51
  ?>
52
  </div>
53
  <?php endif; ?>
54
+ <?php if ( $a['show_teacher'] ): ?>
55
  <div class="course-meta-field">
56
  <?php echo $course->get_instructor_html(); ?>
57
  </div>
62
  <?php endforeach; ?>
63
  </div>
64
  <div class="widget-footer">
65
+ <?php if ( $a['bottom_link'] == 'all_course' ):
66
  $page_id = get_option( 'learn_press_courses_page_id' );
67
  $link = get_page_link( $page_id );
68
  $title = get_the_title( $page_id );
69
  ?>
70
  <a class="pull-right" href="<?php echo $link ?>">
71
+ <?php
72
+ echo( !empty( $a['bottom_link_text'] ) ? $a['bottom_link_text'] : $title );
73
+ ?>
74
  </a>
75
  <?php endif; ?>
76
  </div>
inc/widgets/recent-courses/templates/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden.
inc/widgets/recent-courses/tmpl/index.php DELETED
@@ -1,7 +0,0 @@
1
- <?php
2
- /**
3
- * Created by PhpStorm.
4
- * User: MinhMinh
5
- * Date: 2/24/2017
6
- * Time: 1:20 PM
7
- */
 
 
 
 
 
 
 
learnpress.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: LearnPress
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: 2.1.6.1
8
  Author URI: http://thimpress.com
9
  Requires at least: 3.8
10
  Tested up to: 4.7
@@ -308,6 +308,13 @@ if ( !class_exists( 'LearnPress' ) ) {
308
  }
309
  }
310
 
 
 
 
 
 
 
 
311
  /**
312
  * Get session object instance
313
  *
@@ -433,14 +440,13 @@ if ( !class_exists( 'LearnPress' ) ) {
433
  require_once( 'inc/admin/settings/class-lp-settings-base.php' );
434
  }
435
  $this->settings = LP_Settings::instance();
 
436
  require_once 'inc/class-lp-assets.php';
 
437
  require_once 'inc/question/abstract-lp-question.php';
438
  require_once 'inc/question/class-lp-question-factory.php';
439
- $this->include_post_types();
440
 
441
- if ( defined( 'LP_USE_ATTRIBUTES' ) && LP_USE_ATTRIBUTES ) {
442
- require_once 'inc/attributes/lp-attributes-functions.php';
443
- }
444
 
445
  // course
446
  require_once 'inc/course/lp-course-functions.php';
@@ -467,11 +473,10 @@ if ( !class_exists( 'LearnPress' ) ) {
467
  require_once 'inc/user/class-lp-user-factory.php';
468
  require_once 'inc/user/abstract-lp-user.php';
469
  require_once 'inc/user/class-lp-user.php';
470
- require_once 'inc/user/class-lp-profile.php';
471
-
472
 
473
  // others
474
  require_once 'inc/class-lp-session-handler.php';
 
475
  require_once 'inc/admin/class-lp-email.php';
476
  // assets
477
 
@@ -483,8 +488,19 @@ if ( !class_exists( 'LearnPress' ) ) {
483
 
484
  // shortcodes
485
  require_once 'inc/class-lp-shortcodes.php';
 
 
 
 
 
 
486
  }
487
 
 
 
 
 
 
488
  // include template functions
489
  require_once( 'inc/lp-template-functions.php' );
490
  require_once( 'inc/lp-template-hooks.php' );
@@ -502,9 +518,6 @@ if ( !class_exists( 'LearnPress' ) ) {
502
  require_once 'inc/class-lp-multi-language.php';
503
  require_once 'inc/class-lp-page-controller.php';
504
 
505
- // widgets
506
- LP_Widget::register( array( 'featured-courses', 'popular-courses', 'recent-courses' ) );
507
-
508
  $GLOBALS['lp_query'] = $this->query = new LP_Query();
509
 
510
  }
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: 2.1.4.2
8
  Author URI: http://thimpress.com
9
  Requires at least: 3.8
10
  Tested up to: 4.7
308
  }
309
  }
310
 
311
+ /**
312
+ * Init widgets
313
+ */
314
+ public function widgets_init() {
315
+ do_action( 'lp_widgets_init' );
316
+ }
317
+
318
  /**
319
  * Get session object instance
320
  *
440
  require_once( 'inc/admin/settings/class-lp-settings-base.php' );
441
  }
442
  $this->settings = LP_Settings::instance();
443
+ //if ( !is_admin() ) {
444
  require_once 'inc/class-lp-assets.php';
445
+ //}
446
  require_once 'inc/question/abstract-lp-question.php';
447
  require_once 'inc/question/class-lp-question-factory.php';
 
448
 
449
+ $this->include_post_types();
 
 
450
 
451
  // course
452
  require_once 'inc/course/lp-course-functions.php';
473
  require_once 'inc/user/class-lp-user-factory.php';
474
  require_once 'inc/user/abstract-lp-user.php';
475
  require_once 'inc/user/class-lp-user.php';
 
 
476
 
477
  // others
478
  require_once 'inc/class-lp-session-handler.php';
479
+ require_once 'inc/admin/class-lp-profile.php';
480
  require_once 'inc/admin/class-lp-email.php';
481
  // assets
482
 
488
 
489
  // shortcodes
490
  require_once 'inc/class-lp-shortcodes.php';
491
+ // Include short-code file
492
+ require_once 'inc/shortcodes/profile-page.php';
493
+ require_once 'inc/shortcodes/archive-courses.php';
494
+ require_once 'inc/shortcodes/recent-courses/recent-courses.php';
495
+ require_once 'inc/shortcodes/popular-courses/popular-courses.php';
496
+ require_once 'inc/shortcodes/featured-courses/featured-courses.php';
497
  }
498
 
499
+ //include widgets
500
+ require_once 'inc/widgets/recent-courses/recent-course-widget.php';
501
+ require_once 'inc/widgets/popular-courses/popular-course-widget.php';
502
+ require_once 'inc/widgets/featured-courses/featured-course-widget.php';
503
+
504
  // include template functions
505
  require_once( 'inc/lp-template-functions.php' );
506
  require_once( 'inc/lp-template-hooks.php' );
518
  require_once 'inc/class-lp-multi-language.php';
519
  require_once 'inc/class-lp-page-controller.php';
520
 
 
 
 
521
  $GLOBALS['lp_query'] = $this->query = new LP_Query();
522
 
523
  }
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === LearnPress - WordPress LMS Plugin ===
2
- Contributors: thimpress, tunnhn, phonglq.foobla, chinhtm, thongta, kendy73, leehld
3
  Donate link:
4
  Tags: WordPress LMS, LMS, eLearning, e-Learning, Learning Management System, LMS WordPress, Course, Courses, Quiz, Quizzes, Training, Guru, Sell Courses
5
  Requires at least: 3.8
6
  Tested up to: 4.7
7
- Stable tag: 2.1.6.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -16,13 +16,13 @@ A WordPress LMS Plugin to create WordPress Learning Management System. Turn your
16
 
17
  LearnPress is free and always be free, but it has premium high quality WordPress Plugin which will probably help you make money from your **WordPress based LMS**, try and see how it is. LearnPress WordPress Online Course plugin is lightweight but super powerful with lots of add-ons to empower its core system.
18
 
19
- > **Christmas & New Year Week Sale - 10 Days Left**
20
 
21
  > [Click here](http://eepurl.com/cbKSQX) to get a coupon for 25% Off all LearnPress Add-ons
22
 
23
- > Or you can [buy Education WP theme](http://themeforest.net/item/education-wordpress-theme-education-wp/14058034?utm_source=wporg&utm_medium=learnpressDC&ref=thimpress&utm_campaign=learnpress) for only 64$ and get all of them.
24
 
25
- > **HOT!!** [WordPress theme for Coaches, Trainers, Teachers - Coaching WP](https://themeforest.net/item/speaker-and-life-coach-wordpress-theme-coaching-wp/17097658?utm_source=wporg&utm_medium=learnpressDC&ref=thimpress&utm_campaign=learnpress) is also FOR SALE at only $59, LearnPress included.
26
 
27
  ###LMS & Education WordPress Themes###
28
 
@@ -193,43 +193,6 @@ https://www.transifex.com/projects/p/learnpress/
193
  8. Add-ons of LearnPress.
194
 
195
  == Changelog ==
196
- = 2.1.6.1 =
197
- + Removed cache-flush param
198
- + Added some filters for evaluating course results
199
- + Fixed js unreachable code
200
- + Fixed warning message on update post
201
-
202
- = 2.1.6 =
203
- + Add more options for course results
204
- + Made 'Show correct answer' option depending on 'Show/Hide questions'
205
- + Fixed process fields are added by filter for become a teacher form
206
- + Fixed wrong user profile url
207
- + Fixed user avatar can not save in profile
208
- + Remove related data after removing posts
209
-
210
- = 2.1.5.5 =
211
- + Fixed issue with slug of course page is the same with slug of course tab in profile
212
- + Fixed issue with metabox show/hide field
213
-
214
- = 2.1.5.4 =
215
- + Fixed code with old version of PHP
216
-
217
- = 2.1.5.3 =
218
- + Fixed a bug when using template_include filter
219
-
220
- = 2.1.5.2 =
221
- + Fixed some warning messaages
222
- + Fixed orders display missing in user profile
223
-
224
- = 2.1.5 =
225
- + Added feature allow creating an order for multi users
226
- + Added option to force an action can be triggered after updated order
227
- + Added hook for logout redirection
228
- + Improved emails system ( add emails: order status changed for user, course enrolled for admin, course updated for admin )
229
- + Improved sql queries performance
230
- + Fixed 'Preview' label can not click-able
231
- + Fixed option 'Show correct answer' does not work correctly
232
- + Re-added Recent/Popular/Featured widgets and shortcodes
233
 
234
  = 2.1.4.2 =
235
  + Fixed issue can not view lesson
1
  === LearnPress - WordPress LMS Plugin ===
2
+ Contributors: thimpress, tunnhn, phonglq.foobla, thongta, kendy73, leehld
3
  Donate link:
4
  Tags: WordPress LMS, LMS, eLearning, e-Learning, Learning Management System, LMS WordPress, Course, Courses, Quiz, Quizzes, Training, Guru, Sell Courses
5
  Requires at least: 3.8
6
  Tested up to: 4.7
7
+ Stable tag: 2.1.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
16
 
17
  LearnPress is free and always be free, but it has premium high quality WordPress Plugin which will probably help you make money from your **WordPress based LMS**, try and see how it is. LearnPress WordPress Online Course plugin is lightweight but super powerful with lots of add-ons to empower its core system.
18
 
19
+ > **Limited Time Discount - 10 Days Left**
20
 
21
  > [Click here](http://eepurl.com/cbKSQX) to get a coupon for 25% Off all LearnPress Add-ons
22
 
23
+ > Or you can [buy Education WP theme](http://themeforest.net/item/education-wordpress-theme-education-wp/14058034?utm_source=wporg&utm_medium=learnpressDC&ref=thimpress&utm_campaign=learnpress) for only 64$ and get all Learnpress Premium Add-ons.
24
 
25
+ > **HOT!!** [WordPress theme for Coaches, Trainers, Teachers - Coaching WP](https://themeforest.net/item/speaker-and-life-coach-wordpress-theme-coaching-wp/17097658?utm_source=wporg&utm_medium=learnpressDC&ref=thimpress&utm_campaign=learnpress) is also FOR SALE at only $49, Premium Learnpress Add-ons included.
26
 
27
  ###LMS & Education WordPress Themes###
28
 
193
  8. Add-ons of LearnPress.
194
 
195
  == Changelog ==
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
196
 
197
  = 2.1.4.2 =
198
  + Fixed issue can not view lesson
templates/content-archive-course.php CHANGED
@@ -10,7 +10,7 @@
10
  if ( !defined( 'ABSPATH' ) ) {
11
  exit; // Exit if accessed directly
12
  }
13
- global $post, $wp_query, $lp_tax_query;
14
  ?>
15
  <?php do_action( 'learn_press_before_main_content' ); ?>
16
 
10
  if ( !defined( 'ABSPATH' ) ) {
11
  exit; // Exit if accessed directly
12
  }
13
+ global $post, $wp_query;
14
  ?>
15
  <?php do_action( 'learn_press_before_main_content' ); ?>
16
 
templates/content-question/multi-choice/answer-options.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * @author ThimPress
6
  * @package LearnPress/Templates
7
- * @version 2.1.5
8
  */
9
 
10
  if ( !defined( 'ABSPATH' ) ) {
@@ -31,7 +31,7 @@ if ( $show_result && $completed ) {
31
  $answer_class = !$completed ? array( 'answer-option' ) : array( 'answer-option-result' );
32
 
33
  $disabled = '';
34
- if ( $completed && $show_result || $checked || $course_finished ) {
35
  $answer_correct = true;
36
  if ( $checked && $answer['is_true'] == 'yes' ) {
37
  $answer_class[] = 'answer-true';
@@ -44,13 +44,8 @@ if ( $show_result && $completed ) {
44
  }
45
  if ( !$answer_correct ) {
46
  $answer_class[] = 'user-answer-false';
47
- } else {
48
- if ( $answer['is_true'] == 'yes' ) {
49
- $answer_class[] = 'answer-true';
50
- }
51
  }
52
- $answer_class = array_filter( $answer_class );
53
- $disabled = ' disabled="disabled"';
54
  }
55
  ?>
56
  <li<?php echo $answer_class ? ' class="' . join( ' ', $answer_class ) . '"' : ''; ?>>
@@ -59,7 +54,7 @@ if ( $show_result && $completed ) {
59
 
60
  <label>
61
  <input type="checkbox" name="learn-press-question-<?php echo $this->id; ?>[]" <?php checked( $this->is_selected_option( $answer, $answered ) ); ?> value="<?php echo $answer['value']; ?>" <?php echo $disabled; ?> />
62
- <p class="auto-check-lines option-title"><?php echo apply_filters( 'learn_press_question_answer_text', $answer['text'], $answer, $this ); ?></p>
63
  </label>
64
 
65
  <?php do_action( 'learn_press_after_question_answer_text', $answer, $this ); ?>
4
  *
5
  * @author ThimPress
6
  * @package LearnPress/Templates
7
+ * @version 1.0
8
  */
9
 
10
  if ( !defined( 'ABSPATH' ) ) {
31
  $answer_class = !$completed ? array( 'answer-option' ) : array( 'answer-option-result' );
32
 
33
  $disabled = '';
34
+ if ( $completed && $show_result || $checked || $course_finished) {
35
  $answer_correct = true;
36
  if ( $checked && $answer['is_true'] == 'yes' ) {
37
  $answer_class[] = 'answer-true';
44
  }
45
  if ( !$answer_correct ) {
46
  $answer_class[] = 'user-answer-false';
 
 
 
 
47
  }
48
+ $disabled = ' disabled="disabled"';
 
49
  }
50
  ?>
51
  <li<?php echo $answer_class ? ' class="' . join( ' ', $answer_class ) . '"' : ''; ?>>
54
 
55
  <label>
56
  <input type="checkbox" name="learn-press-question-<?php echo $this->id; ?>[]" <?php checked( $this->is_selected_option( $answer, $answered ) ); ?> value="<?php echo $answer['value']; ?>" <?php echo $disabled; ?> />
57
+ <p class="auto-check-lines"><?php echo apply_filters( 'learn_press_question_answer_text', $answer['text'], $answer, $this ); ?></p>
58
  </label>
59
 
60
  <?php do_action( 'learn_press_after_question_answer_text', $answer, $this ); ?>
templates/content-question/single-choice/answer-options.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * @author ThimPress
6
  * @package LearnPress/Templates
7
- * @version 2.1.5
8
  */
9
 
10
  if ( !defined( 'ABSPATH' ) ) {
@@ -39,10 +39,6 @@ $course_finished = $user->has_finished_course( $course->id );
39
  }
40
  if ( !$answer_correct ) {
41
  $answer_class[] = 'user-answer-false';
42
- }else {
43
- if ( $answer['is_true'] == 'yes' ) {
44
- $answer_class[] = 'answer-true';
45
- }
46
  }
47
  $disabled = ' disabled="disabled"';
48
  }
@@ -52,7 +48,7 @@ $course_finished = $user->has_finished_course( $course->id );
52
  <?php do_action( 'learn_press_before_question_answer_text', $answer, $this ); ?>
53
  <label>
54
  <input type="radio" name="learn-press-question-<?php echo $this->id; ?>" <?php checked( $this->is_selected_option( $answer, $answered ) ); ?> value="<?php echo $answer['value']; ?>" <?php echo $disabled; ?>>
55
- <p class="auto-check-lines option-title"><?php echo apply_filters( 'learn_press_question_answer_text', $answer['text'], $answer, $this ); ?></p>
56
  </label>
57
 
58
  <?php do_action( 'learn_press_after_question_answer_text', $answer, $this ); ?>
4
  *
5
  * @author ThimPress
6
  * @package LearnPress/Templates
7
+ * @version 1.0
8
  */
9
 
10
  if ( !defined( 'ABSPATH' ) ) {
39
  }
40
  if ( !$answer_correct ) {
41
  $answer_class[] = 'user-answer-false';
 
 
 
 
42
  }
43
  $disabled = ' disabled="disabled"';
44
  }
48
  <?php do_action( 'learn_press_before_question_answer_text', $answer, $this ); ?>
49
  <label>
50
  <input type="radio" name="learn-press-question-<?php echo $this->id; ?>" <?php checked( $this->is_selected_option( $answer, $answered ) ); ?> value="<?php echo $answer['value']; ?>" <?php echo $disabled; ?>>
51
+ <p class="auto-check-lines"><?php echo apply_filters( 'learn_press_question_answer_text', $answer['text'], $answer, $this ); ?></p>
52
  </label>
53
 
54
  <?php do_action( 'learn_press_after_question_answer_text', $answer, $this ); ?>
templates/content-quiz/buttons.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * @author ThimPress
6
  * @package LearnPress/Templates
7
- * @version 2.1.6
8
  */
9
 
10
  if ( !defined( 'ABSPATH' ) ) {
@@ -18,11 +18,6 @@ if ( !$quiz ) {
18
  }
19
 
20
  if ( $user->has( 'finished-course', $course->id ) ) {
21
- //learn_press_display_message( __( 'You have already finished course but have not started this quiz.', 'learnpress' ) );
22
- return;
23
- }
24
-
25
- if ( !$quiz->has( 'questions' ) ) {
26
  return;
27
  }
28
 
4
  *
5
  * @author ThimPress
6
  * @package LearnPress/Templates
7
+ * @version 2.0.7
8
  */
9
 
10
  if ( !defined( 'ABSPATH' ) ) {
18
  }
19
 
20
  if ( $user->has( 'finished-course', $course->id ) ) {
 
 
 
 
 
21
  return;
22
  }
23
 
templates/content-single-course.php CHANGED
@@ -17,7 +17,6 @@ if ( post_password_required() ) {
17
  echo get_the_password_form();
18
  return;
19
  }
20
-
21
  ?>
22
  <?php do_action( 'learn_press_before_main_content' ); ?>
23
 
17
  echo get_the_password_form();
18
  return;
19
  }
 
20
  ?>
21
  <?php do_action( 'learn_press_before_main_content' ); ?>
22
 
templates/emails/enrolled-course-admin.php DELETED
@@ -1,17 +0,0 @@
1
- {{header}}
2
-
3
- <p>
4
- Course Name: {{course_name}}
5
- </p>
6
- <p>
7
- Course Author: {{user_name}}
8
- </p>
9
- <p>
10
- Visit: <a href="{{course_url}}">{{course_name}}</a>
11
- </p>
12
-
13
- <p> This course has been enrolled by {{custom_name}} at {{start_time}}. </p>
14
-
15
- <p>Please <a href="{{login_url}}">login</a> and check again!</p>
16
-
17
- {{footer}}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
templates/emails/plain/enrolled-course-admin.php DELETED
@@ -1,13 +0,0 @@
1
- == {{email_heading}} ==
2
-
3
- Course Name: {{course_name}}
4
-
5
- Course Author: {{user_name}}
6
-
7
- Visit: {{course_url}}
8
-
9
- This course has been enrolled by {{custom_name}} at {{start_time}}.
10
-
11
- Please login {{login_url}} and check again!
12
-
13
- {{footer_text}}
 
 
 
 
 
 
 
 
 
 
 
 
 
templates/emails/plain/update-course.php DELETED
@@ -1,7 +0,0 @@
1
- == {{email_heading}} ==
2
-
3
- "{{course_url}}" ({{course_name}}) has just been updated.
4
-
5
- Please login {{login_url}} and start learning now.
6
-
7
- {{footer_text}}
 
 
 
 
 
 
 
templates/emails/plain/user-order-changed-status.php DELETED
@@ -1,9 +0,0 @@
1
- == {{email_heading}} ==
2
-
3
- {{order_items_table}}
4
-
5
- Your order has just changed status to <strong>{{order_status}}</strong>
6
-
7
- View order: {{order_detail_url}}
8
-
9
- {{footer_text}}
 
 
 
 
 
 
 
 
 
templates/emails/update-course.php DELETED
@@ -1,7 +0,0 @@
1
- {{header}}
2
-
3
- <p><a href="{{course_url}}">{{course_name}}</a> has just updated.</p>
4
-
5
- <p>Please <a href="{{login_url}}">login</a> and start learning now.</p>
6
-
7
- {{footer}}
 
 
 
 
 
 
 
templates/emails/user-order-changed-status.php DELETED
@@ -1,9 +0,0 @@
1
- {{header}}
2
-
3
- {{order_items_table}}
4
-
5
- Your order has just changed status to <strong>{{order_status}}</strong>
6
-
7
- <p>View order: <a href="{{order_detail_url}}">{{order_number}}</a></p>
8
-
9
- {{footer}}
 
 
 
 
 
 
 
 
 
templates/global/become-teacher-form.php CHANGED
@@ -13,10 +13,7 @@ $submit_button_process_text = __( 'Submitting...', 'learnpress' );
13
  $submit_button_text = __( 'Submit', 'learnpress' );
14
  ?>
15
  <div id="learn-press-become-teacher-form" class="learn-press-become-teacher-form">
16
- <?php if( $message ) {
17
- learn_press_display_message( $message );
18
- }
19
- ?>
20
  <?php if ( !learn_press_become_teacher_sent() ): ?>
21
  <form id="<?php echo $form_id; ?>" name="become-teacher-form" method="<?php echo $method; ?>" enctype="multipart/form-data" action="<?php echo $action; ?>">
22
  <?php if ( $fields ): ?>
@@ -63,4 +60,4 @@ $submit_button_text = __( 'Submit', 'learnpress' );
63
  <?php endif; ?>
64
  </form>
65
  <?php endif; ?>
66
- </div>
13
  $submit_button_text = __( 'Submit', 'learnpress' );
14
  ?>
15
  <div id="learn-press-become-teacher-form" class="learn-press-become-teacher-form">
16
+ <?php learn_press_display_message( $message ); ?>
 
 
 
17
  <?php if ( !learn_press_become_teacher_sent() ): ?>
18
  <form id="<?php echo $form_id; ?>" name="become-teacher-form" method="<?php echo $method; ?>" enctype="multipart/form-data" action="<?php echo $action; ?>">
19
  <?php if ( $fields ): ?>
60
  <?php endif; ?>
61
  </form>
62
  <?php endif; ?>
63
+ </div>
templates/global/before-main-content.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * @author ThimPress
4
  * @package LearnPress/Templates
5
- * @version 2.1.5
6
  */
7
  if ( !defined( 'ABSPATH' ) ) {
8
  exit; // Exit if accessed directly
2
  /**
3
  * @author ThimPress
4
  * @package LearnPress/Templates
5
+ * @version 1.0
6
  */
7
  if ( !defined( 'ABSPATH' ) ) {
8
  exit; // Exit if accessed directly
templates/order/order-details.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * @author ThimPress
4
  * @package LearnPress/Templates
5
- * @version 2.1.4.2
6
  */
7
 
8
  if ( !defined( 'ABSPATH' ) ) {
2
  /**
3
  * @author ThimPress
4
  * @package LearnPress/Templates
5
+ * @version 1.0
6
  */
7
 
8
  if ( !defined( 'ABSPATH' ) ) {
templates/profile/tabs.php CHANGED
@@ -20,7 +20,13 @@ $current = learn_press_get_current_profile_tab();
20
  }
21
  ?>
22
  <li class="<?php echo esc_attr( $key ); ?>_tab<?php echo $current == $key ? ' current' : ''; ?>">
23
- <?php
 
 
 
 
 
 
24
  $link = learn_press_user_profile_link( $user->id, $key );
25
  ?>
26
  <a href="<?php echo esc_url( $link ); ?>" data-slug="<?php echo esc_attr( $link ); ?>"><?php echo apply_filters( 'learn_press_profile_' . $key . '_tab_title', esc_html( $tab['title'] ), $key ); ?></a>
20
  }
21
  ?>
22
  <li class="<?php echo esc_attr( $key ); ?>_tab<?php echo $current == $key ? ' current' : ''; ?>">
23
+ <?php /*
24
+ <?php if ( get_option( 'permalink_structure' ) ) : ?>
25
+
26
+ <?php else: ?>
27
+ <a href="<?php echo add_query_arg( array( 'user' => $user->user_login, 'tab' => $key ), learn_press_get_page_link( 'profile' ) ); ?>" data-slug="<?php echo add_query_arg( '', '', learn_press_get_page_link( 'profile' ) . $user->user_login ) . '/' . $key; ?>"><?php echo apply_filters( 'learn_press_profile_' . $key . '_tab_title', esc_html( $tab['title'] ), $key ); ?></a>
28
+ <?php endif; ?>
29
+ */
30
  $link = learn_press_user_profile_link( $user->id, $key );
31
  ?>
32
  <a href="<?php echo esc_url( $link ); ?>" data-slug="<?php echo esc_attr( $link ); ?>"><?php echo apply_filters( 'learn_press_profile_' . $key . '_tab_title', esc_html( $tab['title'] ), $key ); ?></a>
templates/profile/tabs/courses/all.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * User Courses enrolled
4
+ *
5
+ * @author ThimPress
6
+ * @package LearnPress/Templates
7
+ * @version 2.0
8
+ */
9
+
10
+
11
+ if ( !defined( 'ABSPATH' ) ) {
12
+ exit;
13
+ }
14
+ /*
15
+
16
+ global $post, $wp;
17
+ $heading = apply_filters( 'learn_press_profile_tab_courses_enrolled_heading', false );
18
+ ?>
19
+
20
+ <?php if ( $heading ): ?>
21
+
22
+ <h4 class="profile-courses-heading"><?php echo $heading; ?></h4>
23
+
24
+ <?php endif; ?>
25
+
26
+ <?php if ( $courses ) : ?>
27
+
28
+ <ul class="learn-press-courses profile-courses courses-list enrolled">
29
+
30
+ <?php foreach ( $courses as $post ) {
31
+ setup_postdata( $post );
32
+ ?>
33
+
34
+ <?php learn_press_get_template( 'profile/tabs/courses/loop.php', array( 'subtab' => 'all', 'user' => $user, 'course_id' => $post->ID ) ); ?>
35
+
36
+ <?php } ?>
37
+ </ul>
38
+
39
+ <?php learn_press_paging_nav( array( 'num_pages' => $num_pages ) ); ?>
40
+ <?php else: ?>
41
+
42
+ <?php learn_press_display_message( __( 'You haven\'t got any courses yet!', 'learnpress' ) ); ?>
43
+
44
+ <?php endif ?>
45
+
46
+ <?php wp_reset_postdata(); // do not forget to call this function here! ?>
47
+
48
+ */
templates/profile/tabs/courses/finished.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * User Courses finished
4
+ *
5
+ * @author ThimPress
6
+ * @package LearnPress/Templates
7
+ * @version 2.0
8
+ */
9
+
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ exit;
12
+ }
13
+ /*
14
+
15
+ global $post;
16
+ $heading = apply_filters( 'learn_press_profile_tab_courses_finished_heading', false );
17
+ ?>
18
+
19
+ <?php if ( $heading ): ?>
20
+
21
+ <h4 class="profile-courses-heading"><?php echo $heading; ?></h4>
22
+
23
+ <?php endif; ?>
24
+
25
+ <?php if ( $courses ) : ?>
26
+
27
+ <ul class="learn-press-courses profile-courses courses-list enrolled">
28
+
29
+ <?php foreach ( $courses as $post ): setup_postdata( $post ); ?>
30
+ <?php setup_postdata( $post ); ?>
31
+ <?php learn_press_get_template( 'profile/tabs/courses/loop.php', array( 'subtab' => 'finished', 'user' => $user, 'course_id' => $post->ID ) ); ?>
32
+
33
+ <?php endforeach; ?>
34
+ </ul>
35
+ <?php learn_press_paging_nav( array( 'num_pages' => $num_pages ) ); ?>
36
+
37
+ <?php else: ?>
38
+
39
+ <?php learn_press_display_message( __( 'You haven\'t finished any courses yet!', 'learnpress' ) ); ?>
40
+
41
+ <?php endif ?>
42
+
43
+ <?php wp_reset_postdata(); // do not forget to call this function here! ?>
44
+ */
templates/profile/tabs/courses/learning.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * User Courses enrolled
4
+ *
5
+ * @author ThimPress
6
+ * @package LearnPress/Templates
7
+ * @version 2.0
8
+ */
9
+
10
+ if ( !defined( 'ABSPATH' ) ) {
11
+ exit;
12
+ }
13
+ /*
14
+
15
+ global $post;
16
+ $heading = apply_filters( 'learn_press_profile_tab_courses_learning_heading', false );
17
+ ?>
18
+
19
+ <?php if ( $heading ): ?>
20
+
21
+ <h4 class="profile-courses-heading"><?php echo $heading; ?></h4>
22
+
23
+ <?php endif; ?>
24
+
25
+ <?php if ( $courses ) : ?>
26
+
27
+ <ul class="learn-press-courses profile-courses courses-list enrolled">
28
+
29
+ <?php foreach( $courses as $post ){ setup_postdata( $post );?>
30
+ <?php setup_postdata( $post ); ?>
31
+ <?php learn_press_get_template( 'profile/tabs/courses/loop.php', array( 'subtab' => 'learning', 'user' => $user, 'course_id' => $post->ID ) ); ?>
32
+
33
+ <?php } ?>
34
+ </ul>
35
+ <?php learn_press_paging_nav( array( 'num_pages' => $num_pages ) ); ?>
36
+
37
+ <?php else: ?>
38
+
39
+ <?php learn_press_display_message( __( 'You haven\'t got any learning courses yet!', 'learnpress' ) ); ?>
40
+
41
+ <?php endif ?>
42
+
43
+ <?php wp_reset_postdata(); // do not forget to call this function here! ?>
44
+
45
+ */
templates/profile/tabs/courses/loop.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * @author ThimPress
6
  * @package LearnPress/Templates
7
- * @version 2.1.4.2
8
  */
9
 
10
  if ( !defined( 'ABSPATH' ) ) {
4
  *
5
  * @author ThimPress
6
  * @package LearnPress/Templates
7
+ * @version 2.x
8
  */
9
 
10
  if ( !defined( 'ABSPATH' ) ) {
templates/profile/tabs/courses/own.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * User Courses own
4
+ *
5
+ * @author ThimPress
6
+ * @package LearnPress/Templates
7
+ * @version 2.0
8
+ */
9
+
10
+
11
+ if ( !defined( 'ABSPATH' ) ) {
12
+ exit;
13
+ }
14
+ /*
15
+ global $post, $wp;
16
+ $heading = apply_filters( 'learn_press_profile_tab_courses_own_heading', false );
17
+ $paged = !empty( $_REQUEST['section'] ) && $_REQUEST['section'] == $subtab ? get_query_var( 'paged' ) : 1;
18
+ ?>
19
+
20
+ <?php if ( $heading ): ?>
21
+
22
+ <h4 class="profile-courses-heading"><?php echo $heading; ?></h4>
23
+
24
+ <?php endif; ?>
25
+
26
+ <?php if ( $courses ) : ?>
27
+
28
+ <ul class="learn-press-courses profile-courses courses-list own">
29
+
30
+ <?php foreach ( $courses as $post ): ?>
31
+ <?php setup_postdata( $post ); ?>
32
+ <?php learn_press_get_template( 'profile/tabs/courses/loop.php', array( 'subtab' => 'own', 'user' => $user, 'course_id' => $post->ID ) ); ?>
33
+
34
+
35
+ <?php endforeach; ?>
36
+
37
+ </ul>
38
+ <?php
39
+ learn_press_paging_nav(
40
+ array(
41
+ 'num_pages' => $num_pages,
42
+ 'paged' => $paged,
43
+ //'base' => add_query_arg( array( 'section' => $subtab ), learn_press_user_profile_link( $user->id, learn_press_get_current_profile_tab() ) )
44
+ )
45
+ );
46
+ ?>
47
+
48
+ <?php else: ?>
49
+
50
+ <?php learn_press_display_message( __( 'You haven\'t got any published courses yet!', 'learnpress' ) ); ?>
51
+
52
+ <?php endif ?>
53
+
54
+ <?php wp_reset_postdata(); // do not forget to call this function here! ?>
55
+ */
templates/profile/tabs/courses/purchased.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * User Courses purchased
4
+ *
5
+ * @author ThimPress
6
+ * @package LearnPress/Templates
7
+ * @version 2.0
8
+ */
9
+
10
+ if ( !defined( 'ABSPATH' ) ) {
11
+ exit;
12
+ }
13
+ /*
14
+
15
+ global $post;
16
+ $heading = apply_filters( 'learn_press_profile_tab_courses_purchased_heading', false );
17
+ ?>
18
+
19
+ <?php if ( $heading ): ?>
20
+
21
+ <h4 class="profile-courses-heading"><?php echo $heading; ?></h4>
22
+
23
+ <?php endif; ?>
24
+
25
+ <?php if ( $courses ) : ?>
26
+
27
+ <ul class="learn-press-courses profile-courses courses-list enrolled">
28
+
29
+ <?php foreach ( $courses as $post ): setup_postdata( $post ); ?>
30
+ <?php setup_postdata( $post ); ?>
31
+ <?php learn_press_get_template( 'profile/tabs/courses/loop.php', array( 'subtab' => 'purchased', 'user' => $user, 'course_id' => $post->ID ) ); ?>
32
+
33
+ <?php endforeach; ?>
34
+ </ul>
35
+ <?php learn_press_paging_nav( array( 'num_pages' => $num_pages ) ); ?>
36
+
37
+ <?php else: ?>
38
+
39
+ <?php learn_press_display_message( __( 'You haven\'t purchased any courses yet!', 'learnpress' ) ); ?>
40
+
41
+ <?php endif ?>
42
+
43
+ <?php wp_reset_postdata(); // do not forget to call this function here! ?>
44
+ */
templates/profile/tabs/edit.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * @author ThimPress
6
  * @package LearnPress/Templates
7
- * @version 2.1.6
8
  */
9
  if ( !defined( 'ABSPATH' ) ) {
10
  exit;
@@ -49,16 +49,8 @@ $first_tab = 'basic-information';
49
  <?php endforeach; ?>
50
  </ul>
51
  <div class="learn-press-subtab-content user-profile-section-content">
52
- <?php
53
- $section_template = learn_press_locate_template( 'profile/tabs/edit/' . $section . '.php' );
54
- if ( $section && file_exists( $section_template ) ) {
55
- ?>
56
- <?php include $section_template; ?>
57
- <input type="hidden" name="lp-profile-section" value="<?php echo $section; ?>" />
58
- <?php } else {
59
- ?>
60
- <?php learn_press_display_message( __( 'The section you are trying to access does not exists.', 'learnpress' ) ); ?>
61
- <?php } ?>
62
  </div>
63
 
64
  <input type="hidden" name="user_id" id="user_id" value="<?php echo esc_attr( $user->id ); ?>" />
4
  *
5
  * @author ThimPress
6
  * @package LearnPress/Templates
7
+ * @version 2.1.1
8
  */
9
  if ( !defined( 'ABSPATH' ) ) {
10
  exit;
49
  <?php endforeach; ?>
50
  </ul>
51
  <div class="learn-press-subtab-content user-profile-section-content">
52
+ <?php include learn_press_locate_template( 'profile/tabs/edit/' . $section . '.php' ); ?>
53
+ <input type="hidden" name="lp-profile-section" value="<?php echo $section; ?>" />
 
 
 
 
 
 
 
 
54
  </div>
55
 
56
  <input type="hidden" name="user_id" id="user_id" value="<?php echo esc_attr( $user->id ); ?>" />
templates/profile/tabs/orders.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * @author ThimPress
6
  * @package LearnPress/Template
7
- * @version x.x
8
  */
9
  defined( 'ABSPATH' ) || exit();
10
 
@@ -32,7 +32,7 @@ if ( $orders = _learn_press_get_user_profile_orders( $user_id, $page, $limit ) )
32
  <td><?php echo $order->get_order_number(); ?></td>
33
  <td><?php echo date_i18n( get_option( 'date_format' ), strtotime( $order->order_date ) ); ?></td>
34
  <td>
35
- <?php echo $order->get_order_status_html(); ?>
36
  <?php
37
  if ( $order->has_status( 'pending' ) ) :
38
  printf( '(<small><a href="%s" class="%s">%s</a></small>)', $order->get_cancel_order_url(), 'cancel-order', __( 'Cancel', 'learnpress' ) );
4
  *
5
  * @author ThimPress
6
  * @package LearnPress/Template
7
+ * @version 1.0
8
  */
9
  defined( 'ABSPATH' ) || exit();
10
 
32
  <td><?php echo $order->get_order_number(); ?></td>
33
  <td><?php echo date_i18n( get_option( 'date_format' ), strtotime( $order->order_date ) ); ?></td>
34
  <td>
35
+ <?php echo $order->get_order_status(); ?>
36
  <?php
37
  if ( $order->has_status( 'pending' ) ) :
38
  printf( '(<small><a href="%s" class="%s">%s</a></small>)', $order->get_cancel_order_url(), 'cancel-order', __( 'Cancel', 'learnpress' ) );
templates/single-course/buttons.php CHANGED
@@ -4,87 +4,117 @@
4
  *
5
  * @author ThimPress
6
  * @package LearnPress/Templates
7
- * @version 2.1.6
8
  */
9
 
10
- if ( !defined( 'ABSPATH' ) ) {
11
  exit; // Exit if accessed directly
12
  }
13
 
14
  $course = LP()->global['course'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  ?>
16
  <div class="learn-press-course-buttons">
 
17
  <?php do_action( 'learn_press_before_course_buttons', $course->id ); ?>
 
18
  <?php
19
- if ( $external_link = $course->get_external_link() ):
20
- $external_button_text = apply_filters( 'learn_press_course_external_link_button_text', __( 'Buy this course', 'learnpress' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  ?>
22
- <?php do_action( 'learn_press_before_external_link_buy_course' ); ?>
23
- <div class="purchase-course">
24
- <a href="<?php echo esc_url( $external_link ); ?>" class="purchase-button">
25
- <?php echo $external_button_text; ?>
26
- </a>
27
- </div>
28
- <?php do_action( 'learn_press_after_external_link_buy_course' ); ?>
29
- <?php else:
30
-
31
- if ( $course->is_required_enroll() ) {
32
-
33
-
34
- $course_status = learn_press_get_user_course_status();
35
- $user = learn_press_get_current_user();
36
- $in_cart = learn_press_is_added_to_cart( $course->id );
37
- // only show enroll button if user had not enrolled
38
- $purchase_button_text = apply_filters( 'learn_press_purchase_button_text', __( 'Buy this course', 'learnpress' ) );
39
- $enroll_button_text = apply_filters( 'learn_press_enroll_button_text', __( 'Enroll', 'learnpress' ) );
40
- $retake_button_text = apply_filters( 'learn_press_retake_button_text', __( 'Retake', 'learnpress' ) );
41
- $notice_enough_student = apply_filters( 'learn_press_course enough students_notice', __( 'The class is full so the enrollment is close. Please contact the site admin.', 'learnpress' ) );
42
-
43
- # -------------------------------
44
- # Finished Course
45
- # -------------------------------
46
- if ( $user->has( 'finished-course', $course->id ) ): ?>
47
- <?php if ( $count = $user->can( 'retake-course', $course->id ) ): ?>
48
- <button
49
- class="button button-retake-course"
50
- data-course_id="<?php echo esc_attr( $course->id ); ?>"
51
- data-security="<?php echo esc_attr( wp_create_nonce( sprintf( 'learn-press-retake-course-%d-%d', $course->id, $user->id ) ) ); ?>">
52
- <?php echo esc_html( sprintf( __( 'Retake course (+%d)', 'learnpress' ), $count ) ); ?>
53
- </button>
54
- <?php endif; ?>
55
- <?php
56
-
57
- # -------------------------------
58
- # Enrolled Course
59
- # -------------------------------
60
- elseif ( $user->has( 'enrolled-course', $course->id ) ): ?>
61
- <?php
62
- $can_finish = $user->can_finish_course( $course->id );
63
- //if ( $can_finish ) {
64
- $finish_course_security = wp_create_nonce( sprintf( 'learn-press-finish-course-' . $course->id . '-' . $user->id ) );
65
- //} else {
66
- //$finish_course_security = '';
67
- //}
68
- ?>
69
- <button
70
- id="learn-press-finish-course"
71
- class="button-finish-course<?php echo !$can_finish ? ' hide-if-js' : ''; ?>"
72
- data-id="<?php echo esc_attr( $course->id ); ?>"
73
- data-security="<?php echo esc_attr( $finish_course_security ); ?>">
74
- <?php esc_html_e( 'Finish course', 'learnpress' ); ?>
75
  </button>
76
- <?php elseif ( $user->can( 'enroll-course', $course->id ) === true ) : ?>
77
- <form name="enroll-course" class="enroll-course" method="post" enctype="multipart/form-data">
78
- <?php do_action( 'learn_press_before_enroll_button' ); ?>
 
 
 
 
 
 
 
 
 
79
 
80
- <input type="hidden" name="lp-ajax" value="enroll-course" />
81
- <input type="hidden" name="enroll-course" value="<?php echo $course->id; ?>" />
82
- <button class="button enroll-button" data-block-content="yes"><?php echo $enroll_button_text; ?></button>
83
 
84
- <?php do_action( 'learn_press_after_enroll_button' ); ?>
85
- </form>
86
- <?php elseif ( $user->can( 'purchase-course', $course->id ) ) : ?>
87
 
 
88
  <form name="purchase-course" class="purchase-course" method="post" enctype="multipart/form-data">
89
  <?php do_action( 'learn_press_before_purchase_button' ); ?>
90
  <button class="button purchase-button" data-block-content="yes">
@@ -92,32 +122,24 @@ $course = LP()->global['course'];
92
  </button>
93
  <?php do_action( 'learn_press_after_purchase_button' ); ?>
94
  <input type="hidden" name="purchase-course" value="<?php echo $course->id; ?>" />
95
- <input type="hidden" value="user can purchase course" />
96
  </form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
 
98
- <?php elseif ( $user->can( 'enroll-course', $course->id ) === 'enough' ) : ?>
99
- <p class="learn-press-message"><?php echo $notice_enough_student; ?></p>
100
- <?php else: ?>
101
- <?php $order_status = $user->get_order_status( $course->id ); ?>
102
- <?php if ( in_array( $order_status, array( 'lp-pending', 'lp-refunded', 'lp-cancelled', 'lp-failed' ) ) ) { ?>
103
- <form name="purchase-course" class="purchase-course" method="post" enctype="multipart/form-data">
104
- <?php do_action( 'learn_press_before_purchase_button' ); ?>
105
- <button class="button purchase-button" data-block-content="yes">
106
- <?php echo $course->is_free() ? $enroll_button_text : $purchase_button_text; ?>
107
- </button>
108
- <?php do_action( 'learn_press_after_purchase_button' ); ?>
109
- <input type="hidden" name="purchase-course" value="<?php echo $course->id; ?>" />
110
- <input type="hidden" value="user order cancelled" />
111
-
112
- </form>
113
- <?php } elseif ( in_array( $order_status, array( 'lp-processing', 'lp-on-hold' ) ) ) { ?>
114
- <?php learn_press_display_message( '<p>' . apply_filters( 'learn_press_user_course_pending_message', __( 'You have purchased this course. Please wait for approval.', 'learnpress' ), $course, $user ) . '</p>' ); ?>
115
- <?php } elseif ( $order_status && $order_status != 'lp-completed' ) { ?>
116
- <?php learn_press_display_message( '<p>' . apply_filters( 'learn_press_user_can_not_purchase_course_message', __( 'Sorry, you can not purchase this course', 'learnpress' ), $course, $user ) . '</p>' ); ?>
117
- <?php } ?>
118
- <?php endif;
119
- }
120
- endif;
121
- ?>
122
  <?php do_action( 'learn_press_after_course_buttons', $course->id ); ?>
 
123
  </div>
4
  *
5
  * @author ThimPress
6
  * @package LearnPress/Templates
7
+ * @version 2.0.6
8
  */
9
 
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
  exit; // Exit if accessed directly
12
  }
13
 
14
  $course = LP()->global['course'];
15
+
16
+ if ( ! $course->is_required_enroll() ) {
17
+ return;
18
+ }
19
+
20
+ $course_status = learn_press_get_user_course_status();
21
+ $user = learn_press_get_current_user();
22
+ $in_cart = learn_press_is_added_to_cart( $course->id );
23
+ // only show enroll button if user had not enrolled
24
+ $purchase_button_text = apply_filters( 'learn_press_purchase_button_text', __( 'Buy this course', 'learnpress' ) );
25
+ $enroll_button_text = apply_filters( 'learn_press_enroll_button_text', __( 'Enroll', 'learnpress' ) );
26
+ $retake_button_text = apply_filters( 'learn_press_retake_button_text', __( 'Retake', 'learnpress' ) );
27
+ $notice_enough_student = apply_filters( 'learn_press_course enough students_notice', __( 'The class is full so the enrollment is close. Please contact the site admin.', 'learnpress' ) );
28
+ $external_link_buy_course = apply_filters( 'learn_press_external_link_buy_course', $course->external_link_buy_course, $course, $user );
29
  ?>
30
  <div class="learn-press-course-buttons">
31
+
32
  <?php do_action( 'learn_press_before_course_buttons', $course->id ); ?>
33
+
34
  <?php
35
+
36
+ # -------------------------------
37
+ # Finished Course
38
+ # -------------------------------
39
+ if ( $user->has( 'finished-course', $course->id ) ): ?>
40
+ <?php if ( $count = $user->can( 'retake-course', $course->id ) ): ?>
41
+ <button
42
+ class="button button-retake-course"
43
+ data-course_id="<?php echo esc_attr( $course->id ); ?>"
44
+ data-security="<?php echo esc_attr( wp_create_nonce( sprintf( 'learn-press-retake-course-%d-%d', $course->id, $user->id ) ) ); ?>">
45
+ <?php echo esc_html( sprintf( __( 'Retake course (+%d)', 'learnpress' ), $count ) ); ?>
46
+ </button>
47
+ <?php endif; ?>
48
+ <?php
49
+
50
+ # -------------------------------
51
+ # Enrolled Course
52
+ # -------------------------------
53
+ elseif ( $user->has( 'enrolled-course', $course->id ) ): ?>
54
+ <?php
55
+ $can_finish = $user->can_finish_course( $course->id );
56
+ //if ( $can_finish ) {
57
+ $finish_course_security = wp_create_nonce( sprintf( 'learn-press-finish-course-' . $course->id . '-' . $user->id ) );
58
+ //} else {
59
+ //$finish_course_security = '';
60
+ //}
61
  ?>
62
+ <button
63
+ id="learn-press-finish-course"
64
+ class="button-finish-course<?php echo ! $can_finish ? ' hide-if-js' : ''; ?>"
65
+ data-id="<?php echo esc_attr( $course->id ); ?>"
66
+ data-security="<?php echo esc_attr( $finish_course_security ); ?>">
67
+ <?php esc_html_e( 'Finish course', 'learnpress' ); ?>
68
+ </button>
69
+ <?php elseif ( $user->can( 'enroll-course', $course->id ) === true ) : ?>
70
+ <?php if ( !empty( $external_link_buy_course ) && $user->can( 'purchase-course', $course->id ) ) : ?>
71
+ <?php do_action( 'learn_press_before_external_link_buy_course' ); ?>
72
+ <div class="purchase-course">
73
+ <a href="<?php echo esc_url($external_link_buy_course); ?>" class="button purchase-button">
74
+ <?php echo $purchase_button_text; ?>
75
+ </a>
76
+ </div>
77
+ <?php do_action( 'learn_press_after_external_link_buy_course' ); ?>
78
+ <?php else : ?>
79
+ <form name="enroll-course" class="enroll-course" method="post" enctype="multipart/form-data">
80
+ <?php do_action( 'learn_press_before_enroll_button' ); ?>
81
+
82
+ <input type="hidden" name="lp-ajax" value="enroll-course" />
83
+ <input type="hidden" name="enroll-course" value="<?php echo $course->id; ?>" />
84
+ <button class="button enroll-button" data-block-content="yes"><?php echo $enroll_button_text; ?></button>
85
+
86
+ <?php do_action( 'learn_press_after_enroll_button' ); ?>
87
+ </form>
88
+ <?php endif; ?>
89
+ <?php elseif ( $user->can( 'purchase-course', $course->id ) ) : ?>
90
+
91
+ <?php if ( empty( $external_link_buy_course ) ) : ?>
92
+ <form name="purchase-course" class="purchase-course" method="post" enctype="multipart/form-data">
93
+ <?php do_action( 'learn_press_before_purchase_button' ); ?>
94
+ <button class="button purchase-button" data-block-content="yes">
95
+ <?php echo $course->is_free() ? $enroll_button_text : $purchase_button_text; ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  </button>
97
+ <?php do_action( 'learn_press_after_purchase_button' ); ?>
98
+ <input type="hidden" name="purchase-course" value="<?php echo $course->id; ?>" />
99
+ </form>
100
+ <?php else : ?>
101
+ <?php do_action( 'learn_press_before_external_link_buy_course' ); ?>
102
+ <div class="purchase-course">
103
+ <a href="<?php echo esc_url($external_link_buy_course); ?>" class="button purchase-button">
104
+ <?php echo $purchase_button_text; ?>
105
+ </a>
106
+ </div>
107
+ <?php do_action( 'learn_press_after_external_link_buy_course' ); ?>
108
+ <?php endif; ?>
109
 
110
+ <?php elseif ( $user->can( 'enroll-course', $course->id ) === 'enough' ) : ?>
111
+ <p class="learn-press-message"><?php echo $notice_enough_student; ?></p>
 
112
 
113
+ <?php else: ?>
114
+ <?php $order_status = $user->get_order_status( $course->id ); ?>
115
+ <?php if ( in_array( $order_status, array( 'lp-pending', 'lp-refunded', 'lp-cancelled', 'lp-failed' ) ) ) { ?>
116
 
117
+ <?php if ( empty( $external_link_buy_course ) ) : ?>
118
  <form name="purchase-course" class="purchase-course" method="post" enctype="multipart/form-data">
119
  <?php do_action( 'learn_press_before_purchase_button' ); ?>
120
  <button class="button purchase-button" data-block-content="yes">
122
  </button>
123
  <?php do_action( 'learn_press_after_purchase_button' ); ?>
124
  <input type="hidden" name="purchase-course" value="<?php echo $course->id; ?>" />
 
125
  </form>
126
+ <?php else : ?>
127
+ <?php do_action( 'learn_press_before_external_link_buy_course' ); ?>
128
+ <div class="purchase-course">
129
+ <a href="<?php echo esc_url($external_link_buy_course); ?>" class="button purchase-button">
130
+ <?php echo $purchase_button_text; ?>
131
+ </a>
132
+ </div>
133
+ <?php do_action( 'learn_press_after_external_link_buy_course' ); ?>
134
+ <?php endif; ?>
135
+
136
+ <?php } elseif ( in_array( $order_status, array( 'lp-processing', 'lp-on-hold' ) ) ) { ?>
137
+ <?php learn_press_display_message( '<p>' . apply_filters( 'learn_press_user_course_pending_message', __( 'You have purchased this course. Please wait for approval.', 'learnpress' ), $course, $user ) . '</p>' ); ?>
138
+ <?php } elseif ( $order_status && $order_status != 'lp-completed' ) { ?>
139
+ <?php learn_press_display_message( '<p>' . apply_filters( 'learn_press_user_can_not_purchase_course_message', __( 'Sorry, you can not purchase this course', 'learnpress' ), $course, $user ) . '</p>' ); ?>
140
+ <?php } ?>
141
+ <?php endif; ?>
142
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
  <?php do_action( 'learn_press_after_course_buttons', $course->id ); ?>
144
+
145
  </div>
templates/single-course/content-item-lp_lesson.php CHANGED
@@ -67,6 +67,7 @@ $can_view_item = $user->can( 'view-item', $item->id, $course->id );
67
  </form>
68
  <?php } ?>
69
 
 
70
  </div>
71
  <?php LP_Assets::enqueue_script( 'learn-press-course-lesson' ); ?>
72
 
67
  </form>
68
  <?php } ?>
69
 
70
+ <?php learn_press_lesson_comment_form( $item->id ); ?>
71
  </div>
72
  <?php LP_Assets::enqueue_script( 'learn-press-course-lesson' ); ?>
73
 
templates/single-course/content-item-only.php CHANGED
@@ -28,6 +28,7 @@ if ( !empty( $_REQUEST['done-action'] ) ) {
28
  }
29
  }
30
  $data = array_merge( $user->get_course_info2( get_the_ID() ), $data );
 
31
  ?>
32
  <style type="text/css">
33
  html{
28
  }
29
  }
30
  $data = array_merge( $user->get_course_info2( get_the_ID() ), $data );
31
+
32
  ?>
33
  <style type="text/css">
34
  html{
templates/single-course/content-item.php CHANGED
@@ -29,8 +29,10 @@ $item_id = isset( $item->id ) ? $item->id : ( isset( $item->ID ) ? $item->ID : 0
29
 
30
  <?php if ( $user->can_edit_item( $item_id, $course->id ) ): ?>
31
  <p class="edit-course-item-link">
32
- <a href="<?php echo get_edit_post_link( $item_id ); ?>"><?php _e( 'Edit this item', 'learnpress' ); ?></a>
33
  </p>
34
  <?php endif; ?>
35
- <?php do_action( 'learn_press_after_content_item', $item_id, $course->id, true ); ?>
 
 
36
  </div>
29
 
30
  <?php if ( $user->can_edit_item( $item_id, $course->id ) ): ?>
31
  <p class="edit-course-item-link">
32
+ <a class="" href="<?php echo get_edit_post_link( $item_id ); ?>"><?php _e( 'Edit this item', 'learnpress' ); ?></a>
33
  </p>
34
  <?php endif; ?>
35
+ <?php
36
+ learn_press_get_nav_course_item($course->id, $item_id, true);
37
+ ?>
38
  </div>
templates/single-course/nav-items.php DELETED
@@ -1,35 +0,0 @@
1
- <?php
2
- /**
3
- * Template for displaying course items navigation
4
- *
5
- * @author ThimPress
6
- * @package LearnPress/Templates
7
- * @version 2.1.5
8
- */
9
-
10
- defined( 'ABSPATH' ) || exit;
11
-
12
- $nav = learn_press_get_nav_course_item_url( $course_id, $item_id, $content_only );
13
-
14
- ?>
15
- <nav id="lp-navigation" class="navigation course-item-navigation" role="navigation">
16
- <div class="nav-links">
17
- <?php if ( isset( $nav['back']['link'] ) ) { ?>
18
- <div class="nav-previous nav-link">
19
- <a class="course-item-title button-load-item js-action" data-id="<?php echo esc_attr( $nav['back']['id'] ); ?>" href="<?php echo esc_attr( $nav['back']['link'] ); ?>" rel="prev">
20
- <span class="meta-nav" aria-hidden="true"><?php esc_html_e( 'Previous', 'learnpress' ); ?></span>
21
- <span class="post-title"><?php echo esc_html( $nav['back']['title'] ); ?></span>
22
- </a>
23
- </div>
24
- <?php } ?>
25
-
26
- <?php if ( isset( $nav['next']['link'] ) ) { ?>
27
- <div class="nav-next nav-link">
28
- <a class="course-item-title button-load-item js-action" data-id="<?php echo esc_attr( $nav['next']['id'] ); ?>" href="<?php echo esc_attr( $nav['next']['link'] ); ?>" rel="next">
29
- <span class="meta-nav" aria-hidden="true"><?php esc_html_e( 'Next', 'learnpress' ); ?></span>
30
- <span class="post-title"><?php echo esc_html( $nav['next']['title'] ); ?></span>
31
- </a>
32
- </div>
33
- <?php } ?>
34
- </div>
35
- </nav>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
templates/single-course/popup.php CHANGED
@@ -1,8 +1 @@
1
- <?php
2
- /**
3
- * Template for displaying popup course
4
- *
5
- * @author ThimPress
6
- * @package LearnPress/Templates
7
- * @version 2.1.5
8
- */
1
+ <?php _deprecated_file( 'template/single-course/popup.php', 'global/js-template.php', '2.1.5' );
 
 
 
 
 
 
 
templates/single-course/price.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * @author ThimPress
6
  * @package LearnPress/Templates
7
- * @version 2.1.4.2
8
  */
9
 
10
  if ( !defined( 'ABSPATH' ) ) {
4
  *
5
  * @author ThimPress
6
  * @package LearnPress/Templates
7
+ * @version 1.0
8
  */
9
 
10
  if ( !defined( 'ABSPATH' ) ) {
templates/single-course/progress.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * @author ThimPress
4
  * @package LearnPress/Templates
5
- * @version 2.1.6
6
  */
7
 
8
  defined( 'ABSPATH' ) || exit();
@@ -45,19 +45,21 @@ $course_results = $course->evaluate_course_results();
45
  <div class="course-progress">
46
  <h4 class="lp-course-progress-heading">
47
  <?php esc_html_e( 'Course results', 'learnpress' ); ?>
48
- <?php if ( $tooltip = learn_press_get_course_results_tooltip( $course->id ) ) { ?>
49
- <span class="learn-press-tooltip" data-content="<?php echo esc_html( $tooltip ); ?>"></span>
50
- <?php } ?>
 
 
 
 
 
 
 
51
  </h4>
52
- <div class="lp-course-status">
53
- <span class="number"><?php echo $current; ?><span class="percentage-sign">%</span></span>
54
- <?php if ( $grade = $user->get_course_grade( $course->id ) ) { ?>
55
- <span class="grade <?php echo esc_attr( $grade ); ?>">
56
- <?php learn_press_course_grade_html( $grade ); ?>
57
- </span>
58
- <?php } ?>
59
  </div>
60
- <div class="lp-course-progress <?php echo $passed ? ' passed' : ''; ?>" data-value="<?php echo $current; ?>"
61
  data-passing-condition="<?php echo $passing_condition; ?>">
62
  <div class="lp-progress-bar">
63
  <div class="lp-progress-value" style="width: <?php echo $current; ?>%;">
@@ -69,4 +71,7 @@ $course_results = $course->evaluate_course_results();
69
  </div>
70
  </div>
71
  </div>
 
 
 
72
  </div>
2
  /**
3
  * @author ThimPress
4
  * @package LearnPress/Templates
5
+ * @version 2.0.4
6
  */
7
 
8
  defined( 'ABSPATH' ) || exit();
45
  <div class="course-progress">
46
  <h4 class="lp-course-progress-heading">
47
  <?php esc_html_e( 'Course results', 'learnpress' ); ?>
48
+ <?php
49
+ if ( $course->is_evaluation( 'evaluate_final_quiz' ) ) {
50
+ $tooltip = __( "Evaluated by results of final quiz", 'learnpress' );
51
+ } elseif ( $course->is_evaluation( 'evaluate_quizzes' ) ) {
52
+ $tooltip = __( "Evaluated by average results of quizzes", 'learnpress' );
53
+ } else {
54
+ $tooltip = __( "Evaluated by items completed", 'learnpress' );
55
+ }
56
+ ?>
57
+ <span class="learn-press-tooltip" data-content="<?php echo esc_html( $tooltip ); ?>"></span>
58
  </h4>
59
+ <div>
60
+ <span class="number"><?php echo $current ?></span><span class="percentage-sign">%</span>
 
 
 
 
 
61
  </div>
62
+ <div class="lp-course-progress<?php echo $passed ? ' passed' : ''; ?>" data-value="<?php echo $current; ?>"
63
  data-passing-condition="<?php echo $passing_condition; ?>">
64
  <div class="lp-progress-bar">
65
  <div class="lp-progress-value" style="width: <?php echo $current; ?>%;">
71
  </div>
72
  </div>
73
  </div>
74
+ <?php /*if ($user->has_enrolled_course($course->id)): ?>
75
+ <?php learn_press_get_template('single-course/buttons.php'); ?>
76
+ <?php endif;*/ ?>
77
  </div>
templates/single-course/section/item-meta.php CHANGED
@@ -2,80 +2,38 @@
2
  /**
3
  * @author ThimPress
4
  * @package LearnPress/Templates
5
- * @version 2.1.6
6
  */
7
 
8
  defined( 'ABSPATH' ) || exit();
9
 
10
  $user = learn_press_get_current_user();
11
  $course = LP()->global['course'];
 
 
12
  $course_item = $course->get_item( $item->ID );
13
-
14
  $status = $user->get_course_status( $course->id );
15
- $item_status = $user->get_item_status( $item->ID );
16
-
17
- $security = wp_create_nonce( sprintf( 'complete-item-%d-%d-%d', $user->id, $course->id, $item->ID ) );
18
-
19
- $result = $user->get_quiz_results( $item->ID );
20
- $has_result = false;
21
- if ( in_array( $item_status, array( 'completed', 'started' ) ) ) {
22
- $has_result = true;
23
- }
24
  ?>
25
  <div class="course-item-meta">
26
  <?php do_action( 'learn_press_before_item_meta', $item ); ?>
27
  <?php if ( $status != 'enrolled' && $course_item->is_preview() && $course->is_required_enroll() ): ?>
28
  <span class="lp-label lp-label-preview"><?php _e( 'Preview', 'learnpress' ); ?></span>
29
  <?php endif; ?>
30
- <?php
31
- if ( $user->can_view_item( $item->ID, $course->id ) !== false ) {
32
- if ( $item->post_type == 'lp_quiz' ) {
33
-
34
- $passing_grade_type = get_post_meta( $item->ID, '_lp_passing_grade_type', true );
35
- if ( $result ) {
36
- $result_text = $passing_grade_type == 'point' ? sprintf( '%d/%d', $result->mark, $result->quiz_mark ) : $result->mark_percent . '%';
37
- } else {
38
- $result_text = '';
39
- }
40
- ?>
41
- <span class="item-loop-meta-text item-result"><?php echo $result_text; ?></span>
42
-
43
- <?php
44
- if ( $course->is( 'final-quiz', $item->ID ) ) {
45
- ?><span class="item-loop-meta-text item-final"><?php _e( 'Final Quiz', 'learnpress' ); ?></span><?php
46
- }
47
- if ( $item_status == 'completed' ) {
48
- $grade = $user->get_quiz_graduation( $course_item->id, $course->id );
49
- if ( $grade === 'passed' ) {
50
- ?>
51
- <span class="lp-icon item-status item-status-passed" title="<?php esc_attr_e( 'Passed', 'learnpress' ); ?>"></span><?php
52
- } else {
53
- ?>
54
- <span class="lp-icon item-status item-status-failed" title="<?php esc_attr_e( 'Failed', 'learnpress' ); ?>"></span><?php
55
- }
56
- } elseif ( $item_status == 'viewed' ) {
57
- ?>
58
- <span class="lp-icon item-status item-status-viewed" title="<?php esc_attr_e( 'Viewed', 'learnpress' ); ?>"></span><?php
59
- } elseif ( $item_status == 'started' ) {
60
- ?>
61
- <span class="lp-icon item-status item-status-started" title="<?php esc_attr_e( 'In Progress', 'learnpress' ); ?>"></span><?php
62
- }
63
- } else {
64
- if ( $item_status == 'completed' ) {
65
- ?>
66
- <span class="lp-icon item-status item-status-passed" title="<?php esc_attr_e( 'Completed', 'learnpress' ); ?>"></span>
67
- <?php
68
- } elseif ( $item_status == 'viewed' ) { ?>
69
- <span class="lp-icon item-status item-status-viewed" title="<?php esc_attr_e( 'Viewed', 'learnpress' ); ?>"></span>
70
- <?php
71
- }
72
- }
73
- if ( !$item_status ) {
74
- ?>
75
- <span class="lp-icon item-status"></span>
76
- <?php
77
- }
78
- }
79
- ?>
80
  <?php do_action( 'learn_press_after_item_meta', $item ); ?>
81
  </div>
2
  /**
3
  * @author ThimPress
4
  * @package LearnPress/Templates
5
+ * @version 2.1.4
6
  */
7
 
8
  defined( 'ABSPATH' ) || exit();
9
 
10
  $user = learn_press_get_current_user();
11
  $course = LP()->global['course'];
12
+ $item_status = $user->get_item_status( $item->ID );
13
+ $security = wp_create_nonce( sprintf( 'complete-item-%d-%d-%d', $user->id, $course->id, $item->ID ) );
14
  $course_item = $course->get_item( $item->ID );
 
15
  $status = $user->get_course_status( $course->id );
 
 
 
 
 
 
 
 
 
16
  ?>
17
  <div class="course-item-meta">
18
  <?php do_action( 'learn_press_before_item_meta', $item ); ?>
19
  <?php if ( $status != 'enrolled' && $course_item->is_preview() && $course->is_required_enroll() ): ?>
20
  <span class="lp-label lp-label-preview"><?php _e( 'Preview', 'learnpress' ); ?></span>
21
  <?php endif; ?>
22
+ <?php if ( $user->can_view_item( $item->ID, $course->id ) !== false ) { ?>
23
+ <?php if ( $item->post_type == 'lp_quiz' ) { ?>
24
+ <span class="item-loop-meta-text item-result">
25
+ <?php if ( $result = $user->get_quiz_results( $item->ID ) ): ?>
26
+ <?php echo sprintf( '%d%%', round( $result->mark_percent ) ); ?>
27
+ <?php endif; ?>
28
+ </span>
29
+ <?php } ?>
30
+ <?php if ( $item_status == 'completed' ) { ?>
31
+ <span class="lp-icon item-status" title="<?php esc_attr_e( 'Completed', 'learnpress' ); ?>"></span>
32
+ <?php } elseif ( $item_status == 'started' ) { ?>
33
+ <span class="lp-icon item-status button-complete-item button-complete-lesson" data-security="<?php echo esc_attr( $security ); ?>" title="<?php esc_attr_e( 'Not Completed', 'learnpress' ); ?>"></span>
34
+ <?php } else { ?>
35
+ <span class="lp-icon item-status button-complete-item button-complete-lesson" data-security="<?php echo esc_attr( $security ); ?>" title="<?php esc_attr_e( 'Not Started', 'learnpress' ); ?>"></span>
36
+ <?php } ?>
37
+ <?php } ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  <?php do_action( 'learn_press_after_item_meta', $item ); ?>
39
  </div>
templates/single-course/section/item-quiz.php CHANGED
@@ -2,46 +2,22 @@
2
  /**
3
  * @author ThimPress
4
  * @package LearnPress/Templates
5
- * @version 2.1.6
6
  */
7
 
8
  if ( !defined( 'ABSPATH' ) ) {
9
  exit; // Exit if accessed directly
10
  }
11
- $user = learn_press_get_current_user();
12
- $course = LP()->global['course'];
13
- $viewable = learn_press_user_can_view_quiz( $item->ID, $course->id );//learn_press_is_enrolled_course();
14
- $tag = $viewable ? 'a' : 'span';
15
- $target = apply_filters( 'learn_press_section_item_link_target', '_blank', $item );
16
- $item_title = apply_filters( 'learn_press_section_item_title', get_the_title( $item->ID ), $item );
17
- $item_link = $viewable ? 'href="' . $course->get_item_link( $item->ID ) . '"' : '';
18
- $item_status = $user->get_item_status( $item->ID );
19
- $result = $user->get_quiz_results( $item->ID );
20
- $has_result = false;
21
- if ( in_array( $item_status, array( 'completed', 'started' ) ) ) {
22
- $has_result = true;
23
- }
24
- $class = '';
25
- if ( $has_result ) {
26
- $class = 'item-has-result';
27
- }
28
  ?>
29
 
30
- <li <?php learn_press_course_item_class( $item->ID, $course->id, $class ); ?> data-type="<?php echo $item->post_type; ?>">
31
  <?php do_action( 'learn_press_before_section_item_title', $item, $section, $course ); ?>
32
-
33
- <?php
34
- printf(
35
- '<%s class="%s" target="%s" data-id="%d" %s>%s</%s>',
36
- $tag,
37
- 'course-item-title button-load-item',
38
- $target,
39
- $item->ID,
40
- $item_link,
41
- $item_title,
42
- $tag
43
- );
44
- ?>
45
- <!--<<?php echo $tag; ?> class="course-item-title button-load-item" target="<?php echo $target; ?>" <?php echo $item_link; ?> data-id="<?php echo $item->ID; ?>"><?php echo $item_title ?></<?php echo $tag; ?>>-->
46
  <?php do_action( 'learn_press_after_section_item_title', $item, $section, $course ); ?>
47
  </li>
2
  /**
3
  * @author ThimPress
4
  * @package LearnPress/Templates
5
+ * @version 1.0
6
  */
7
 
8
  if ( !defined( 'ABSPATH' ) ) {
9
  exit; // Exit if accessed directly
10
  }
11
+ $course = LP()->global['course'];
12
+ $viewable = learn_press_user_can_view_quiz( $item->ID, $course->id );//learn_press_is_enrolled_course();
13
+ $tag = $viewable ? 'a' : 'span';
14
+ $target = apply_filters( 'learn_press_section_item_link_target', '_blank', $item );
15
+ $item_title = apply_filters( 'learn_press_section_item_title', get_the_title( $item->ID ), $item );
16
+ $item_link = $viewable ? 'href="' . $course->get_item_link( $item->ID ) . '"' : '';
 
 
 
 
 
 
 
 
 
 
 
17
  ?>
18
 
19
+ <li <?php learn_press_course_item_class( $item->ID ); ?> data-type="<?php echo $item->post_type; ?>">
20
  <?php do_action( 'learn_press_before_section_item_title', $item, $section, $course ); ?>
21
+ <<?php echo $tag; ?> class="course-item-title button-load-item" target="<?php echo $target; ?>" <?php echo $item_link; ?> data-id="<?php echo $item->ID; ?>"><?php echo $item_title ?></<?php echo $tag; ?>>
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  <?php do_action( 'learn_press_after_section_item_title', $item, $section, $course ); ?>
23
  </li>
templates/single-course/section/title.php CHANGED
@@ -22,7 +22,7 @@ if ( $section_name === false ) {
22
  <?php if ( $section_description = apply_filters( 'learn_press_curriculum_section_description', $section->section_description, $section ) ) { ?>
23
  <p><?php echo $section_description; ?></p>
24
  <?php } ?>
25
- <span class="meta">
26
  <span class="step"><?php printf( __( '%d/%d', 'learnpress' ), $user->get_completed_items_in_section( $course->id, $section->section_id, $force ), sizeof( $section->items ) ); ?></span>
27
  <span class="collapse"></span>
28
  </span>
22
  <?php if ( $section_description = apply_filters( 'learn_press_curriculum_section_description', $section->section_description, $section ) ) { ?>
23
  <p><?php echo $section_description; ?></p>
24
  <?php } ?>
25
+ <span class="meta">
26
  <span class="step"><?php printf( __( '%d/%d', 'learnpress' ), $user->get_completed_items_in_section( $course->id, $section->section_id, $force ), sizeof( $section->items ) ); ?></span>
27
  <span class="collapse"></span>
28
  </span>
templates/widgets/featured-courses/default.php DELETED
@@ -1,85 +0,0 @@
1
- <?php
2
- /**
3
- * Template for displaying content of Featured Courses widget
4
- *
5
- * @author ThimPress
6
- * @package LearnPress/Templates/Widgets
7
- * @version 2.1.5
8
- */
9
-
10
- defined( 'ABSPATH' ) || exit;
11
-
12
- $instance = $this->instance;
13
- ?>
14
- <div class="<?php echo 'archive-course-widget-outer ' . esc_attr( $instance["css_class"] ); ?>">
15
- <div class="widget-body">
16
- <?php foreach ( $this->courses as $course ): ?>
17
- <div class="course-entry">
18
- <?php if ( !empty( $instance['show_thumbnail'] ) ): ?>
19
- <div class="course-cover">
20
- <a href="<?php echo get_the_permalink( $course->id ); ?>">
21
- <?php echo get_the_post_thumbnail( $course->id, 'medium' ); ?>
22
- </a>
23
- </div>
24
- <?php endif; ?>
25
- <div class="course-detail">
26
- <a href="<?php echo get_the_permalink( $course->id ) ?>">
27
- <h3 class="course-title">
28
- <?php echo $course->get_course_data()->post_title; ?>
29
- </h3>
30
- </a>
31
- <?php if ( !empty( $instance['desc_length'] ) && intval( $instance['desc_length'] ) > 0 ): ?>
32
- <div class="course-description"><?php
33
- $content_length = intval( $instance['desc_length'] );
34
- $the_content = $course->get_course_data()->post_content;
35
- $the_content = wp_trim_words( $the_content, $content_length, __( '...', 'learnpress' ) );
36
- echo $the_content;
37
- ?></div>
38
- <?php endif; ?>
39
- <div class="course-meta-data">
40
- <?php if ( !empty( $instance['show_price'] ) ): ?>
41
- <div class="course-meta-field">
42
- <?php
43
- echo $course->get_price_html();
44
- ?>
45
- </div>
46
- <?php endif; ?>
47
- <?php if ( !empty( $instance['show_enrolled_students'] ) ): ?>
48
- <div class="course-student-number course-meta-field">
49
- <?php
50
- $students = $course->get_users_enrolled();
51
- echo intval( $students ) > 1 ? sprintf( __( '%d students', 'learnpress' ), $students ) : sprintf( __( '%d student', 'learnpress' ), $students );
52
- ?>
53
- </div>
54
- <?php endif; ?>
55
- <?php if ( !empty( $instance['show_lesson'] ) ): ?>
56
- <div class="course-lesson-number course-meta-field">
57
- <?php
58
- $lessons = sizeof( $course->get_lessons() );
59
- echo intval( $lessons ) > 1 ? sprintf( __( '%d lessons', 'learnpress' ), $lessons ) : sprintf( __( '%d lesson', 'learnpress' ), $lessons );
60
- ?>
61
- </div>
62
- <?php endif; ?>
63
- <?php if ( !empty( $instance['show_teacher'] ) ): ?>
64
- <div class="course-meta-field">
65
- <?php echo $course->get_instructor_html(); ?>
66
- </div>
67
- <?php endif; ?>
68
- </div>
69
- </div>
70
- </div>
71
- <?php endforeach; ?>
72
- </div>
73
- <div class="widget-footer">
74
- <?php if ( !empty( $instance['bottom_link_text'] ) ):
75
- $page_id = get_option( 'learn_press_courses_page_id' );
76
- $link = get_the_permalink( $page_id );
77
- $title = get_the_title( $page_id );
78
- ?>
79
- <a class="pull-right" href="<?php echo $link ?>">
80
- <?php echo wp_kses_post( $instance['bottom_link_text'] ); ?>
81
- </a>
82
- <?php endif; ?>
83
- </div>
84
- </div>
85
- <div class="clearfix"></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
templates/widgets/popular-courses/default.php DELETED
@@ -1,85 +0,0 @@
1
- <?php
2
- /**
3
- * Template for displaying content of Popular Courses widget
4
- *
5
- * @author ThimPress
6
- * @package LearnPress/Templates/Widgets
7
- * @version 2.1.5
8
- */
9
-
10
- defined( 'ABSPATH' ) || exit;
11
-
12
- $instance = $this->instance;
13
- ?>
14
- <div class="<?php echo 'archive-course-widget-outer ' . esc_attr( $instance["css_class"] ); ?>">
15
- <div class="widget-body">
16
- <?php foreach ( $this->courses as $course ): ?>
17
- <div class="course-entry">
18
- <?php if ( !empty( $instance['show_thumbnail'] ) ): ?>
19
- <div class="course-cover">
20
- <a href="<?php echo get_the_permalink( $course->id ); ?>">
21
- <?php echo get_the_post_thumbnail( $course->id, 'medium' ); ?>
22
- </a>
23
- </div>
24
- <?php endif; ?>
25
- <div class="course-detail">
26
- <a href="<?php echo get_the_permalink( $course->id ) ?>">
27
- <h3 class="course-title">
28
- <?php echo $course->get_course_data()->post_title; ?>
29
- </h3>
30
- </a>
31
- <?php if ( !empty( $instance['desc_length'] ) && intval( $instance['desc_length'] ) > 0 ): ?>
32
- <div class="course-description"><?php
33
- $content_length = intval( $instance['desc_length'] );
34
- $the_content = $course->get_course_data()->post_content;
35
- $the_content = wp_trim_words( $the_content, $content_length, __( '...', 'learnpress' ) );
36
- echo $the_content;
37
- ?></div>
38
- <?php endif; ?>
39
- <div class="course-meta-data">
40
- <?php if ( !empty( $instance['show_price'] ) ): ?>
41
- <div class="course-meta-field">
42
- <?php
43
- echo $course->get_price_html();
44
- ?>
45
- </div>
46
- <?php endif; ?>
47
- <?php if ( !empty( $instance['show_enrolled_students'] ) ): ?>
48
- <div class="course-student-number course-meta-field">
49
- <?php
50
- $students = $course->get_users_enrolled();
51
- echo intval( $students ) > 1 ? sprintf( __( '%d students', 'learnpress' ), $students ) : sprintf( __( '%d student', 'learnpress' ), $students );
52
- ?>
53
- </div>
54
- <?php endif; ?>
55
- <?php if ( !empty( $instance['show_lesson'] ) ): ?>
56
- <div class="course-lesson-number course-meta-field">
57
- <?php
58
- $lessons = sizeof( $course->get_lessons() );
59
- echo intval( $lessons ) > 1 ? sprintf( __( '%d lessons', 'learnpress' ), $lessons ) : sprintf( __( '%d lesson', 'learnpress' ), $lessons );
60
- ?>
61
- </div>
62
- <?php endif; ?>
63
- <?php if ( !empty( $instance['show_teacher'] ) ): ?>
64
- <div class="course-meta-field">
65
- <?php echo $course->get_instructor_html(); ?>
66
- </div>
67
- <?php endif; ?>
68
- </div>
69
- </div>
70
- </div>
71
- <?php endforeach; ?>
72
- </div>
73
- <div class="widget-footer">
74
- <?php if ( !empty( $instance['bottom_link_text'] ) ):
75
- $page_id = get_option( 'learn_press_courses_page_id' );
76
- $link = get_the_permalink( $page_id );
77
- $title = get_the_title( $page_id );
78
- ?>
79
- <a class="pull-right" href="<?php echo $link ?>">
80
- <?php echo wp_kses_post( $instance['bottom_link_text'] ); ?>
81
- </a>
82
- <?php endif; ?>
83
- </div>
84
- </div>
85
- <div class="clearfix"></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
templates/widgets/recent-courses/default.php DELETED
@@ -1,85 +0,0 @@
1
- <?php
2
- /**
3
- * Template for displaying content of Recent Courses widget
4
- *
5
- * @author ThimPress
6
- * @package LearnPress/Templates/Widgets
7
- * @version 2.1.5
8
- */
9
-
10
- defined( 'ABSPATH' ) || exit;
11
-
12
- $instance = $this->instance;
13
- ?>
14
- <div class="<?php echo 'archive-course-widget-outer ' . esc_attr( $instance["css_class"] ); ?>">
15
- <div class="widget-body">
16
- <?php foreach ( $this->courses as $course ): ?>
17
- <div class="course-entry">
18
- <?php if ( !empty( $instance['show_thumbnail'] ) ): ?>
19
- <div class="course-cover">
20
- <a href="<?php echo get_the_permalink( $course->id ); ?>">
21
- <?php echo get_the_post_thumbnail( $course->id, 'medium' ); ?>
22
- </a>
23
- </div>
24
- <?php endif; ?>
25
- <div class="course-detail">
26
- <a href="<?php echo get_the_permalink( $course->id ) ?>">
27
- <h3 class="course-title">
28
- <?php echo $course->get_course_data()->post_title; ?>
29
- </h3>
30
- </a>
31
- <?php if ( !empty( $instance['desc_length'] ) && intval( $instance['desc_length'] ) > 0 ): ?>
32
- <div class="course-description"><?php
33
- $content_length = intval( $instance['desc_length'] );
34
- $the_content = $course->get_course_data()->post_content;
35
- $the_content = wp_trim_words( $the_content, $content_length, __( '...', 'learnpress' ) );
36
- echo $the_content;
37
- ?></div>
38
- <?php endif; ?>
39
- <div class="course-meta-data">
40
- <?php if ( !empty( $instance['show_price'] ) ): ?>
41
- <div class="course-meta-field">
42
- <?php
43
- echo $course->get_price_html();
44
- ?>
45
- </div>
46
- <?php endif; ?>
47
- <?php if ( !empty( $instance['show_enrolled_students'] ) ): ?>
48
- <div class="course-student-number course-meta-field">
49
- <?php
50
- $students = $course->get_users_enrolled();
51
- echo intval( $students ) > 1 ? sprintf( __( '%d students', 'learnpress' ), $students ) : sprintf( __( '%d student', 'learnpress' ), $students );
52
- ?>
53
- </div>
54
- <?php endif; ?>
55
- <?php if ( !empty( $instance['show_lesson'] ) ): ?>
56
- <div class="course-lesson-number course-meta-field">
57
- <?php
58
- $lessons = sizeof( $course->get_lessons() );
59
- echo intval( $lessons ) > 1 ? sprintf( __( '%d lessons', 'learnpress' ), $lessons ) : sprintf( __( '%d lesson', 'learnpress' ), $lessons );
60
- ?>
61
- </div>
62
- <?php endif; ?>
63
- <?php if ( !empty( $instance['show_teacher'] ) ): ?>
64
- <div class="course-meta-field">
65
- <?php echo $course->get_instructor_html(); ?>
66
- </div>
67
- <?php endif; ?>
68
- </div>
69
- </div>
70
- </div>
71
- <?php endforeach; ?>
72
- </div>
73
- <div class="widget-footer">
74
- <?php if ( !empty( $instance['bottom_link_text'] ) ):
75
- $page_id = get_option( 'learn_press_courses_page_id' );
76
- $link = get_the_permalink( $page_id );
77
- $title = get_the_title( $page_id );
78
- ?>
79
- <a class="pull-right" href="<?php echo $link ?>">
80
- <?php echo wp_kses_post( $instance['bottom_link_text'] ); ?>
81
- </a>
82
- <?php endif; ?>
83
- </div>
84
- </div>
85
- <div class="clearfix"></div>