LearnPress – WordPress LMS Plugin - Version 2.1.5.5

Version Description

  • Fixed issue with slug of course page is the same with slug of course tab in profile
  • Fixed issue with metabox show/hide field
Download this release

Release Info

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

Code changes from version 2.1.6.1 to 2.1.5.5

Files changed (52) hide show
  1. assets/css/admin/admin.css +6 -6
  2. assets/css/admin/admin.less +9 -8
  3. assets/css/admin/meta-box-course.css +0 -7
  4. assets/css/admin/meta-box-course.less +1 -4
  5. assets/css/learnpress.css +23 -88
  6. assets/css/learnpress.less +37 -98
  7. assets/js/admin/admin.js +1 -1
  8. assets/js/admin/meta-box-course.js +1 -25
  9. assets/js/admin/meta-box-quiz.js +1 -13
  10. assets/js/frontend/learnpress.js +2 -1
  11. assets/js/frontend/lesson.js +6 -3
  12. assets/js/frontend/single-course.js +12 -43
  13. assets/js/global.js +3 -2
  14. assets/js/global.min.js +2 -2
  15. inc/admin/includes/class-markdown-parse.php +5 -7
  16. inc/class-lp-assets.php +1 -1
  17. inc/class-lp-cache.php +2 -34
  18. inc/class-lp-page-controller.php +3 -6
  19. inc/class-lp-request-handler.php +10 -20
  20. inc/class-lp-shortcodes.php +21 -2
  21. inc/course/abstract-lp-course.php +25 -154
  22. inc/course/lp-course-functions.php +0 -31
  23. inc/custom-post-types/course.php +12 -26
  24. inc/custom-post-types/order.php +2 -32
  25. inc/custom-post-types/quiz.php +41 -50
  26. inc/lesson/lp-lesson-functions.php +7 -19
  27. inc/libraries/meta-box/inc/fields/datetime.php +1 -1
  28. inc/libraries/meta-box/inc/fields/time.php +2 -2
  29. inc/lp-constants.php +1 -1
  30. inc/lp-core-functions.php +9 -52
  31. inc/lp-init.php +20 -40
  32. inc/lp-template-functions.php +17 -10
  33. inc/new-functions.php +119 -0
  34. inc/order/class-lp-order.php +3 -2
  35. inc/question/class-lp-question-factory.php +2 -17
  36. inc/quiz/class-lp-quiz-factory.php +1 -10
  37. inc/updates/09/script.js +2 -1
  38. inc/user/abstract-lp-user.php +17 -58
  39. inc/user/class-lp-user-factory.php +5 -10
  40. inc/user/lp-user-functions.php +4 -14
  41. learnpress.php +1 -1
  42. readme.txt +2 -16
  43. templates/content-quiz/buttons.php +2 -6
  44. templates/global/become-teacher-form.php +2 -5
  45. templates/profile/tabs/edit.php +3 -11
  46. templates/single-course/buttons.php +116 -91
  47. templates/single-course/content-item-only.php +1 -0
  48. templates/single-course/nav-items.php +0 -1
  49. templates/single-course/progress.php +17 -12
  50. templates/single-course/section/item-meta.php +24 -57
  51. templates/single-course/section/item-quiz.php +9 -33
  52. templates/single-course/section/title.php +1 -1
assets/css/admin/admin.css CHANGED
@@ -19,14 +19,11 @@ input:focus:-moz-placeholder {
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;
@@ -272,6 +269,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;
19
.rwmb-field .rwmb-input .rwmb-label {
20
margin-top: 0;
21
}
22
+ .rwmb-field .rwmb-input .option-desc {
23
font-weight: normal;
24
+ padding-left: 24px;
25
font-style: italic;
26
+ margin-top: 3px;
27
}
28
.lp-nav-tab-wrapper {
29
border-bottom: 1px solid #ccc;
269
.meta_box_course_lesson_quiz li select {
270
min-width: 250px;
271
}
272
+ .description {
273
+ margin-top: 5px;
274
+ }
275
.dashed-placeholder {
276
border: 2px dashed #999;
277
padding: 10px;
assets/css/admin/admin.less CHANGED
@@ -26,14 +26,11 @@ input:focus:-moz-placeholder {
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
}
@@ -318,6 +315,10 @@ input:focus:-moz-placeholder {
318
min-width: 250px;
319
}
320
321
.dashed-placeholder {
322
border: 2px dashed #999;
323
padding: 10px;
26
.rwmb-label {
27
margin-top: 0;
28
}
29
+ .option-desc {
30
+ font-weight: normal;
31
+ padding-left: 24px;
32
+ font-style: italic;
33
+ margin-top: 3px;
34
}
35
}
36
}
315
min-width: 250px;
316
}
317
318
+ .description {
319
+ margin-top: 5px;
320
+ }
321
+
322
.dashed-placeholder {
323
border: 2px dashed #999;
324
padding: 10px;
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;
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;
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 {
3
.rwmb-duration-wrapper select {
4
vertical-align: baseline;
5
}
6
+
7
.post-type-lp_course {
8
#postdivric,
9
#submitpost {
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,27 @@
357
height: 100%;
358
content: '';
359
}
360
#learn-press-course-curriculum .course-item.focus {
361
background: #ffb710;
362
}
@@ -381,20 +353,6 @@
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 +474,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 +839,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 +962,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;
@@ -2619,7 +2554,7 @@ body.content-item-only #learn-press-content-item.expand {
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;
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-completed,
321
+ #learn-press-course-curriculum .course-item.item-has-status.item-completed .item-status-passed {
322
+ background: #95e6f9;
323
+ }
324
+ #learn-press-course-curriculum .course-item.item-has-status.item-completed .item-status-failed {
325
+ background: #ff5425;
326
+ }
327
+ #learn-press-course-curriculum .course-item.item-has-status.item-completed .item-status-failed:before {
328
+ content: '\f335';
329
+ font-family: Dashicons;
330
+ font-size: 24px;
331
+ }
332
#learn-press-course-curriculum .course-item.focus {
333
background: #ffb710;
334
}
353
float: right;
354
margin-top: 5px;
355
}
356
.lp-icon {
357
display: inline-block;
358
font-family: 'lp-icons';
474
.single-lp_course .learn-press-course-results-progress .percentage-sign {
475
margin-left: 5px;
476
}
477
.single-lp_course .learn-press-course-results-progress:after {
478
display: block;
479
content: '';
839
height: 43px;
840
line-height: 43px;
841
background: #F5F5F5;
842
+ margin: 0 10px;
843
border: 1px solid #DDD;
844
outline: none;
845
}
962
padding: 0;
963
margin-left: 0;
964
}
965
.quiz-questions-list {
966
margin: 0 0 20px 0;
967
padding: 0;
2554
.course-item-navigation {
2555
border-top: 4px solid #333;
2556
padding-top: 10px;
2557
+ margin-bottom: 20px;
2558
}
2559
.course-item-navigation .nav-links .nav-link {
2560
opacity: 1;
assets/css/learnpress.less CHANGED
@@ -430,59 +430,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 +464,29 @@
517
content: '';
518
}
519
}
520
-
521
&.focus {
522
background: #ffb710;
523
&.off {
@@ -538,15 +507,6 @@
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 +604,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 +1001,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 +1096,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 {
@@ -2212,12 +2151,12 @@ body.content-item-only {
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;
@@ -2229,34 +2168,34 @@ body.content-item-only {
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: '';
430
.lp-icon {
431
display: none;
432
}
433
&.viewable {
434
cursor: pointer;
435
&:hover {
464
content: '';
465
}
466
}
467
+ &.item-has-status .item-status {
468
+ display: inline-block;
469
+ background: #d6d6d6;
470
+ margin-left: 5px;
471
+ &:before {
472
+ content: '\ea10';
473
+ color: #FFF;
474
+ }
475
+ }
476
+ &.item-has-status.item-completed {
477
+ .item-status-completed,
478
+ .item-status-passed {
479
+ background: #95e6f9;
480
+ }
481
+ .item-status-failed {
482
+ background: #ff5425;
483
+ &:before {
484
+ content: '\f335';
485
+ font-family: Dashicons;
486
+ font-size: 24px;
487
+ }
488
+ }
489
+ }
490
&.focus {
491
background: #ffb710;
492
&.off {
507
right: 15px;
508
float: right;
509
margin-top: 5px;
510
}
511
}
512
604
.percentage-sign {
605
margin-left: 5px;
606
}
607
&:after {
608
display: block;
609
content: '';
1001
height: 43px;
1002
line-height: 43px;
1003
background: #F5F5F5;
1004
+ margin: 0 10px;
1005
border: 1px solid #DDD;
1006
outline: none;
1007
}
1096
list-style: none;
1097
padding: 0;
1098
margin-left: 0;
1099
}
1100
1101
.quiz-questions-list {
2151
}
2152
}
2153
2154
+ .edit-course-item-link{
2155
+ a{
2156
font-size: 14px;
2157
position: relative;
2158
padding-left: 25px;
2159
+ &:after{
2160
content: "\f464";
2161
font-family: Dashicons;
2162
font-size: 26px;
2168
}
2169
}
2170
2171
+ .course-item-navigation{
2172
border-top: 4px solid #333;
2173
padding-top: 10px;
2174
+ margin-bottom: 20px;
2175
+ .nav-links{
2176
+ .nav-link{
2177
opacity: 1;
2178
+ a{
2179
opacity: 1;
2180
+ .meta-nav{
2181
display: block;
2182
text-transform: uppercase;
2183
font-size: small;
2184
color: #b9b9b9;
2185
}
2186
+ .post-title{
2187
opacity: 1;
2188
}
2189
}
2190
+ &.nav-previous{
2191
float: left;
2192
}
2193
+ &.nav-next{
2194
float: right;
2195
text-align: right;
2196
}
2197
}
2198
+ &:after{
2199
clear: both;
2200
display: block;
2201
content: '';
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/meta-box-course.js CHANGED
@@ -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
},
@@ -1442,22 +1434,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)) {
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
},
1434
});
1435
});
1436
1437
1438
function canSubmit() {
1439
if ((opts.current_user_type == 'admin') || !opts.required_review || (opts.course_status == 'publish' && opts.enable_edit_published)) {
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/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/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,16 +322,10 @@ 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) {
@@ -421,6 +389,7 @@ if (typeof LearnPress === 'undefined') {
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;
@@ -752,12 +721,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.$('.course-progress .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
331
if (data.setUrl) {
389
var that = this,
390
$target = $(e.target),
391
id = this._getItemId($target);
392
+ console.log(id)
393
f = f || {force: false};
394
if (!id || this.itemLoading) {
395
return;
721
_loadItem : function (e) {
722
var $iframe = $('<iframe webkitallowfullscreen mozallowfullscreen allowfullscreen />').src($(e.target).attr('href') + '?content-item-only=yes');
723
this.$('#popup-content-inner').html($iframe);
724
+ return '';
725
+ e.preventDefault();
726
+ $.ajax({
727
+ url : $(e.target).attr('href'),
728
+ success: this._ajaxLoadItemSuccess
729
+ });
730
},
731
_ajaxLoadItemSuccess: function (response) {
732
this.$('#popup-content-inner').html($(response).contents().find('.lp_course'));
assets/js/global.js CHANGED
@@ -557,14 +557,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 +572,7 @@ if (typeof window.LP == 'undefined') {
572
data = $.parseJSON(data);
573
}
574
} catch (e) {
575
data = {};
576
}
577
return data;
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
data = $.parseJSON(data);
573
}
574
} catch (e) {
575
+ LP.log(e);
576
data = {};
577
}
578
return data;
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/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/class-lp-assets.php CHANGED
@@ -285,7 +285,7 @@ class LP_Assets {
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' );
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' );
inc/class-lp-cache.php CHANGED
@@ -118,11 +118,6 @@ class LP_Cache {
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
*
@@ -624,30 +619,6 @@ class LP_Cache {
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
/**
652
* Flush cache by sections or LP group
653
*
@@ -679,6 +650,7 @@ class LP_Cache {
679
}
680
wp_cache_delete( $value, self::$_group );
681
}
682
} catch ( Exception $ex ) {
683
}
684
}
@@ -723,12 +695,8 @@ class LP_Cache {
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() {
118
*/
119
protected static $_quiz_history = 'user-quiz-history';
120
121
/**
122
* Set data to cache
123
*
619
return self::_get_cache( self::$_user_item_id, $key, $def );
620
}
621
622
/**
623
* Flush cache by sections or LP group
624
*
650
}
651
wp_cache_delete( $value, self::$_group );
652
}
653
+ add_filter( 'wp_redirect', array( __CLASS__, 'cache_flush' ) );
654
} catch ( Exception $ex ) {
655
}
656
}
695
}
696
697
public static function init() {
698
+ add_action( 'init', array( __CLASS__, 'redirect' ) );
699
700
}
701
702
public static function redirect() {
inc/class-lp-page-controller.php CHANGED
@@ -205,12 +205,9 @@ 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
/**
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
+ LP()->wp_query = clone( $wp_query );
210
+
211
212
$template = get_page_template();
213
/**
inc/class-lp-request-handler.php CHANGED
@@ -28,31 +28,25 @@ 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,10 +55,6 @@ 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
}
@@ -84,7 +74,7 @@ class LP_Request_Handler {
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 {
28
* Constructor
29
*/
30
public static function init() {
31
+ if(strtolower($_SERVER['REQUEST_METHOD']) == 'post'){
32
+ LP_Cache::flush();
33
+ //wp_cache_delete( 'course-curriculum', 'learnpress');
34
+ }
35
+ //add_action( 'wp_loaded', array( __CLASS__, 'get_header' ), - 1000 );
36
+ //add_action( 'wp_head', array( __CLASS__, 'process_request' ), 1000 );
37
+
38
+ //add_action( 'wp_loaded', array( __CLASS__, 'get_header' ), - 1000 );
39
+ //add_action( 'admin_head', array( __CLASS__, 'process_request' ), 1000 );
40
if ( is_admin() ) {
41
add_action( 'init', array( __CLASS__, 'process_request' ), 50 );
42
} else {
43
add_action( 'wp', array( __CLASS__, 'process_request' ), 50 );
44
}
45
46
LP_Request_Handler::register( 'purchase-course', 'learn_press_purchase_course_handler', 20 );
47
LP_Request_Handler::register( 'enroll-course', 'learn_press_purchase_course_handler', 20 );
48
}
49
50
public static function get_header() {
51
ob_start();
52
}
55
* Process actions
56
*/
57
public static function process_request() {
58
if ( !empty( $_REQUEST ) ) foreach ( $_REQUEST as $key => $value ) {
59
do_action( 'learn_press_request_handler_' . $key, $value, $_REQUEST );
60
}
74
if ( !$item['action'] || !$item['callback'] ) {
75
continue;
76
}
77
+ list( $action, $callback, $priority ) = array_values($item);
78
add_action( 'learn_press_request_handler_' . $action, $callback, $priority );
79
}
80
} else {
inc/class-lp-shortcodes.php CHANGED
@@ -70,6 +70,7 @@ 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();
@@ -439,7 +440,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 +469,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();
70
parse_str( $wp->matched_query, $query );
71
if ( empty( $query['view'] ) ) {
72
$redirect = learn_press_user_profile_link( $wp->query_vars['user'] );
73
+
74
if ( ! empty( $redirect ) ) {
75
wp_redirect( $redirect );
76
die();
440
),
441
$atts
442
);
443
+ $fields = array(
444
+ 'bat_name' => array(
445
+ 'title' => __( 'Name', 'learnpress' ),
446
+ 'type' => 'text',
447
+ 'placeholder' => __( 'Your name', 'learnpress' ),
448
+ 'def' => $user->display_name
449
+ ),
450
+ 'bat_email' => array(
451
+ 'title' => __( 'Email', 'learnpress' ),
452
+ 'type' => 'email',
453
+ 'placeholder' => __( 'Your email address', 'learnpress' ),
454
+ 'def' => $user->user_email
455
+ ),
456
+ 'bat_phone' => array(
457
+ 'title' => __( 'Phone', 'learnpress' ),
458
+ 'type' => 'text',
459
+ 'placeholder' => __( 'Your phone number', 'learnpress' )
460
+ )
461
+ );
462
+ $fields = apply_filters( 'learn_press_become_teacher_form_fields', $fields );
463
ob_start();
464
$args = array_merge(
465
array(
469
),
470
$atts
471
);
472
learn_press_get_template( 'global/become-teacher-form.php', $args );
473
474
$html = ob_get_clean();
inc/course/abstract-lp-course.php CHANGED
@@ -821,7 +821,7 @@ abstract class LP_Abstract_Course {
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)
@@ -1093,113 +1093,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 +1172,14 @@ 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
}
@@ -1290,9 +1195,7 @@ abstract class LP_Abstract_Course {
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
}
@@ -1315,17 +1218,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 +1234,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 +1261,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 +1380,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 +1404,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 +1428,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 +1455,4 @@ abstract class LP_Abstract_Course {
1584
return $embed;
1585
}
1586
1587
- }
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)
1093
1094
$quizzes = $this->get_quizzes();
1095
1096
+ if ( ( $this->course_result == 'evaluate_lesson' ) || !$quizzes ) {
1097
//$results = $this->_evaluate_course_by_items( $user_id, $force );
1098
$results = $this->_evaluate_course_by_lesson( $user_id, $force );
1099
+ } else {
1100
+ if ( $this->course_result == 'evaluate_final_quiz' ) {
1101
+ $results = $this->_evaluate_course_by_quiz( $user_id, $force );
1102
} else {
1103
+ $results = $this->_evaluate_course_by_quizzes( $user_id, $force );
1104
}
1105
}
1106
+ return apply_filters( 'learn_press_evaluation_course_results', $results );
1107
}
1108
1109
public function is_evaluation( $thing ) {
1172
/**
1173
* Get number of lessons user has completed
1174
*
1175
+ * @param $user_id
1176
+ * @param array $items
1177
+ * @param bool $force
1178
*
1179
* @return int|mixed|null|void
1180
*/
1181
public function get_completed_items( $user_id = 0, $force = false, $type = '' ) {
1182
+ // public function get_completed_items( $user_id = 0, $items = array(), $force = false, $type='' ) {
1183
if ( !$user_id ) {
1184
$user_id = get_current_user_id();
1185
}
1195
}
1196
$k = sprintf( '%d-%d-%d', $user_id, $this->id, $item_id );
1197
if ( !empty( $item_statuses[$k] ) && $item_statuses[$k] == 'completed' ) {
1198
+ $completed_items[] = $item_id;
1199
}
1200
}
1201
}
1218
return apply_filters( 'learn_press_count_user_completed_items', $count, $this->id, $user_id );
1219
}
1220
1221
/**
1222
* Calculate results of course by final quiz
1223
*
1234
1235
public function evaluate_quiz( $quiz_id, $user_id, $force = false ) {
1236
$user = learn_press_get_user( $user_id );
1237
+ $quiz = LP_Quiz::get_quiz( $quiz_id );
1238
$results = $user->get_quiz_results( $quiz_id, $this->id );
1239
if ( !$results ) {
1240
$result = 0;
1261
$quizzes = $this->get_quizzes();
1262
$result = 0;
1263
if ( $quizzes ) {
1264
foreach ( $quizzes as $quiz ) {
1265
$result += $this->evaluate_quiz( $quiz->ID, $user_id, $force );
1266
}
1267
+ $result = round( $result / sizeof( $quizzes ) );
1268
}
1269
return apply_filters( 'learn_press_evaluation_course_quizzes', $result, $this->id, $user_id );
1270
}
1380
* @return mixed
1381
*/
1382
public function output_args( $args = null ) {
1383
+
1384
+ $args = wp_parse_args( $args, array( 'echo' => true, 'user_id' => get_current_user_id() ) );
1385
+
1386
+ $user = learn_press_get_user( $args['user_id'] );
1387
+
1388
$output = array(
1389
'id' => $this->id,
1390
'url' => $this->get_permalink(),
1391
+ 'results' => $user->get_course_info( $this->id ),// $this->get_course_info( $args['user_id'] ),
1392
'current_item' => $this->is_viewing_item(),
1393
'items' => $this->get_items_params()
1394
);
1404
*/
1405
public function get_items_params( $user_id = null ) {
1406
global $wpdb;
1407
+ $user = learn_press_get_current_user( $user_id );
1408
+ $items = $this->get_curriculum_items(
1409
array(
1410
'field' => array( 'item_id', 'item_type', 'post_title', 'section_id' ),
1411
'field_map' => array( 'id', 'type', 'title' ),
1412
'field_format' => array( '%d', '%s', '%s', '%d' )
1413
)
1414
);
1415
if ( $items ) foreach ( $items as $k => $item ) {
1416
if ( ( $view = $user->can( 'view-item', $item['id'], $this->id ) ) !== false ) {
1417
+ $items[$k]['url'] = $this->get_item_link( $item['id'] );
1418
+ $items[$k]['status'] = $user->get_item_status( $item['id'], $this->id );
1419
if ( $view == 'preview' ) {
1420
1421
}
1428
return $items;
1429
}
1430
1431
1432
public function get_video_embed() {
1433
$video_id = $this->video_id;
1455
return $embed;
1456
}
1457
1458
+ }
inc/course/lp-course-functions.php CHANGED
@@ -773,34 +773,3 @@ function learn_press_prepare_archive_courses( $template ) {
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
- }
773
}
774
return $template;
775
}
inc/custom-post-types/course.php CHANGED
@@ -571,17 +571,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 +591,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 +754,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 +956,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 +1102,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,7 +1214,7 @@ 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'];
571
*
572
* @return mixed|null|void
573
*/
574
+ public
575
+ static function assessment_meta_box() {
576
$post_id = learn_press_get_request( 'post' );
577
$prefix = '_lp_';
578
+ $course_result_desc = __( 'The method to assess the result of a student for a course.', 'learnpress' );
579
+ if ( $post_id && get_post_meta( $post_id, '_lp_course_result', true ) == 'evaluate_final_quiz' && !get_post_meta( $post_id, '_lp_final_quiz', true ) ) {
580
$course_result_desc .= __( '<br /><strong>Note! </strong>No final quiz in course, please add a final quiz', 'learnpress' );
581
}
582
$meta_box = array(
591
'type' => 'radio',
592
'desc' => $course_result_desc,
593
'options' => array(
594
+ 'evaluate_lesson' => __( 'Evaluate lessons', 'learnpress' ),
595
+ 'evaluate_quizzes' => __( 'Evaluate result of quizzes', 'learnpress' ),
596
+ 'evaluate_final_quiz' => __( 'Evaluate the result of the final quiz', 'learnpress' )
597
),
598
'std' => 'evaluate_lesson',
599
),
600
array(
601
'name' => __( 'Passing condition value', 'learnpress' ),
754
public static function author_meta_box() {
755
756
$course_id = !empty( $_GET['post'] ) ? $_GET['post'] : 0;
757
+
758
+ $author = get_post( $course_id ) ? get_post( $course_id )->post_author : '';
759
760
$prefix = '_lp_';
761
956
if ( 'dopreview' == $preview && 'draft' == $post->post_status ) {
957
learn_press_add_message( __( 'Course Curriculum only appear if course is saved', 'learnpress' ), 'error' );
958
}
959
if ( !empty( $_REQUEST['_lp_curriculum'] ) && 'dopreview' !== $preview ) {
960
$section_order = 0;
961
$query_update = array();
1102
$submit_for_review = false;
1103
}
1104
if ( ( $submit_for_review || ( $old_status != $new_status ) ) && $post->post_status != 'auto-draft' ) {
1105
+ $action = 'for_reviewer';
1106
+ update_post_meta( $post->ID, '_lp_submit_for_reviewer', 'yes' );
1107
}
1108
}
1109
$message = learn_press_get_request( 'review-message' );
1214
private function _update_price() {
1215
global $wpdb, $post;
1216
$request = $_POST;
1217
+ $payment = learn_press_get_request('_lp_payment') == 1;
1218
$price = floatval( $request['_lp_price'] );
1219
$sale_price = $request['_lp_sale_price'];
1220
$sale_price_start = $request['_lp_sale_start'];
inc/custom-post-types/order.php CHANGED
@@ -29,7 +29,7 @@ if ( !class_exists( 'LP_Order_Post_Type' ) ) {
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 );
@@ -54,7 +54,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 +83,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 );
29
add_action( 'add_meta_boxes', array( $this, 'post_new' ) );
30
31
$this
32
+ ->add_map_method( 'before_delete', 'delete_order_items' )
33
->add_map_method( 'save', 'save_order' );
34
35
parent::__construct( $post_type );
54
*
55
* @param $post_id
56
*/
57
+ public function delete_order_items( $post_id ) {
58
global $wpdb, $post;
59
if ( get_post_type( $post_id ) != 'lp_order' ) {
60
return;
83
", $post_id );
84
$wpdb->query( $query );
85
86
// delete all data related user order
87
if ( $user_id ) {
88
learn_press_delete_user_data( $user_id );
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/lesson/lp-lesson-functions.php CHANGED
@@ -51,15 +51,15 @@ function learn_press_lesson_comment_form( $lesson_id, $course_id, $content_only
51
/**
52
* Add class css js-action to element comment reply
53
*/
54
- add_filter('comment_reply_link', 'lesson_comment_reply_link', 10, 4);
55
56
- if (!function_exists('lesson_comment_reply_link')) {
57
58
- function lesson_comment_reply_link($link, $args, $comment, $post) {
59
60
- $link = str_replace('comment-reply-link', 'comment-reply-link js-action', $link);
61
- return $link;
62
- }
63
}
64
65
/**
@@ -73,16 +73,4 @@ if ( !function_exists( 'lesson_cancel_comment_reply_link' ) ) {
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
- }
51
/**
52
* Add class css js-action to element comment reply
53
*/
54
+ add_filter( 'comment_reply_link', 'lesson_comment_reply_link', 10, 4 );
55
56
+ if ( !function_exists( 'lesson_comment_reply_link' ) ) {
57
58
+ function lesson_comment_reply_link( $link, $args, $comment, $post ) {
59
60
+ $link = str_replace( 'comment-reply-link', 'comment-reply-link js-action', $link );
61
+ return $link;
62
+ }
63
}
64
65
/**
73
$formatted_link = str_replace( 'cancel-comment-reply-link"', 'cancel-comment-reply-link" class="js-action"', $formatted_link );
74
return $formatted_link;
75
}
76
+ }
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/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/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
4
*/
5
$upload_dir = wp_upload_dir();
6
// version
7
+ define( 'LEARNPRESS_VERSION', '2.1.5.5' );
8
9
define( 'LP_WP_CONTENT', basename( WP_CONTENT_DIR ) );
10
inc/lp-core-functions.php CHANGED
@@ -1361,31 +1361,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 +1391,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 +1413,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 +1515,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
@@ -2246,7 +2203,7 @@ function learn_press_user_profile_link( $user_id = 0, $tab = null ) {
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 '';
@@ -2859,4 +2816,4 @@ function learn_press_validation_data_before_save( $value = '', $name = '' ) {
2859
}
2860
2861
return $value;
2862
- }
1361
return apply_filters( 'learn_press_user_maybe_is_a_teacher', $role, $user->id );
1362
}
1363
1364
function learn_press_process_become_a_teacher_form( $args = null ) {
1365
$user = learn_press_get_current_user();
1366
$error = false;
1391
$error = true;
1392
}
1393
}
1394
if ( !$error ) {
1395
$to_email = array( get_option( 'admin_email' ) );
1396
$message_headers = '';
1397
$subject = __( 'Please moderate', 'learnpress' );
1398
+ $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";
1399
1400
+ $notify_message .= sprintf( __( 'Name: %s', 'learnpress' ), $args['name'] ) . "\r\n";
1401
+ $notify_message .= sprintf( __( 'Email: %s', 'learnpress' ), $args['email'] ) . "\r\n";
1402
+ $notify_message .= sprintf( __( 'Phone: %s', 'learnpress' ), $args['phone'] ) . "\r\n";
1403
+ $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";
1404
$args = array(
1405
$to_email,
1406
( $subject ),
1413
1414
set_transient( 'learn_press_become_teacher_sent_' . $user->id, 'yes', HOUR_IN_SECONDS * 2 );
1415
}
1416
$return['result'] = $error ? 'error' : 'success';
1417
return $return;
1418
}
1515
* @param $data
1516
*/
1517
function learn_press_send_json( $data ) {
1518
+ echo '<!-- LP_AJAX_START -->';
1519
@header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
1520
echo wp_json_encode( $data );
1521
+ echo '<!-- LP_AJAX_END -->';
1522
die;
1523
}
1524
2203
if ( is_numeric( $user_id ) ) {
2204
$user = get_user_by( 'id', $user_id );
2205
} else {