PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.9
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.9
4.4.9 4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 All 140 releases
← All changes | inc/course/lp-course-functions.php +116 -143 4.1.7.2 → 4.4.9 View file →
@@ -51,9 +51,9 @@
51 51 * @param int $user_id
52 52 *
53 53 * @return string
54 54 * @since 3.0.0
55 - * @depecated 4.1.6.9
55 + * @deprecated 4.1.6.9
56 56 */
57 57 /*function learn_press_create_course_action_nonce( $action, $course_id = 0, $user_id = 0 ) {
58 58 return LP_Nonce_Helper::create_course( $action, $course_id, $user_id );
59 59 }*/
@@ -67,9 +67,9 @@
67 67 * @param int $user_id
68 68 *
69 69 * @return bool
70 70 * @since 3.0.0
71 - * @depecated 4.1.6.9
71 + * @deprecated 4.1.6.9
72 72 */
73 73 /*function learn_press_verify_course_action_nonce( $nonce, $action, $course_id = 0, $user_id = 0 ) {
74 74 return LP_Nonce_Helper::verify_course( $nonce, $action, $course_id, $user_id );
75 75 }*/
@@ -76,8 +76,10 @@
76 76
77 77 /**
78 78 * Get type of items are supported in course curriculum (post types).
79 79 * Default: [lp_lesson, lp_quiz]
80 + * When all addon use hook 'learn-press/course/item-types-support', will deprecate this function
81 + * @use CourseModel::item_types_support
80 82 *
81 83 * @return mixed
82 84 * @since 3.0.0
83 85 * @editor tungnx
@@ -82,8 +84,9 @@
82 84 * @since 3.0.0
83 85 * @editor tungnx
84 86 * @version 1.0.1
85 87 * @return array
88 + * @deprecated
86 89 */
87 90 function learn_press_get_course_item_types( bool $return_only_value = true ): array {
88 91 return apply_filters(
89 92 'learn-press/course-item-type',
@@ -129,9 +132,12 @@
129 132
130 133 return $wpdb->get_results( $query );
131 134 }
132 135
133 -function _learn_press_usort_terms_by_ID( $terms ) {
136 +/**
137 + * @deprecated 4.2.7.4
138 + */
139 +/*function _learn_press_usort_terms_by_ID( $terms ) {
134 140 $version = get_bloginfo( 'version' );
135 141 if ( version_compare( $version, '4.7', '>=' ) ) {
136 142 $terms = wp_list_sort( $terms, 'term_id' );
137 143 } else {
@@ -138,11 +144,11 @@
138 144 usort( $terms, '_usort_terms_by_ID' );
139 145 }
140 146
141 147 return $terms;
142 -}
148 +}*/
143 149
144 -function learn_press_course_post_type_link( $permalink, $post ) {
150 +/*function learn_press_course_post_type_link( $permalink, $post ) {
145 151 if ( $post->post_type !== 'lp_course' ) {
146 152 return $permalink;
147 153 }
148 154
@@ -203,11 +209,11 @@
203 209
204 210 $permalink = str_replace( $find, $replace, $permalink );
205 211
206 212 return $permalink;
207 -}
213 +}*/
208 214
209 -add_filter( 'post_type_link', 'learn_press_course_post_type_link', 10, 2 );
215 +//add_filter( 'post_type_link', 'learn_press_course_post_type_link', 10, 2 );
210 216
211 217 function learn_press_item_meta_format( $item, $nonce = '' ) {
212 218 if ( current_theme_supports( 'post-formats' ) ) {
213 219 $format = get_post_format( $item );
@@ -228,15 +234,18 @@
228 234 }
229 235 }
230 236 }
231 237
232 -function learn_press_course_item_format_exclude( $format, $item ) {
238 +/**
239 + * @deprecated 4.2.7.4
240 + */
241 +/*function learn_press_course_item_format_exclude( $format, $item ) {
233 242 if ( learn_press_get_post_type( $item ) != LP_LESSON_CPT || ( $format == 'standard' ) ) {
234 243 $format = false;
235 244 }
236 245
237 246 return $format;
238 -}
247 +}*/
239 248
240 249 /**
241 250 * Get curriculum of a course
242 251 *
@@ -243,15 +252,15 @@
243 252 * @param $course_id
244 253 *
245 254 * @return mixed
246 255 * @version 1.0
247 - *
256 + * @deprecated 4.2.7.4
248 257 */
249 -function learn_press_get_course_curriculum( $course_id ) {
258 +/*function learn_press_get_course_curriculum( $course_id ) {
250 259 $course = learn_press_get_course( $course_id );
251 260
252 261 return $course->get_curriculum();
253 -}
262 +}*/
254 263
255 264 /**
256 265 * Verify course access
257 266 *
@@ -261,9 +270,9 @@
261 270 * @return boolean
262 271 * @deprecated 4.1.3
263 272 * @editor tungnx
264 273 */
265 -function learn_press_is_enrolled_course( $course_id = null, $user_id = null ) {
274 +/*function learn_press_is_enrolled_course( $course_id = null, $user_id = null ) {
266 275 _deprecated_function( __FUNCTION__, '4.1.3' );
267 276 if ( $course = learn_press_get_course( $course_id ) && $user = learn_press_get_user( $user_id ) ) {
268 277 return $user->has_enrolled_course( $course_id );
269 278 }
@@ -268,9 +277,9 @@
268 277 return $user->has_enrolled_course( $course_id );
269 278 }
270 279
271 280 return false;
272 -}
281 +}*/
273 282
274 283 /**
275 284 * Detect if a course is free or not
276 285 *
@@ -276,16 +285,17 @@
276 285 *
277 286 * @param null $course_id
278 287 *
279 288 * @return bool
289 + * @deprecated 4.2.7.4
280 290 */
281 -function learn_press_is_free_course( $course_id = null ) {
291 +/*function learn_press_is_free_course( $course_id = null ) {
282 292 if ( ! $course_id ) {
283 293 $course_id = get_the_ID();
284 294 }
285 295
286 296 return learn_press_get_course( $course_id )->is_free();
287 -}
297 +}*/
288 298
289 299 /**
290 300 * get current status of user's course
291 301 *
@@ -293,11 +303,11 @@
293 303 * @param int $course_id
294 304 *
295 305 * @return string
296 306 * @author Tunn
297 - *
307 + * @deprecated 4.2.7.4
298 308 */
299 -function learn_press_get_user_course_status( $user_id = null, $course_id = null ) {
309 +/*function learn_press_get_user_course_status( $user_id = null, $course_id = null ) {
300 310 $course = learn_press_get_course( $course_id );
301 311 $user = learn_press_get_user( $user_id );
302 312
303 313 if ( $course && $user ) {
@@ -304,9 +314,9 @@
304 314 return $user->get_course_status( $course_id );
305 315 }
306 316
307 317 return false;
308 -}
318 +}*/
309 319
310 320 /**
311 321 * Wrap function can-view-item of user object.
312 322 *
@@ -318,14 +328,14 @@
318 328 * @since 3.1.0
319 329 *
320 330 */
321 331 //function learn_press_can_view_item( $item_id, $course_id = 0, $user_id = 0 ) {
322 -// if ( ! $user_id ) {
323 -// $user_id = get_current_user_id();
324 -// }
325 -// $user = learn_press_get_user( $user_id );
332 +// if ( ! $user_id ) {
333 +// $user_id = get_current_user_id();
334 +// }
335 +// $user = learn_press_get_user( $user_id );
326 336 //
327 -// return $user->can_view_item( $item_id, $course_id );
337 +// return $user->can_view_item( $item_id, $course_id );
328 338 //}
329 339
330 340 /**
331 341 * Get course setting is enroll required or public
@@ -333,17 +343,17 @@
333 343 * @param int $course_id
334 344 *
335 345 * @return boolean
336 346 * @since 0.9.5
337 - *
347 + * @deprecated 4.2.7.4
338 348 */
339 -function learn_press_course_enroll_required( $course_id = null ) {
349 +/*function learn_press_course_enroll_required( $course_id = null ) {
340 350 $course_id = learn_press_get_course_id( $course_id );
341 351
342 352 $required = ( 'yes' == get_post_meta( $course_id, '_lpr_course_enrolled_require', true ) );
343 353
344 354 return apply_filters( 'learn_press_course_enroll_required', $required, $course_id );
345 -}
355 +}*/
346 356
347 357 function learn_press_get_all_courses( $args = array() ) {
348 358 $term = '';
349 359 $exclude = '';
@@ -361,9 +371,12 @@
361 371
362 372 return apply_filters( 'learn_press_get_courses', $posts, $args );
363 373 }
364 374
365 -function learn_press_search_post_excerpt( $where = '' ) {
375 +/**
376 + * @deprecated 4.2.7.4
377 + */
378 +/*function learn_press_search_post_excerpt( $where = '' ) {
366 379 global $wp_the_query, $wpdb;
367 380
368 381 if ( empty( $wp_the_query->query_vars['s'] ) ) {
369 382 return $where;
@@ -375,9 +388,9 @@
375 388 $where
376 389 );
377 390
378 391 return $where;
379 -}
392 +}*/
380 393
381 394 // add_filter( 'posts_where', 'learn_press_search_post_excerpt' );
382 395
383 396 function learn_press_get_course_user( $course_id = null ) {
@@ -390,19 +403,17 @@
390 403
391 404 /**
392 405 * Get item types support in course curriculum.
393 406 *
394 - * @param bool $keys
395 - *
396 - * @return mixed|null
407 + * @return array
397 408 */
398 -function learn_press_course_get_support_item_types( $keys = false ) {
399 - $types = array();
400 - if ( ! empty( $GLOBALS['learn_press_course_support_item_types'] ) ) {
401 - $types = $GLOBALS['learn_press_course_support_item_types'];
402 - }
409 +function learn_press_course_get_support_item_types() {
410 + $types = [
411 + LP_LESSON_CPT => __( 'Lesson', 'learnpress' ),
412 + LP_QUIZ_CPT => __( 'Quiz', 'learnpress' ),
413 + ];
403 414
404 - return apply_filters( 'learn-press/course-support-items', $keys ? array_keys( $types ) : $types, $keys );
415 + return apply_filters( 'learn-press/course-support-items', $types, false );
405 416 }
406 417
407 418 /**
408 419 * Register new type of course item
@@ -408,10 +419,11 @@
408 419 * Register new type of course item
409 420 *
410 421 * @param string $post_type - Usually is post type
411 422 * @param string $label - Name show for user
423 + * @deprecated 4.2.7.4
412 424 */
413 -function learn_press_course_add_support_item_type( $post_type, $label = '' ) {
425 +/*function learn_press_course_add_support_item_type( $post_type, $label = '' ) {
414 426 if ( empty( $GLOBALS['learn_press_course_support_item_types'] ) ) {
415 427 $GLOBALS['learn_press_course_support_item_types'] = array();
416 428 }
417 429 if ( func_num_args() == 1 && is_array( func_get_arg( 0 ) ) ) {
@@ -420,9 +432,9 @@
420 432 }
421 433 } elseif ( func_num_args() == 2 ) {
422 434 $GLOBALS['learn_press_course_support_item_types'][ func_get_arg( 0 ) ] = func_get_arg( 1 );
423 435 }
424 -}
436 +}*/
425 437
426 438 /**
427 439 * Check if course is support an item's type.
428 440 *
@@ -444,14 +456,17 @@
444 456
445 457 return $support;
446 458 }
447 459
448 -learn_press_course_add_support_item_type(
460 +/**
461 + * @deprecated 4.2.7.4
462 + */
463 +/*learn_press_course_add_support_item_type(
449 464 array(
450 465 'lp_lesson' => __( 'Lesson', 'learnpress' ),
451 466 'lp_quiz' => __( 'Quiz', 'learnpress' ),
452 467 )
453 -);
468 +);*/
454 469
455 470 function learn_press_add_course_item_feature( $type, $feature ) {
456 471 $features = array();
457 472 if ( ! empty( $GLOBALS['learn_press_course_item_features'] ) ) {
@@ -504,9 +519,9 @@
504 519 * @param int $item_id
505 520 *
506 521 * @return string
507 522 * @since 3.0.0
508 - *
523 + * Addon Assignment 4.1.1 still use
509 524 */
510 525 function learn_press_get_course_item_permalink( int $course_id = 0, int $item_id = 0 ): string {
511 526 $course = learn_press_get_course( $course_id );
512 527 if ( $course ) {
@@ -515,25 +530,20 @@
515 530
516 531 return '';
517 532 }
518 533
519 -
534 +/**
535 + * @deprecated 4.2.2
536 + */
520 537 function learn_press_get_the_course() {
521 - static $course;
522 - if ( ! $course ) {
523 - $course_id = get_the_ID();
524 - if ( learn_press_get_post_type( $course ) == LP_COURSE_CPT ) {
525 - $course = learn_press_get_course( $course_id );
526 - }
527 - }
528 - if ( ! $course ) {
529 - return new LP_Course( 0 );
530 - }
531 -
532 - return $course;
538 + _deprecated_function( __FUNCTION__, '4.2.2', 'learn_press_get_course' );
539 + return learn_press_get_course();
533 540 }
534 541
535 -function learn_press_get_user_question_answer( $args = '' ) {
542 +/**
543 + * @deprecated 4.2.7.4
544 + */
545 +/*function learn_press_get_user_question_answer( $args = '' ) {
536 546 $args = wp_parse_args(
537 547 $args,
538 548 array(
539 549 'question_id' => 0,
@@ -560,19 +570,25 @@
560 570 }
561 571 }
562 572
563 573 return $answered;
564 -}
574 +}*/
565 575
566 -function need_to_updating() {
576 +/**
577 + * @deprecated 4.2.7.4
578 + */
579 +/*function need_to_updating() {
567 580 ob_start();
568 581 learn_press_display_message( 'This function need to updating' );
569 582
570 583 return ob_get_clean();
571 -}
584 +}*/
572 585
573 -/* filter section item single course */
574 -function learn_press_get_course_sections() {
586 +/**
587 + * filter section item single course
588 + * @deprecated 4.2.7.4
589 + */
590 +/*function learn_press_get_course_sections() {
575 591 return apply_filters(
576 592 'learn_press_get_course_sections',
577 593 array(
578 594 'lp_lesson',
@@ -578,23 +594,29 @@
578 594 'lp_lesson',
579 595 'lp_quiz',
580 596 )
581 597 );
582 -}
598 +}*/
583 599
584 -function lean_press_get_course_sections() {
600 +/**
601 + * @deprecated 4.2.7.4
602 + */
603 +/*function lean_press_get_course_sections() {
585 604 _deprecated_function( __FUNCTION__, '2.1', 'learn_press_get_course_sections' );
586 605
587 606 return learn_press_get_course_sections();
588 -}
607 +}*/
589 608
590 -if ( ! function_exists( 'learn_press_get_course_item_url' ) ) {
609 +/**
610 + * @deprecated 4.2.7.4
611 + */
612 +/*if ( ! function_exists( 'learn_press_get_course_item_url' ) ) {
591 613 function learn_press_get_course_item_url( $course_id = null, $item_id = null ) {
592 614 $course = learn_press_get_course( $course_id );
593 615
594 616 return $course ? $course->get_item_link( $item_id ) : false;
595 617 }
596 -}
618 +}*/
597 619
598 620 /**
599 621 * Add filter to WP comment form of lesson or quiz to output ID of current course.
600 622 *
@@ -655,9 +677,9 @@
655 677 * @param int $comment_id
656 678 * @param string $status
657 679 *
658 680 * @since 3.0.10
659 - * @depecated 4.1.6.9
681 + * @deprecated 4.1.6.9
660 682 *
661 683 */
662 684 /*function learn_press_force_refresh_course( $comment_id, $status ) {
663 685
@@ -673,38 +695,10 @@
673 695
674 696 add_action( 'comment_post', 'learn_press_force_refresh_course', 1000, 2 );*/
675 697
676 698 /**
677 - * @editor tungnx | comment code
678 - * @deprecated 3.2.7.5
699 + * @deprecated 4.1.6.9
679 700 */
680 -/*if ( ! function_exists( 'learn_press_get_sample_link_course_item_url' ) ) {
681 -
682 - function learn_press_get_sample_link_course_item_url( $item_id = null ) {
683 -
684 - if ( ! $item_id ) {
685 - return;
686 - }
687 -
688 -
689 - $permalink = get_the_permalink( $item_id );
690 - $post_name = get_post_field( 'post_name', $item_id );
691 -
692 - if ( '' != get_option( 'permalink_structure' ) ) {
693 - $permalink = $post_name;
694 - } else {
695 - $key = preg_replace( '!lp_!', '', learn_press_get_post_type( $item_id ) );
696 - $permalink = add_query_arg( array( $key => $post_name ), $permalink );
697 - }
698 -
699 - return $permalink;
700 -
701 - }
702 -}*/
703 -
704 -/**
705 - * @depecated 4.1.6.9
706 - */
707 701 /*if ( ! function_exists( 'learn_press_get_nav_course_item_url' ) ) {
708 702 function learn_press_get_nav_course_item_url( $course_id = null, $item_id = null, $content_only = false ) {
709 703
710 704 $course = learn_press_get_course( $course_id );
@@ -742,37 +736,12 @@
742 736 return $return;
743 737 }
744 738 }*/
745 739
746 -if ( ! function_exists( 'learn_press_edit_item_link' ) ) {
747 - /**
748 - * Displaying course items navigation
749 - *
750 - * @param null $item_id
751 - * @param null $course_id
752 - * @param bool $content_only
753 - */
754 - function learn_press_edit_item_link( $item_id = null, $course_id = null, $content_only = false ) {
755 - $user = learn_press_get_current_user();
756 - if ( $user->can_edit_item( $item_id, $course_id ) ) : ?>
757 - <p class="edit-course-item-link">
758 - <a href="<?php echo get_edit_post_link( $item_id ); ?>">
759 - <?php
760 - _e(
761 - 'Edit this item',
762 - 'learnpress'
763 - );
764 - ?>
765 - </a>
766 - </p>
767 - <?php
768 - endif;
769 - }
770 -}
771 740 /**
772 741 * Get course id of an item by id
773 742 *
774 - * @depecated 4.1.6.9
743 + * @deprecated 4.1.6.9
775 744 */
776 745
777 746 if ( ! function_exists( 'learn_press_get_item_course_id' ) ) {
778 747
@@ -891,18 +860,17 @@
891 860 * @since 3.0.0
892 861 *
893 862 */
894 863 function learn_press_get_preview_url( $post_id ) {
895 - return
896 - esc_url_raw(
897 - add_query_arg(
898 - array(
899 - 'lp-preview' => $post_id,
900 - '_wpnonce' => wp_create_nonce( 'lp-preview' ),
901 - ),
902 - trailingslashit( get_home_url() )
903 - )
904 - );
864 + return esc_url_raw(
865 + add_query_arg(
866 + array(
867 + 'lp-preview' => $post_id,
868 + '_wpnonce' => wp_create_nonce( 'lp-preview' ),
869 + ),
870 + trailingslashit( get_home_url() )
871 + )
872 + );
905 873 }
906 874
907 875 if ( ! function_exists( 'learn_press_course_item_type_link' ) ) {
908 876 /**
@@ -990,9 +958,12 @@
990 958
991 959 return $html;
992 960 }
993 961
994 -function learn_press_get_course_results_tooltip( $course_id ) {
962 +/**
963 + * @deprecated 4.2.7.4
964 + */
965 +/*function learn_press_get_course_results_tooltip( $course_id ) {
995 966 $metabox = LP_Course_Post_Type::assessment_meta_box();
996 967 $options = $metabox['fields'][0]['options'];
997 968 $cr = get_post_meta( $course_id, '_lp_course_result', true );
998 969 $tooltip = ! empty( $options[ $cr ] ) ? $options[ $cr ] : false;
@@ -1002,9 +973,9 @@
1002 973 }
1003 974 }
1004 975
1005 976 return $tooltip;
1006 -}
977 +}*/
1007 978
1008 979 function learn_press_course_passing_condition( $value, $format, $course_id ) {
1009 980 $course = learn_press_get_course( $course_id );
1010 981 $quiz_id = $course->get_final_quiz();
@@ -1023,13 +994,16 @@
1023 994 }
1024 995
1025 996 add_filter( 'learn-press/course-passing-condition', 'learn_press_course_passing_condition', 10, 3 );
1026 997
998 +/**
999 + * @deprecated 4.2.7.4
1000 + */
1027 1001 function learn_press_remove_query_var_enrolled_course( $redirect ) {
1028 1002 return esc_url_raw( remove_query_arg( 'enroll-course', $redirect ) );
1029 1003 }
1030 1004
1031 -add_filter( 'learn-press/enroll-course-redirect', 'learn_press_remove_query_var_enrolled_course' );
1005 +//add_filter( 'learn-press/enroll-course-redirect', 'learn_press_remove_query_var_enrolled_course' );
1032 1006
1033 1007 /**
1034 1008 * Mark the user to know if they have just logged in
1035 1009 * for some purpose.
@@ -1035,14 +1009,13 @@
1035 1009 * for some purpose.
1036 1010 *
1037 1011 * @since 3.0.0
1038 1012 */
1039 -function learn_press_mark_user_just_logged_in() {
1013 +/*function learn_press_mark_user_just_logged_in() {
1040 1014 LearnPress::instance()->session->set( 'user_just_logged_in', 'yes' );
1041 1015 }
1016 +add_action( 'wp_login', 'learn_press_mark_user_just_logged_in' );*/
1042 1017
1043 -add_action( 'wp_login', 'learn_press_mark_user_just_logged_in' );
1044 -
1045 1018 function learn_press_translate_course_result_required( $course ) {
1046 1019 if ( ! $course ) {
1047 1020 return '';
1048 1021 }
@@ -1051,21 +1024,21 @@
1051 1024
1052 1025 $evaluate_type = $course->get_data( 'course_result', 'evaluate_lesson' );
1053 1026 switch ( $evaluate_type ) {
1054 1027 case 'evaluate_lesson':
1055 - $label = esc_html__( 'lessons completed per total number of lessons.', 'learnpress' );
1028 + $label = esc_html__( 'completed lessons per the total number of lessons.', 'learnpress' );
1056 1029 break;
1057 1030 case 'evaluate_quiz':
1058 - $label = esc_html__( 'quizzes passed per total number of quizzes.', 'learnpress' );
1031 + $label = esc_html__( 'passed quizzes per the total number of quizzes.', 'learnpress' );
1059 1032 break;
1060 1033 case 'evaluate_final_quiz':
1061 1034 $label = esc_html__( 'Final Quiz', 'learnpress' );
1062 1035 break;
1063 1036 case 'evaluate_questions':
1064 - $label = esc_html__( 'correct answers per total number of questions.', 'learnpress' );
1037 + $label = esc_html__( 'correct answers per the total number of questions.', 'learnpress' );
1065 1038 break;
1066 1039 case 'evaluate_mark':
1067 - $label = esc_html__( 'score achieved per total score of the questions.', 'learnpress' );
1040 + $label = esc_html__( 'score achieved per the total score of the questions.', 'learnpress' );
1068 1041 break;
1069 1042 default:
1070 1043 $label = apply_filters( 'learnpress/message/evaluate/' . $evaluate_type, $evaluate_type );
1071 1044 break;