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/lp-core-functions.php +193 -1110 4.1.7.2 → 4.4.9 View file →
@@ -7,8 +7,10 @@
7 7 * @package LearnPress/Functions
8 8 * @version 1.0
9 9 */
10 10
11 +use LearnPress\Helpers\Config;
12 +
11 13 defined( 'ABSPATH' ) || exit;
12 14
13 15 /**
14 16 * Vue write php has script, so when sanitize will error, so use code is mask pass check sanitize, esc
@@ -39,38 +41,13 @@
39 41 return $can_edit;
40 42 }
41 43 add_filter( 'use_block_editor_for_post_type', 'learnpress_gutenberg_disable_cpt', 10, 2 );
42 44
43 -/**
44 - * Get instance of a CURD class by type
45 - *
46 - * @param string $type
47 - *
48 - * @return bool|LP_Course_CURD|LP_User_CURD|LP_Quiz_CURD|LP_Question_CURD
49 - * @depecated 4.1.7.2
50 - */
51 -/*function learn_press_get_curd( $type ) {
52 - $curds = array(
53 - 'user' => 'LP_User_CURD',
54 - 'course' => 'LP_Course_CURD',
55 - 'quiz' => 'LP_Quiz_CURD',
56 - 'question' => 'LP_Question_CURD',
57 - );
58 -
59 - $curd = false;
60 -
61 - if ( ! empty( $curds[ $type ] ) && class_exists( $curds[ $type ] ) ) {
62 - $curd = new $curds[ $type ]();
63 - }
64 -
65 - return apply_filters( 'learn-press/curd', $curd, $type, $curds );
66 -}*/
67 -
68 45 if ( ! function_exists( 'lp_add_body_class' ) ) {
69 46 function lp_add_body_class( $classes ) {
70 47 $classes = (array) $classes;
71 48
72 - if ( learn_press_is_profile() ) {
49 + if ( LP_Page_Controller::is_page_profile() ) {
73 50 $classes[] = 'learnpress-profile';
74 51 } elseif ( learn_press_is_checkout() ) {
75 52 $classes[] = 'learnpress-checkout';
76 53 }
@@ -127,9 +104,9 @@
127 104 }
128 105 $atts = ' ' . implode( ' ', $options );
129 106 }
130 107
131 - $tip = sprintf( '<span class="learn-press-tip" ' . $atts . '>%s</span>', $tip );
108 + $tip = sprintf( '<div class="learn-press-tip" ' . $atts . '><span>%s</span></div>', $tip );
132 109
133 110 if ( $echo ) {
134 111 echo wp_kses_post( $tip );
135 112 }
@@ -295,39 +272,39 @@
295 272 /**
296 273 * Get current URL user is viewing.
297 274 *
298 275 * @return string
276 + * @deprecated 4.2.2
299 277 */
300 278 function learn_press_get_current_url() {
301 - static $current_url;
279 + //_deprecated_function( __FUNCTION__, '4.2.2', 'LP_Helper::getUrlCurrent' );
280 + return LP_Helper::getUrlCurrent();
302 281
303 - if ( ! $current_url ) {
304 - $url = untrailingslashit( esc_url_raw( $_SERVER['REQUEST_URI'] ) );
282 + $url = untrailingslashit( esc_url_raw( $_SERVER['REQUEST_URI'] ) );
305 283
306 - if ( ! preg_match( '!^https?!', $url ) ) {
307 - $siteurl = trailingslashit( get_home_url() );
308 - $home_query = '';
284 + if ( ! preg_match( '!^https?!', $url ) ) {
285 + $siteurl = trailingslashit( get_home_url() );
286 + $home_query = '';
309 287
310 - if ( strpos( $siteurl, '?' ) !== false ) {
311 - $parts = explode( '?', $siteurl );
312 - $home_query = $parts[1];
313 - $siteurl = $parts[0];
314 - }
288 + if ( strpos( $siteurl, '?' ) !== false ) {
289 + $parts = explode( '?', $siteurl );
290 + $home_query = $parts[1];
291 + $siteurl = $parts[0];
292 + }
315 293
316 - if ( $home_query ) {
317 - parse_str( untrailingslashit( $home_query ), $home_query );
318 - $url = esc_url_raw( add_query_arg( $home_query, $url ) );
319 - }
294 + if ( $home_query ) {
295 + parse_str( untrailingslashit( $home_query ), $home_query );
296 + $url = esc_url_raw( add_query_arg( $home_query, $url ) );
297 + }
320 298
321 - $segs1 = explode( '/', $siteurl );
322 - $segs2 = explode( '/', $url );
299 + $segs1 = explode( '/', $siteurl );
300 + $segs2 = explode( '/', $url );
323 301
324 - if ( $removed = array_intersect( $segs1, $segs2 ) ) {
325 - if ( $segs2 = array_diff( $segs2, $removed ) ) {
326 - $current_url = $siteurl . join( '/', $segs2 );
327 - if ( strpos( $current_url, '?' ) === false ) {
328 - $current_url = trailingslashit( $current_url );
329 - }
302 + if ( $removed = array_intersect( $segs1, $segs2 ) ) {
303 + if ( $segs2 = array_diff( $segs2, $removed ) ) {
304 + $current_url = $siteurl . join( '/', $segs2 );
305 + if ( strpos( $current_url, '?' ) === false ) {
306 + $current_url = trailingslashit( $current_url );
330 307 }
331 308 }
332 309 }
333 310 }
@@ -335,21 +312,8 @@
335 312 return $current_url;
336 313 }
337 314
338 315 /**
339 - * Compares an url with current URL user is viewing
340 - *
341 - * @param string $url
342 - *
343 - * @return bool
344 - */
345 -function learn_press_is_current_url( $url ) {
346 - $current_url = learn_press_get_current_url();
347 -
348 - return ( $current_url && $url ) && strcmp( $current_url, learn_press_sanitize_url( $url ) ) == 0;
349 -}
350 -
351 -/**
352 316 * Remove unneeded characters in an URL
353 317 *
354 318 * @param string $url
355 319 * @param bool $trailingslashit
@@ -363,9 +327,9 @@
363 327 $url_without_http = preg_replace( '![/]+!', '/', $url_without_http );
364 328 $url = $matches[1] . $url_without_http;
365 329
366 330 return ( $trailingslashit &&
367 - strpos( $url, '?' ) === false ) ? trailingslashit( $url ) : untrailingslashit( $url );
331 + strpos( $url, '?' ) === false ) ? trailingslashit( $url ) : untrailingslashit( $url );
368 332 }
369 333
370 334 return $url;
371 335 }
@@ -449,11 +413,11 @@
449 413 // This isn't needed for get_terms
450 414 unset( $args['orderby'] );
451 415
452 416 // Set args for get_terms
453 - $args['menu_order'] = isset( $args['order'] ) ? $args['order'] : 'ASC';
454 - $args['hide_empty'] = isset( $args['hide_empty'] ) ? $args['hide_empty'] : 0;
455 - $args['fields'] = isset( $args['fields'] ) ? $args['fields'] : 'names';
417 + $args['menu_order'] = $args['order'] ?? 'ASC';
418 + $args['hide_empty'] = $args['hide_empty'] ?? 0;
419 + $args['fields'] = $args['fields'] ?? 'names';
456 420
457 421 // Ensure slugs is valid for get_terms - slugs isn't supported
458 422 $args['fields'] = $args['fields'] === 'slugs' ? 'id=>slug' : $args['fields'];
459 423 $terms = get_terms( $taxonomy, $args );
@@ -545,16 +509,18 @@
545 509 * Get page id from admin settings page
546 510 *
547 511 * @param string $name
548 512 *
513 + * @since 3.0.0
514 + * @version 1.0.2
549 515 * @return int
550 516 */
551 517 function learn_press_get_page_id( string $name ): int {
552 - $page_id = LP_Settings::instance()->get( "{$name}_page_id", false );
518 + $page_id = LP_Settings::get_option( "{$name}_page_id", false );
553 519
554 - if ( function_exists( 'icl_object_id' ) ) {
520 + /*if ( function_exists( 'icl_object_id' ) ) {
555 521 $page_id = icl_object_id( $page_id, 'page', false, defined( 'ICL_LANGUAGE_CODE' ) ? ICL_LANGUAGE_CODE : '' );
556 - }
522 + }*/
557 523
558 524 $page_id = (int) $page_id;
559 525
560 526 return apply_filters( 'learn_press_get_page_id', $page_id, $name );
@@ -657,9 +623,9 @@
657 623
658 624 if ( $links ) {
659 625 ?>
660 626 <div class="<?php echo esc_attr( $args['wrapper_class'] ); ?>">
661 - <?php echo wp_kses_post( $links ); ?>
627 + <?php echo wp_kses_post( $links ); ?>
662 628 </div>
663 629 <?php
664 630 }
665 631
@@ -690,9 +656,9 @@
690 656
691 657 $pages = absint( $total / $limit );
692 658
693 659 if ( $total % $limit != 0 ) {
694 - $pages ++;
660 + ++$pages;
695 661 }
696 662
697 663 return $pages;
698 664 }
@@ -785,66 +751,8 @@
785 751 return $a1;
786 752 }
787 753
788 754 /**
789 - * Send email notification.
790 - *
791 - * @param string $to .
792 - * @param string $action .
793 - * @param array $vars .
794 - *
795 - * @return bool
796 - * @depecated 4.1.7.2
797 - */
798 -/*function learn_press_send_mail( $to = '', $action = '', $vars = array() ) {
799 - $email_settings = LP_Settings::instance();
800 -
801 - if ( ! $email_settings->get( $action . '.enable' ) ) {
802 - return "The action {$action} doesnt support";
803 - }
804 -
805 - $user = get_user_by( 'email', $to );
806 -
807 - $vars['log_in'] = apply_filters( 'learn_press_site_url', get_home_url() );
808 -
809 - // Send email.
810 - $email = new LP_Email();
811 - $email->set_action( $action );
812 - $email->parse_email( $vars );
813 - $email->add_recipient( $to );
814 -
815 - return $email->send();
816 -}*/
817 -
818 -/*
819 - * Send email notification when a course be published
820 - * @deprecated 4.1.7.2
821 - */
822 -/*function learn_press_publish_course( $new_status, $old_status, $post ) {
823 - if ( $old_status == 'pending' && $new_status == 'publish' && $post->post_type == 'lp_course' ) {
824 - $instructor = get_userdata( $post->post_author );
825 - $mail_to = $instructor->user_email;
826 -
827 - learn_press_send_mail(
828 - $mail_to,
829 - 'published_course',
830 - apply_filters(
831 - 'learn_press_vars_enrolled_course',
832 - array(
833 - 'user_name' => $instructor->display_name,
834 - 'course_name' => $post->post_title,
835 - 'course_link' => get_permalink( $post->ID ),
836 - ),
837 - $post,
838 - $instructor
839 - )
840 - );
841 - }
842 -}*/
843 -
844 -//add_action( 'transition_post_status', 'learn_press_publish_course', 10, 3 );
845 -
846 -/**
847 755 * @param $user_id
848 756 *
849 757 * @return WP_Query
850 758 */
@@ -925,365 +833,35 @@
925 833 /**
926 834 * Get the list of currencies with code and name.
927 835 *
928 836 * @return array
929 - * @version 3.0.0
837 + * @version 3.0.1
930 838 *
931 839 * @author ThimPress
932 840 */
933 841 function learn_press_currencies() {
934 - $currencies = array(
935 - 'AFN' => __( 'Afghan afghani', 'learnpress' ),
936 - 'ALL' => __( 'Albanian lek', 'learnpress' ),
937 - 'DZD' => __( 'Algerian dinar', 'learnpress' ),
938 - 'EUR' => __( 'Euro', 'learnpress' ),
939 - 'AOA' => __( 'Angolan kwanza', 'learnpress' ),
940 - 'XCD' => __( 'East Caribbean dollar', 'learnpress' ),
941 - 'ARS' => __( 'Argentine peso', 'learnpress' ),
942 - 'AMD' => __( 'Armenian dram', 'learnpress' ),
943 - 'AWG' => __( 'Aruban florin', 'learnpress' ),
944 - 'AUD' => __( 'Australian dollar', 'learnpress' ),
945 - 'AZN' => __( 'Azerbaijani manat', 'learnpress' ),
946 - 'BSD' => __( 'Bahamian dollar', 'learnpress' ),
947 - 'BHD' => __( 'Bahraini dinar', 'learnpress' ),
948 - 'BDT' => __( 'Bangladeshi taka', 'learnpress' ),
949 - 'BBD' => __( 'Barbadian dollar', 'learnpress' ),
950 - 'BYR' => __( 'Belarusian ruble', 'learnpress' ),
951 - 'BZD' => __( 'Belizean dollar', 'learnpress' ),
952 - 'XOF' => __( 'West African CFA franc', 'learnpress' ),
953 - 'BMD' => __( 'Bermudian dollar', 'learnpress' ),
954 - 'BTN' => __( 'Bhutanese ngultrum', 'learnpress' ),
955 - 'BOB' => __( 'Bolivian boliviano', 'learnpress' ),
956 - 'USD' => __( 'US dollar', 'learnpress' ),
957 - 'BAM' => __( 'Bosnia and Herzegovina convertible mark', 'learnpress' ),
958 - 'BWP' => __( 'Botswana pula', 'learnpress' ),
959 - 'BRL' => __( 'Brazilian real', 'learnpress' ),
960 - 'BND' => __( 'Brunei dollar', 'learnpress' ),
961 - 'BGN' => __( 'Bulgarian lev', 'learnpress' ),
962 - 'MMK' => __( 'Burmese kyat', 'learnpress' ),
963 - 'BIF' => __( 'Burundian franc', 'learnpress' ),
964 - 'KHR' => __( 'Cambodian riel', 'learnpress' ),
965 - 'XAF' => __( 'Central African CFA franc', 'learnpress' ),
966 - 'CAD' => __( 'Canadian dollar', 'learnpress' ),
967 - 'CVE' => __( 'Cape Verdean escudo', 'learnpress' ),
968 - 'KYD' => __( 'Cayman Islands dollar', 'learnpress' ),
969 - 'CLP' => __( 'Chilean peso', 'learnpress' ),
970 - 'CNY' => __( 'Chinese renminbi', 'learnpress' ),
971 - 'COP' => __( 'Colombian peso', 'learnpress' ),
972 - 'KMF' => __( 'Comorian franc', 'learnpress' ),
973 - 'CDF' => __( 'Congolese franc', 'learnpress' ),
974 - 'NZD' => __( 'New Zealand dollar', 'learnpress' ),
975 - 'CRC' => __( 'Costa Rican colón', 'learnpress' ),
976 - 'HRK' => __( 'Croatian kuna', 'learnpress' ),
977 - 'CUC' => __( 'Cuban peso', 'learnpress' ),
978 - 'ANG' => __( 'Netherlands Antilles guilder', 'learnpress' ),
979 - 'CZK' => __( 'Czech koruna', 'learnpress' ),
980 - 'DKK' => __( 'Danish krone', 'learnpress' ),
981 - 'DJF' => __( 'Djiboutian franc', 'learnpress' ),
982 - 'DOP' => __( 'Dominican peso', 'learnpress' ),
983 - 'EGP' => __( 'Egyptian pound', 'learnpress' ),
984 - 'SVC' => __( 'Salvadoran colón', 'learnpress' ),
985 - 'ERN' => __( 'Eritrean nakfa', 'learnpress' ),
986 - 'ETB' => __( 'Ethiopian birr', 'learnpress' ),
987 - 'FKP' => __( 'Falkland Islands pound', 'learnpress' ),
988 - 'FJD' => __( 'Fijian dollar', 'learnpress' ),
989 - 'XPF' => __( 'CFP franc', 'learnpress' ),
990 - 'GMD' => __( 'Gambian dalasi', 'learnpress' ),
991 - 'GEL' => __( 'Georgian lari', 'learnpress' ),
992 - 'GHS' => __( 'Ghanian cedi', 'learnpress' ),
993 - 'GIP' => __( 'Gibraltar pound', 'learnpress' ),
994 - 'GTQ' => __( 'Guatemalan quetzal', 'learnpress' ),
995 - 'GBP' => __( 'British pound', 'learnpress' ),
996 - 'GNF' => __( 'Guinean franc', 'learnpress' ),
997 - 'GYD' => __( 'Guyanese dollar', 'learnpress' ),
998 - 'HTG' => __( 'Haitian gourde', 'learnpress' ),
999 - 'HNL' => __( 'Honduran lempira', 'learnpress' ),
1000 - 'HKD' => __( 'Hong Kong dollar', 'learnpress' ),
1001 - 'HUF' => __( 'Hungarian forint', 'learnpress' ),
1002 - 'ISK' => __( 'Icelandic króna', 'learnpress' ),
1003 - 'INR' => __( 'Indian rupee', 'learnpress' ),
1004 - 'IDR' => __( 'Indonesian rupiah', 'learnpress' ),
1005 - 'IRR' => __( 'Iranian rial', 'learnpress' ),
1006 - 'IQD' => __( 'Iraqi dinar', 'learnpress' ),
1007 - 'ILS' => __( 'Israeli new sheqel', 'learnpress' ),
1008 - 'JMD' => __( 'Jamaican dollar', 'learnpress' ),
1009 - 'JPY' => __( 'Japanese yen ', 'learnpress' ),
1010 - 'JOD' => __( 'Jordanian dinar', 'learnpress' ),
1011 - 'KZT' => __( 'Kazakhstani tenge', 'learnpress' ),
1012 - 'KES' => __( 'Kenyan shilling', 'learnpress' ),
1013 - 'KPW' => __( 'North Korean won', 'learnpress' ),
1014 - 'KWD' => __( 'Kuwaiti dinar', 'learnpress' ),
1015 - 'KGS' => __( 'Kyrgyzstani som', 'learnpress' ),
1016 - 'KRW' => __( 'South Korean won', 'learnpress' ),
1017 - 'LAK' => __( 'Lao kip', 'learnpress' ),
1018 - 'LVL' => __( 'Latvian lats', 'learnpress' ),
1019 - 'LBP' => __( 'Lebanese pound', 'learnpress' ),
1020 - 'LSL' => __( 'Lesotho loti', 'learnpress' ),
1021 - 'LRD' => __( 'Liberian dollar', 'learnpress' ),
1022 - 'LD' => __( 'Libyan dinar', 'learnpress' ),
1023 - 'CHF' => __( 'Swiss franc', 'learnpress' ),
1024 - 'LTL' => __( 'Lithuanian litas', 'learnpress' ),
1025 - 'MOP' => __( 'Macanese pataca', 'learnpress' ),
1026 - 'MKD' => __( 'Macedonian denar', 'learnpress' ),
1027 - 'MGA' => __( 'Malagasy ariary', 'learnpress' ),
1028 - 'MWK' => __( 'Malawian kwacha', 'learnpress' ),
1029 - 'MYR' => __( 'Malaysian ringgit', 'learnpress' ),
1030 - 'MVR' => __( 'Maldivian rufiyaa', 'learnpress' ),
1031 - 'MRO' => __( 'Mauritanian ouguiya', 'learnpress' ),
1032 - 'MUR' => __( 'Mauritian rupee', 'learnpress' ),
1033 - 'MXN' => __( 'Mexican peso', 'learnpress' ),
1034 - 'MDL' => __( 'Moldovan leu', 'learnpress' ),
1035 - 'MNT' => __( 'Mongolian tugrik', 'learnpress' ),
1036 - 'MAD' => __( 'Moroccan dirham', 'learnpress' ),
1037 - 'MZN' => __( 'Mozambican metical', 'learnpress' ),
1038 - 'NAD' => __( 'Namibian dollar', 'learnpress' ),
1039 - 'NPR' => __( 'Nepalese rupee', 'learnpress' ),
1040 - 'NIO' => __( 'Nicaraguan córdoba', 'learnpress' ),
1041 - 'NGN' => __( 'Nigerian naira', 'learnpress' ),
1042 - 'NOK' => __( 'Norwegian krone', 'learnpress' ),
1043 - 'OMR' => __( 'Omani rial', 'learnpress' ),
1044 - 'PKR' => __( 'Pakistani rupee', 'learnpress' ),
1045 - 'PAB' => __( 'Panamanian balboa', 'learnpress' ),
1046 - 'PGK' => __( 'Papua New Guinea kina', 'learnpress' ),
1047 - 'PYG' => __( 'Paraguayan guarani', 'learnpress' ),
1048 - 'PEN' => __( 'Peruvian nuevo sol', 'learnpress' ),
1049 - 'PHP' => __( 'Philippine peso', 'learnpress' ),
1050 - 'PLN' => __( 'Polish zloty', 'learnpress' ),
1051 - 'QAR' => __( 'Qatari riyal', 'learnpress' ),
1052 - 'RON' => __( 'Romanian leu', 'learnpress' ),
1053 - 'RUB' => __( 'Russian ruble', 'learnpress' ),
1054 - 'RWF' => __( 'Rwandan franc', 'learnpress' ),
1055 - 'WST' => __( 'Samoan tālā', 'learnpress' ),
1056 - 'STD' => __( 'São Tomé and Príncipe dobra', 'learnpress' ),
1057 - 'SAR' => __( 'Saudi riyal', 'learnpress' ),
1058 - 'RSD' => __( 'Serbian dinar', 'learnpress' ),
1059 - 'SCR' => __( 'Seychellois rupee', 'learnpress' ),
1060 - 'SLL' => __( 'Sierra Leonean leone', 'learnpress' ),
1061 - 'SGD' => __( 'Singapore dollar', 'learnpress' ),
1062 - 'SBD' => __( 'Solomon Islands dollar', 'learnpress' ),
1063 - 'SOS' => __( 'Somali shilling', 'learnpress' ),
1064 - 'ZAR' => __( 'South African rand', 'learnpress' ),
1065 - 'LKR' => __( 'Sri Lankan rupee', 'learnpress' ),
1066 - 'SHP' => __( 'St. Helena pound', 'learnpress' ),
1067 - 'SDG' => __( 'Sudanese pound', 'learnpress' ),
1068 - 'SRD' => __( 'Surinamese dollar', 'learnpress' ),
1069 - 'SZL' => __( 'Swazi lilangeni', 'learnpress' ),
1070 - 'SEK' => __( 'Swedish krona', 'learnpress' ),
1071 - 'SYP' => __( 'Syrian pound', 'learnpress' ),
1072 - 'TWD' => __( 'New Taiwan dollar', 'learnpress' ),
1073 - 'TJS' => __( 'Tajikistani somoni', 'learnpress' ),
1074 - 'TZS' => __( 'Tanzanian shilling', 'learnpress' ),
1075 - 'THB' => __( 'Thai baht ', 'learnpress' ),
1076 - 'TOP' => __( 'Tongan pa’anga', 'learnpress' ),
1077 - 'TTD' => __( 'Trinidad and Tobago dollar', 'learnpress' ),
1078 - 'TND' => __( 'Tunisian dinar', 'learnpress' ),
1079 - 'TRY' => __( 'Turkish lira', 'learnpress' ),
1080 - 'TMT' => __( 'Turkmenistani manat', 'learnpress' ),
1081 - 'UGX' => __( 'Ugandan shilling', 'learnpress' ),
1082 - 'UAH' => __( 'Ukrainian hryvnia', 'learnpress' ),
1083 - 'AED' => __( 'United Arab Emirates dirham', 'learnpress' ),
1084 - 'UYU' => __( 'Uruguayan peso', 'learnpress' ),
1085 - 'UZS' => __( 'Uzbekistani som', 'learnpress' ),
1086 - 'VUV' => __( 'Vanuatu vatu', 'learnpress' ),
1087 - 'VEF' => __( 'Venezuelan bolivar', 'learnpress' ),
1088 - 'VND' => __( 'Vietnamese dong', 'learnpress' ),
1089 - 'YER' => __( 'Yemeni rial', 'learnpress' ),
1090 - 'ZMK' => __( 'Zambian kwacha', 'learnpress' ),
1091 - 'ZWL' => __( 'Zimbabwean dollar', 'learnpress' ),
1092 - 'JEP' => __( 'Jersey pound', 'learnpress' ),
1093 - 'LYD' => __( 'Libyan dinar', 'learnpress' ),
1094 - );
1095 -
1096 - asort( $currencies );
1097 -
1098 - return apply_filters( 'learn-press/currencies', $currencies );
842 + return Config::instance()->get( 'currencies', 'settings' );
1099 843 }
1100 844
1101 845 /**
1102 - * Get current setting of currency.
846 + * Return list of common symbols of the currencies on the world.
1103 847 *
1104 - * @return string
848 + * @return array
849 + * @version 3.0.1
1105 850 */
1106 -function learn_press_get_currency() {
1107 - $currency = apply_filters( 'learn_press_currency', LP_Settings::instance()->get( 'currency', 'USD' ) );
1108 -
1109 - return apply_filters( 'learn-press/currency', $currency );
851 +function learn_press_currency_symbols() {
852 + return Config::instance()->get( 'currency-symbols', 'settings' );
1110 853 }
1111 854
1112 855 /**
1113 - * Return list of common symbols of the currencies on the world.
856 + * Get current setting of currency.
1114 857 *
1115 - * @return array
858 + * @return string
1116 859 */
1117 -function learn_press_currency_symbols() {
1118 - $symbols = array(
1119 - 'AED' => '&#x62f;.&#x625;',
1120 - 'AFN' => '&#x60b;',
1121 - 'ALL' => 'L',
1122 - 'AMD' => 'AMD',
1123 - 'ANG' => '&fnof;',
1124 - 'AOA' => 'Kz',
1125 - 'ARS' => '&#36;',
1126 - 'AUD' => '&#36;',
1127 - 'AWG' => 'Afl.',
1128 - 'AZN' => 'AZN',
1129 - 'BAM' => 'KM',
1130 - 'BBD' => '&#36;',
1131 - 'BDT' => '&#2547;&nbsp;',
1132 - 'BGN' => '&#1083;&#1074;.',
1133 - 'BHD' => '.&#x62f;.&#x628;',
1134 - 'BIF' => 'Fr',
1135 - 'BMD' => '&#36;',
1136 - 'BND' => '&#36;',
1137 - 'BOB' => 'Bs.',
1138 - 'BRL' => '&#82;&#36;',
1139 - 'BSD' => '&#36;',
1140 - 'BTC' => '&#3647;',
1141 - 'BTN' => 'Nu.',
1142 - 'BWP' => 'P',
1143 - 'BYR' => 'Br',
1144 - 'BYN' => 'Br',
1145 - 'BZD' => '&#36;',
1146 - 'CAD' => '&#36;',
1147 - 'CDF' => 'Fr',
1148 - 'CHF' => '&#67;&#72;&#70;',
1149 - 'CLP' => '&#36;',
1150 - 'CNY' => '&yen;',
1151 - 'COP' => '&#36;',
1152 - 'CRC' => '&#x20a1;',
1153 - 'CUC' => '&#36;',
1154 - 'CUP' => '&#36;',
1155 - 'CVE' => '&#36;',
1156 - 'CZK' => '&#75;&#269;',
1157 - 'DJF' => 'Fr',
1158 - 'DKK' => 'DKK',
1159 - 'DOP' => 'RD&#36;',
1160 - 'DZD' => '&#x62f;.&#x62c;',
1161 - 'EGP' => 'EGP',
1162 - 'ERN' => 'Nfk',
1163 - 'ETB' => 'Br',
1164 - 'EUR' => '&euro;',
1165 - 'FJD' => '&#36;',
1166 - 'FKP' => '&pound;',
1167 - 'GBP' => '&pound;',
1168 - 'GEL' => '&#x20be;',
1169 - 'GGP' => '&pound;',
1170 - 'GHS' => '&#x20b5;',
1171 - 'GIP' => '&pound;',
1172 - 'GMD' => 'D',
1173 - 'GNF' => 'Fr',
1174 - 'GTQ' => 'Q',
1175 - 'GYD' => '&#36;',
1176 - 'HKD' => '&#36;',
1177 - 'HNL' => 'L',
1178 - 'HRK' => 'kn',
1179 - 'HTG' => 'G',
1180 - 'HUF' => '&#70;&#116;',
1181 - 'IDR' => 'Rp',
1182 - 'ILS' => '&#8362;',
1183 - 'IMP' => '&pound;',
1184 - 'INR' => '&#8377;',
1185 - 'IQD' => '&#x639;.&#x62f;',
1186 - 'IRR' => '&#xfdfc;',
1187 - 'IRT' => '&#x062A;&#x0648;&#x0645;&#x0627;&#x0646;',
1188 - 'ISK' => 'kr.',
1189 - 'JEP' => '&pound;',
1190 - 'JMD' => '&#36;',
1191 - 'JOD' => '&#x62f;.&#x627;',
1192 - 'JPY' => '&yen;',
1193 - 'KES' => 'KSh',
1194 - 'KGS' => '&#x441;&#x43e;&#x43c;',
1195 - 'KHR' => '&#x17db;',
1196 - 'KMF' => 'Fr',
1197 - 'KPW' => '&#x20a9;',
1198 - 'KRW' => '&#8361;',
1199 - 'KWD' => '&#x62f;.&#x643;',
1200 - 'KYD' => '&#36;',
1201 - 'KZT' => '&#8376;',
1202 - 'LAK' => '&#8365;',
1203 - 'LBP' => '&#x644;.&#x644;',
1204 - 'LKR' => '&#xdbb;&#xdd4;',
1205 - 'LRD' => '&#36;',
1206 - 'LSL' => 'L',
1207 - 'LYD' => '&#x644;.&#x62f;',
1208 - 'MAD' => '&#x62f;.&#x645;.',
1209 - 'MDL' => 'MDL',
1210 - 'MGA' => 'Ar',
1211 - 'MKD' => '&#x434;&#x435;&#x43d;',
1212 - 'MMK' => 'Ks',
1213 - 'MNT' => '&#x20ae;',
1214 - 'MOP' => 'P',
1215 - 'MRU' => 'UM',
1216 - 'MUR' => '&#x20a8;',
1217 - 'MVR' => '.&#x783;',
1218 - 'MWK' => 'MK',
1219 - 'MXN' => '&#36;',
1220 - 'MYR' => '&#82;&#77;',
1221 - 'MZN' => 'MT',
1222 - 'NAD' => 'N&#36;',
1223 - 'NGN' => '&#8358;',
1224 - 'NIO' => 'C&#36;',
1225 - 'NOK' => '&#107;&#114;',
1226 - 'NPR' => '&#8360;',
1227 - 'NZD' => '&#36;',
1228 - 'OMR' => '&#x631;.&#x639;.',
1229 - 'PAB' => 'B/.',
1230 - 'PEN' => 'S/',
1231 - 'PGK' => 'K',
1232 - 'PHP' => '&#8369;',
1233 - 'PKR' => '&#8360;',
1234 - 'PLN' => '&#122;&#322;',
1235 - 'PRB' => '&#x440;.',
1236 - 'PYG' => '&#8370;',
1237 - 'QAR' => '&#x631;.&#x642;',
1238 - 'RMB' => '&yen;',
1239 - 'RON' => 'lei',
1240 - 'RSD' => '&#1088;&#1089;&#1076;',
1241 - 'RUB' => '&#8381;',
1242 - 'RWF' => 'Fr',
1243 - 'SAR' => '&#x631;.&#x633;',
1244 - 'SBD' => '&#36;',
1245 - 'SCR' => '&#x20a8;',
1246 - 'SDG' => '&#x62c;.&#x633;.',
1247 - 'SEK' => '&#107;&#114;',
1248 - 'SGD' => '&#36;',
1249 - 'SHP' => '&pound;',
1250 - 'SLL' => 'Le',
1251 - 'SOS' => 'Sh',
1252 - 'SRD' => '&#36;',
1253 - 'SSP' => '&pound;',
1254 - 'STN' => 'Db',
1255 - 'SYP' => '&#x644;.&#x633;',
1256 - 'SZL' => 'L',
1257 - 'THB' => '&#3647;',
1258 - 'TJS' => '&#x405;&#x41c;',
1259 - 'TMT' => 'm',
1260 - 'TND' => '&#x62f;.&#x62a;',
1261 - 'TOP' => 'T&#36;',
1262 - 'TRY' => '&#8378;',
1263 - 'TTD' => '&#36;',
1264 - 'TWD' => '&#78;&#84;&#36;',
1265 - 'TZS' => 'Sh',
1266 - 'UAH' => '&#8372;',
1267 - 'UGX' => 'UGX',
1268 - 'USD' => '&#36;',
1269 - 'UYU' => '&#36;',
1270 - 'UZS' => 'UZS',
1271 - 'VEF' => 'Bs F',
1272 - 'VES' => 'Bs.S',
1273 - 'VND' => '&#8363;',
1274 - 'VUV' => 'Vt',
1275 - 'WST' => 'T',
1276 - 'XAF' => 'CFA',
1277 - 'XCD' => '&#36;',
1278 - 'XOF' => 'CFA',
1279 - 'XPF' => 'Fr',
1280 - 'YER' => '&#xfdfc;',
1281 - 'ZAR' => '&#82;',
1282 - 'ZMW' => 'ZK',
1283 - );
860 +function learn_press_get_currency(): string {
861 + $currency = LP_Settings::instance()->get( 'currency', 'USD' );
1284 862
1285 - return apply_filters( 'learn-press/currency-symbols', $symbols );
863 + return esc_html( apply_filters( 'learn-press/currency', $currency ) );
1286 864 }
1287 865
1288 866 /**
1289 867 * Return currency symbol from the code.
@@ -1296,9 +874,9 @@
1296 874 if ( ! $currency ) {
1297 875 $currency = learn_press_get_currency();
1298 876 }
1299 877 $symbols = learn_press_currency_symbols();
1300 - $currency_symbol = isset( $symbols[ $currency ] ) ? $symbols[ $currency ] : '';
878 + $currency_symbol = $symbols[ $currency ] ?? '';
1301 879
1302 880 $currency_symbol = apply_filters( 'learn_press_currency_symbol', $currency_symbol, $currency );
1303 881
1304 882 return apply_filters( 'learn-press/currency-symbol', $currency_symbol, $currency );
@@ -1313,14 +891,19 @@
1313 891 * @editor tungnx
1314 892 * @modify 4.1.4
1315 893 */
1316 894 function learn_press_get_page_link( string $key ): string {
1317 - $page_id = learn_press_get_page_id( $key );
1318 - $link = '';
895 + $page_id = learn_press_get_page_id( $key );
896 + $key_cache = "lp/page-link/{$key}";
897 + $link = LP_Cache::cache_load_first( 'get', $key_cache );
898 + if ( false !== $link ) {
899 + return $link;
900 + }
1319 901
1320 902 if ( $page_id && get_post_status( $page_id ) == 'publish' ) {
1321 903 $permalink = get_permalink( $page_id );
1322 904 $link = apply_filters( 'learn-press/get-page-link', trailingslashit( $permalink ), $page_id, $key );
905 + LP_Cache::cache_load_first( 'set', $key_cache, $link );
1323 906 }
1324 907
1325 908 return $link;
1326 909 }
@@ -1421,38 +1004,8 @@
1421 1004
1422 1005 return $result;
1423 1006 }
1424 1007
1425 -function learn_press_course_lesson_permalink_friendly( $permalink, $lesson_id, $course_id ) {
1426 - if ( '' != get_option( 'permalink_structure' ) ) {
1427 - if ( preg_match( '!\?lesson=([^\?\&]*)!', $permalink, $matches ) ) {
1428 - $permalink = preg_replace(
1429 - '!/?\?lesson=([^\?\&]*)!',
1430 - '/' . basename( get_permalink( $matches[1] ) ),
1431 - untrailingslashit( $permalink )
1432 - );
1433 - }
1434 - }
1435 -
1436 - return $permalink;
1437 -}
1438 -
1439 -function learn_press_course_question_permalink_friendly( $permalink, $lesson_id, $course_id ) {
1440 - if ( '' != get_option( 'permalink_structure' ) ) {
1441 - if ( preg_match( '!\?lesson=([^\?\&]*)!', $permalink, $matches ) ) {
1442 - $permalink = preg_replace(
1443 - '!/?\?lesson=([^\?\&]*)!',
1444 - '/' . basename( get_permalink( $matches[1] ) ),
1445 - untrailingslashit( $permalink )
1446 - );
1447 - }
1448 - }
1449 -
1450 - return $permalink;
1451 -}
1452 -
1453 -add_filter( 'learn_press_course_lesson_permalink', 'learn_press_course_lesson_permalink_friendly', 10, 3 );
1454 -
1455 1008 function learn_press_user_maybe_is_a_teacher( $user = null ) {
1456 1009 if ( ! $user ) {
1457 1010 $user = learn_press_get_current_user();
1458 1011 } elseif ( is_numeric( $user ) ) {
@@ -1457,9 +1010,9 @@
1457 1010 $user = learn_press_get_current_user();
1458 1011 } elseif ( is_numeric( $user ) ) {
1459 1012 $user = learn_press_get_user( $user );
1460 1013 }
1461 - if ( ! $user ) {
1014 + if ( ! $user || $user instanceof LP_User_Guest ) {
1462 1015 return false;
1463 1016 }
1464 1017
1465 1018 $role = $user->has_role( 'administrator' ) ? 'administrator' : false;
@@ -1490,61 +1043,8 @@
1490 1043 }
1491 1044
1492 1045 add_filter( 'gettext_with_context', '_learn_press_translate_user_roles', 10, 4 );
1493 1046
1494 -/**
1495 - * Modifies the statement $where to make the search works correct
1496 - *
1497 - * @param string
1498 - *
1499 - * @return string
1500 - * @deprecated 4.1.7.2
1501 - */
1502 -//function learn_press_posts_where_statement_search( $where ) {
1503 -// // gets the global query var object
1504 -// global $wp_query, $wpdb;
1505 -//
1506 -// /**
1507 -// * Need to wrap this block into () in order to make it works correctly when filter by specific post type => maybe a bug :)
1508 -// * from => ( wp_2_posts.post_status = 'publish' OR wp_2_posts.post_status = 'private') OR wp_2_terms.name LIKE '%s%'
1509 -// * to => ( ( wp_2_posts.post_status = 'publish' OR wp_2_posts.post_status = 'private') OR wp_2_terms.name LIKE '%s%' )
1510 -// */
1511 -// $a = preg_match( '!(' . $wpdb->posts . '.post_status)!', $where );
1512 -// $b = preg_match( '!(OR\s+' . $wpdb->terms . '.name LIKE \'%' . $wp_query->get( 's' ) . '%\')!', $where );
1513 -//
1514 -// if ( $a && $b ) {
1515 -// // append ( to the start of the block
1516 -// $where = preg_replace( '!(' . $wpdb->posts . '.post_status)!', '( $1', $where, 1 );
1517 -//
1518 -// // append ) to the end of the block
1519 -// $where = preg_replace(
1520 -// '!(OR\s+' . $wpdb->terms . '.name LIKE \'%' . $wp_query->get( 's' ) . '%\')!',
1521 -// '$1 )',
1522 -// $where
1523 -// );
1524 -// }
1525 -// remove_filter( 'posts_where', 'learn_press_posts_where_statement_search', 99 );
1526 -//
1527 -// return $where;
1528 -//}
1529 -
1530 -/**
1531 - * Filter post type for search function
1532 - * Only search lpr_course if see the param ref=course in request
1533 - *
1534 - * @param WP_Query $q
1535 - * @deprecated 4.1.7.2
1536 - */
1537 -/*function learn_press_filter_search( $q ) {
1538 - if ( $q->is_main_query() && $q->is_search() && ( ! empty( $_REQUEST['ref'] ) && sanitize_text_field( $_REQUEST['ref'] ) == 'course' ) ) {
1539 - $q->set( 'post_type', 'lp_course' );
1540 -
1541 - add_filter( 'posts_where', 'learn_press_posts_where_statement_search', 99 );
1542 - remove_filter( 'pre_get_posts', 'learn_press_filter_search', 99 );
1543 - }
1544 -}*/
1545 -//add_filter( 'pre_get_posts', 'learn_press_filter_search', 99 );
1546 -
1547 1047 if ( ! function_exists( 'learn_press_send_json' ) ) {
1548 1048 function learn_press_send_json( $data ) {
1549 1049 echo '<-- LP_AJAX_START -->';
1550 1050 echo wp_json_encode( $data );
@@ -1678,14 +1178,13 @@
1678 1178 function learn_press_is_course_archive() {
1679 1179 global $wp_query;
1680 1180
1681 1181 $queried_object_id = ! empty( $wp_query->queried_object ) ? $wp_query->queried_object : 0;
1682 - $is_courses = defined( 'LEARNPRESS_IS_COURSES' ) && LEARNPRESS_IS_COURSES;
1683 1182 $is_tag = defined( 'LEARNPRESS_IS_TAG' ) && LEARNPRESS_IS_TAG || is_tax( 'course_tag' );
1684 1183 $is_category = defined( 'LEARNPRESS_IS_CATEGORY' ) && LEARNPRESS_IS_CATEGORY || is_tax( 'course_category' );
1685 1184 $page_id = learn_press_get_page_id( 'courses' );
1686 1185
1687 - return ( $is_courses || $is_category || $is_tag ) || is_post_type_archive( 'lp_course' ) || ( $page_id && ( $queried_object_id && is_page( $page_id ) ) );
1186 + return ( $is_category || $is_tag ) || is_post_type_archive( 'lp_course' ) || ( $page_id && ( $queried_object_id && is_page( $page_id ) ) );
1688 1187 }
1689 1188 }
1690 1189
1691 1190 if ( ! function_exists( 'learn_press_is_course_tax' ) ) {
@@ -1714,19 +1213,15 @@
1714 1213 }
1715 1214 }
1716 1215
1717 1216 if ( ! function_exists( 'learn_press_is_course' ) ) {
1718 - function learn_press_is_course() {
1719 - /**
1720 - * @var WP_Query $wp_query
1721 - */
1722 - global $wp_query;
1723 -
1724 - if ( $wp_query->get_queried_object() ) {
1217 + function learn_press_is_course(): bool {
1218 + try {
1725 1219 return is_singular( array( LP_COURSE_CPT ) );
1726 - } else {
1727 - return false;
1220 + } catch ( Throwable $e ) {
1728 1221 }
1222 +
1223 + return false;
1729 1224 }
1730 1225 }
1731 1226
1732 1227 if ( ! function_exists( 'learn_press_is_lesson' ) ) {
@@ -1776,8 +1271,19 @@
1776 1271
1777 1272 return apply_filters( 'learn-press/is-checkout', false );
1778 1273 }
1779 1274
1275 +function learn_press_is_instructors() {
1276 + $page_id = learn_press_get_page_id( 'instructors' );
1277 +
1278 + if ( $page_id && is_page( $page_id ) ) {
1279 + return true;
1280 + }
1281 +
1282 + return apply_filters( 'learn-press/is-instructor', false );
1283 +}
1284 +
1285 +
1780 1286 /**
1781 1287 * Return register permalink
1782 1288 *
1783 1289 * @return mixed
@@ -1786,43 +1292,31 @@
1786 1292 return apply_filters( 'learn_press_register_url', wp_registration_url() );
1787 1293 }
1788 1294
1789 1295 /**
1790 - * Add a new notice into queue
1791 - *
1792 - * @param string
1793 - * @param string
1794 - *
1795 - * @return mixed
1796 - */
1797 -function learn_press_add_notice( $message, $type = 'updated' ) {
1798 - LP_Admin_Notice::instance()->add( $message, $type );
1799 -}
1800 -
1801 -/**
1802 1296 * Set user's cookie
1803 1297 *
1804 - * @param $name
1805 - * @param $value
1806 - * @param int $expire
1807 - * @param bool $secure
1298 + * @param string $name
1299 + * @param mixed $value
1300 + * @param int $expire
1301 + * @param bool $httponly
1808 1302 *
1809 1303 * @editor tungnx
1810 - * @version 1.0.2
1304 + * @version 1.0.3
1811 1305 */
1812 -function learn_press_setcookie( $name, $value, $expire = 0, $secure = false, $httponly = false ) {
1813 - $secure = ( 'https' === parse_url( wp_login_url(), PHP_URL_SCHEME ) );
1814 -
1815 - @setcookie( $name, $value, $expire, COOKIEPATH ? COOKIEPATH : '/', COOKIE_DOMAIN, $secure, $httponly );
1306 +function learn_press_setcookie( string $name = '', string $value = '', int $expire = 0, bool $httponly = true ) {
1307 + @setcookie( $name, $value, $expire, COOKIEPATH ?: '/', COOKIE_DOMAIN, is_ssl(), $httponly );
1816 1308 }
1817 1309
1818 1310 /**
1819 1311 * Clear cookie
1820 1312 *
1821 - * @param $name
1313 + * @param string $name
1822 1314 */
1823 -function learn_press_remove_cookie( $name ) {
1824 - setcookie( $name, '', time() - YEAR_IN_SECONDS, COOKIEPATH ? COOKIEPATH : '/', COOKIE_DOMAIN );
1315 +function learn_press_remove_cookie( string $name = '' ) {
1316 + if ( ! empty( $name ) ) {
1317 + setcookie( $name, '', time() - YEAR_IN_SECONDS, COOKIEPATH ? COOKIEPATH : '/', COOKIE_DOMAIN, is_ssl(), true );
1318 + }
1825 1319
1826 1320 if ( array_key_exists( $name, $_COOKIE ) ) {
1827 1321 unset( $_COOKIE[ $name ] );
1828 1322 }
@@ -1828,9 +1322,9 @@
1828 1322 }
1829 1323 }
1830 1324
1831 1325 /**
1832 - * Filter the login url so third-party can be customize
1326 + * Filter the login url so third-party can be customized
1833 1327 *
1834 1328 * @param string $redirect
1835 1329 *
1836 1330 * @return mixed
@@ -1880,45 +1374,12 @@
1880 1374 return apply_filters( 'learn_press_get_endpoint_url', esc_url_raw( $url ), $name, $value, $url );
1881 1375 }
1882 1376
1883 1377 /**
1884 - * Add all endpoints from settings to the pages.
1378 + * @deprecated 4.2.3
1885 1379 */
1886 -function learn_press_add_endpoints() {
1887 - $settings = LP_Settings::instance();
1888 -
1889 - $endpoints = $settings->get_checkout_endpoints();
1890 - if ( $endpoints ) {
1891 - foreach ( $endpoints as $endpoint => $value ) {
1892 - LearnPress::instance()->query_vars[ $endpoint ] = $value;
1893 - add_rewrite_endpoint( $value, EP_PAGES );
1894 - }
1895 - }
1896 -
1897 - $endpoints = $settings->get_profile_endpoints();
1898 - if ( $endpoints ) {
1899 - foreach ( $endpoints as $endpoint => $value ) {
1900 - LearnPress::instance()->query_vars[ $endpoint ] = $value;
1901 - add_rewrite_endpoint( $value, EP_PAGES );
1902 - }
1903 - }
1904 -
1905 - $endpoints = $settings->get( 'quiz_endpoints' );
1906 - if ( $endpoints ) {
1907 - foreach ( $endpoints as $endpoint => $value ) {
1908 - $endpoint = preg_replace( '!_!', '-', $endpoint );
1909 - LearnPress::instance()->query_vars[ $endpoint ] = $value;
1910 - add_rewrite_endpoint(
1911 - $value, /*EP_ROOT | */
1912 - EP_PAGES
1913 - );
1914 - }
1915 - }
1916 -}
1917 -
1918 -add_action( 'init', 'learn_press_add_endpoints' );
1919 -
1920 1380 function learn_press_is_yes( $value ) {
1381 + _deprecated_function( __FUNCTION__, '4.2.3' );
1921 1382 return ( $value === 1 ) || ( $value === '1' ) || ( $value == 'yes' ) || ( $value == true ) || ( $value == 'on' );
1922 1383 }
1923 1384
1924 1385 /**
@@ -1924,10 +1385,12 @@
1924 1385 /**
1925 1386 * @param mixed $value
1926 1387 *
1927 1388 * @return bool
1389 + * @deprecated 4.2.3
1928 1390 */
1929 1391 function _is_false_value( $value ) {
1392 + _deprecated_function( __FUNCTION__, '4.2.3' );
1930 1393 if ( is_numeric( $value ) ) {
1931 1394 return $value == 0;
1932 1395 } elseif ( is_string( $value ) ) {
1933 1396 return ( empty( $value ) || is_null( $value ) || in_array( $value, array( 'no', 'off', 'false' ) ) );
@@ -1945,11 +1408,11 @@
1945 1408
1946 1409 // Map query vars to their keys, or get them if endpoints are not supported
1947 1410 foreach ( LearnPress::instance()->query_vars as $key => $var ) {
1948 1411 if ( isset( $_GET[ $var ] ) ) {
1949 - $wp->query_vars[ $key ] = LP_Helper::sanitize_params_submitted( $_GET[ $var ] ?? '' );
1412 + $wp->query_vars[ $key ] = LP_Helper::sanitize_params_submitted( $_GET[ $var ] );
1950 1413 } elseif ( isset( $wp->query_vars[ $var ] ) ) {
1951 - $wp->query_vars[ $key ] = LP_Helper::sanitize_params_submitted( $wp->query_vars[ $var ] ?? '' );
1414 + $wp->query_vars[ $key ] = LP_Helper::sanitize_params_submitted( $wp->query_vars[ $var ] );
1952 1415 }
1953 1416 }
1954 1417 }
1955 1418
@@ -1967,54 +1430,18 @@
1967 1430 }
1968 1431 }
1969 1432
1970 1433 /**
1971 - * @param string $handle
1972 - * @param bool $hash
1973 - *
1974 - * @return string
1975 - * @depecated 4.1.7.2
1976 - */
1977 -/*function learn_press_get_log_file_path( $handle, $hash = false ) {
1978 - if ( $hash ) {
1979 - $hash = '-' . sanitize_file_name( wp_hash( $handle ) );
1980 - }
1981 -
1982 - return trailingslashit( LP_LOG_PATH ) . $handle . $hash . '.log';
1983 -}*/
1984 -
1985 -/**
1986 1434 * Get the cart object in checkout page
1987 1435 *
1988 1436 * @return LP_Cart
1437 + * @deprecated 4.2.0
1989 1438 */
1990 1439 function learn_press_get_checkout_cart() {
1440 + _deprecated_function( __FUNCTION__, '4.2.0', 'LearnPress::instance()->cart' );
1991 1441 return apply_filters( 'learn_press_checkout_cart', LearnPress::instance()->cart );
1992 1442 }
1993 1443
1994 -/*function learn_press_front_scripts() {
1995 - if ( is_admin() ) {
1996 - return;
1997 - }
1998 - $js = array(
1999 - 'ajax' => admin_url( 'admin-ajax.php' ),
2000 - 'plugin_url' => LearnPress::instance()->plugin_url(),
2001 - 'siteurl' => home_url(),
2002 - 'current_url' => learn_press_get_current_url(),
2003 - 'localize' => array(
2004 - 'button_ok' => __( 'OK', 'learnpress' ),
2005 - 'button_cancel' => __( 'Cancel', 'learnpress' ),
2006 - 'button_yes' => __( 'Yes', 'learnpress' ),
2007 - 'button_no' => __( 'No', 'learnpress' ),
2008 - ),
2009 - );
2010 - foreach ( $js as $k => $v ) {
2011 - LP_Assets::add_param( $k, $v, array( 'learn-press-single-course', 'learn-press-global' ), 'LP_Settings' );
2012 - }
2013 -}
2014 -
2015 -add_action( 'wp_print_scripts', 'learn_press_front_scripts' );*/
2016 -
2017 1444 function learn_press_user_time( $time, $format = 'timestamp' ) {
2018 1445 if ( is_string( $time ) ) {
2019 1446 $time = @strtotime( $time );
2020 1447 }
@@ -2040,13 +1467,20 @@
2040 1467 *
2041 1468 * @param bool $default
2042 1469 *
2043 1470 * @return mixed|string
1471 + * @deprecated 4.2.2
1472 + * addon commission 4.0.2 still use this function
2044 1473 */
2045 1474 function learn_press_get_current_profile_tab( $default = true ) {
2046 1475 global $wp_query, $wp;
2047 1476 $current = '';
2048 1477
1478 + // Only load on profile page.
1479 + if ( ! LP_Page_Controller::is_page_profile() ) {
1480 + return false;
1481 + }
1482 +
2049 1483 if ( ! empty( $_REQUEST['tab'] ) ) {
2050 1484 $current = LP_Helper::sanitize_params_submitted( $_REQUEST['tab'] );
2051 1485 } elseif ( ! empty( $wp_query->query_vars['tab'] ) ) {
2052 1486 $current = $wp_query->query_vars['tab'];
@@ -2067,9 +1501,9 @@
2067 1501
2068 1502 return $current;
2069 1503 }
2070 1504
2071 -add_action( 'init', 'learn_press_get_current_profile_tab' );
1505 +//add_action( 'init', 'learn_press_get_current_profile_tab' );
2072 1506
2073 1507 function learn_press_profile_tab_exists( $tab ) {
2074 1508 $tabs = learn_press_get_user_profile_tabs();
2075 1509
@@ -2079,40 +1513,8 @@
2079 1513
2080 1514 return false;
2081 1515 }
2082 1516
2083 -/**
2084 - * Replace the spacing with the + (plus) char.
2085 - *
2086 - * @param string $string
2087 - *
2088 - * @return string
2089 - * @depecated 4.1.7.2
2090 - */
2091 -/*function _learn_press_urlencode( $string ) {
2092 - return preg_replace( '/\s/', '+', $string );
2093 -}*/
2094 -
2095 -/**
2096 - * Point the archive post type link to course page if current
2097 - * post type is course and the page for displaying course is
2098 - * setup.
2099 - *
2100 - * @param string $link
2101 - * @param string $post_type
2102 - *
2103 - * @return string
2104 - * @depecated 4.1.7.2
2105 - */
2106 -/*function learn_press_post_type_archive_link( $link, $post_type ) {
2107 - if ( $post_type == LP_COURSE_CPT && learn_press_get_page_id( 'courses' ) ) {
2108 - $link = learn_press_get_page_link( 'courses' );
2109 - }
2110 -
2111 - return $link;
2112 -}*/
2113 -//add_filter( 'post_type_archive_link', 'learn_press_post_type_archive_link', 10, 2 );
2114 -
2115 1517 function learn_press_single_term_title( $prefix = '', $display = true ) {
2116 1518 $term = get_queried_object();
2117 1519
2118 1520 if ( ! $term ) {
@@ -2212,9 +1614,9 @@
2212 1614 ),
2213 1615 array(
2214 1616 'title' => __( 'Enable cart', 'learnpress' ),
2215 1617 'desc' => __(
2216 - 'Check this option to enable user purchase multiple courses at one time.',
1618 + 'Check this option to enable users to purchase multiple courses at one time.',
2217 1619 'learnpress'
2218 1620 ),
2219 1621 'id' => $class->get_field_name( 'enable_cart' ),
2220 1622 'default' => 'yes',
@@ -2221,9 +1623,9 @@
2221 1623 'type' => 'checkbox',
2222 1624 ),
2223 1625 array(
2224 1626 'title' => __( 'Add to cart redirect', 'learnpress' ),
2225 - 'desc' => __( 'Redirect to checkout immediately after adding course to cart.', 'learnpress' ),
1627 + 'desc' => __( 'Redirect to checkout immediately after adding the course to the cart.', 'learnpress' ),
2226 1628 'id' => $class->get_field_name( 'redirect_after_add' ),
2227 1629 'default' => 'yes',
2228 1630 'type' => 'checkbox',
2229 1631 ),
@@ -2228,9 +1630,9 @@
2228 1630 'type' => 'checkbox',
2229 1631 ),
2230 1632 array(
2231 1633 'title' => __( 'AJAX add to cart', 'learnpress' ),
2232 - 'desc' => __( 'Using AJAX to add course to cart.', 'learnpress' ),
1634 + 'desc' => __( 'Using AJAX to add the course to the cart.', 'learnpress' ),
2233 1635 'id' => $class->get_field_name( 'ajax_add_to_cart' ),
2234 1636 'default' => 'no',
2235 1637 'type' => 'checkbox',
2236 1638 ),
@@ -2359,33 +1761,8 @@
2359 1761 die( __FUNCTION__ );
2360 1762 }
2361 1763 }
2362 1764
2363 -/**
2364 - * Get current time to user for calculate remaining time of quiz.
2365 - *
2366 - * @return int
2367 - * @depecated 4.1.7.2
2368 - */
2369 -/*function learn_press_get_current_time() {
2370 - $current_time = apply_filters( 'learn_press_get_current_time', 0 );
2371 -
2372 - if ( $current_time > 0 ) {
2373 - return $current_time;
2374 - }
2375 -
2376 - $a = current_time( 'timestamp' );
2377 - $b = time();
2378 - $c = current_time( 'mysql' );
2379 - $d = strtotime( $c );
2380 -
2381 - if ( $d == $a ) {
2382 - return $a;
2383 - } else {
2384 - return $b;
2385 - }
2386 -}*/
2387 -
2388 1765 function learn_press_get_requested_post_type() {
2389 1766 global $pagenow;
2390 1767 if ( $pagenow == 'post-new.php' && ! empty( $_REQUEST['post_type'] ) ) {
2391 1768 $post_type = LP_Helper::sanitize_params_submitted( $_REQUEST['post_type'] );
@@ -2525,30 +1902,14 @@
2525 1902 echo '<span class="learn-press-tooltip" data-tooltip="' . esc_attr( $tooltip ) . '"></span>';
2526 1903 }
2527 1904
2528 1905 /**
2529 - * Get timezone offset from wp settings.
2530 - *
2531 - * @return float|int
2532 - * @since 3.0.0
2533 - * @depecated 4.1.7.2
2534 - */
2535 -/*function learn_press_timezone_offset() {
2536 - if ( $tz = get_option( 'timezone_string' ) ) {
2537 - $timezone = new DateTimeZone( $tz );
2538 -
2539 - return $timezone->getOffset( new DateTime( 'now' ) );
2540 - } else {
2541 - return floatval( get_option( 'gmt_offset', 0 ) ) * HOUR_IN_SECONDS;
2542 - }
2543 -}*/
2544 -
2545 -/**
2546 1906 * Get default static pages of LP.
2547 1907 *
2548 1908 * @return array
2549 1909 *
2550 1910 * @since 3.0.0
1911 + * @deprecated 4.2.3
2551 1912 */
2552 1913 function learn_press_static_page_ids() {
2553 1914 $pages = LP_Object_Cache::get( 'static-page-ids', 'learn-press' );
2554 1915
@@ -2572,35 +1933,8 @@
2572 1933 return apply_filters( 'learn-press/static-page-ids', $pages );
2573 1934 }
2574 1935
2575 1936 /**
2576 - * Get default static pages of LP.
2577 - *
2578 - * @param bool $name - Optional. TRUE will return name only.
2579 - *
2580 - * @return array
2581 - *
2582 - * @since 3.0.0
2583 - */
2584 -function learn_press_static_pages( $name = false ) {
2585 - $pages = apply_filters(
2586 - 'learn-press/static-pages',
2587 - array(
2588 - 'checkout' => _x( 'Checkout', 'static-page-name', 'learnpress' ),
2589 - 'courses' => _x( 'Courses', 'static-page-name', 'learnpress' ),
2590 - 'profile' => _x( 'Profile', 'static-page-name', 'learnpress' ),
2591 - 'become_a_teacher' => _x( 'Become a Teacher', 'static-page-name', 'learnpress' ),
2592 - )
2593 - );
2594 -
2595 - if ( $name ) {
2596 - return array_keys( $pages );
2597 - }
2598 -
2599 - return $pages;
2600 -}
2601 -
2602 -/**
2603 1937 * Callback function for sorting to array|object by key|prop priority.
2604 1938 *
2605 1939 * @param array|object $a
2606 1940 * @param array|object $b
@@ -2606,10 +1940,11 @@
2606 1940 * @param array|object $b
2607 1941 *
2608 1942 * @return int
2609 1943 * @since 3.0.0
1944 + * @deprecated 4.4.5
2610 1945 */
2611 -function learn_press_sort_list_by_priority_callback( $a, $b ) {
1946 +/*function learn_press_sort_list_by_priority_callback( $a, $b ) {
2612 1947 $a_priority = null;
2613 1948 $b_priority = null;
2614 1949
2615 1950 if ( is_array( $a ) && array_key_exists( 'priority', $a ) ) {
@@ -2636,26 +1971,32 @@
2636 1971 return 0;
2637 1972 }
2638 1973
2639 1974 return ( $a_priority < $b_priority ) ? - 1 : 1;
2640 -}
1975 +}*/
2641 1976
2642 1977 /**
2643 1978 * Localize date with custom format.
2644 1979 *
2645 - * @param string $timestamp
1980 + * @param int|bool $timestamp
2646 1981 * @param string $format
2647 1982 * @param bool $gmt
2648 1983 *
2649 1984 * @return string
2650 1985 * @since 3.0.0
1986 + * @deprcated 4.2.6 use LP_Datetime format instead
2651 1987 */
2652 -function learn_press_date_i18n( $timestamp = '', $format = '', $gmt = false ) {
1988 +function learn_press_date_i18n( $timestamp = 0, string $format = '', bool $gmt = false ): string {
2653 1989 if ( ! $format ) {
2654 1990 $format = get_option( 'date_format' );
2655 1991 }
2656 1992
2657 - return date_i18n( $format, $timestamp, $gmt );
1993 + $date_str = date_i18n( $format, $timestamp, $gmt );
1994 + if ( ! is_string( $date_str ) ) {
1995 + $date_str = '';
1996 + }
1997 +
1998 + return $date_str;
2658 1999 }
2659 2000
2660 2001 /**
2661 2002 * Get item types of course support for blocking. Default is lp_lesson
@@ -2701,42 +2042,8 @@
2701 2042 return $post_type;
2702 2043 }
2703 2044
2704 2045 /**
2705 - * Add post type of a post into cache
2706 - *
2707 - * @param int|array $id
2708 - * @param string $type
2709 - *
2710 - * @since 3.1.0
2711 - * @depecated 4.1.7.2
2712 - */
2713 -/*function learn_press_cache_add_post_type( $id, $type = '' ) {
2714 - if ( false === ( $post_types = LP_Object_Cache::get( 'post-types', 'learn-press' ) ) ) {
2715 - $post_types = array();
2716 - }
2717 -
2718 - if ( func_num_args() == 1 && is_array( $id ) ) {
2719 - $post_types = $post_types + $id;
2720 - } else {
2721 - $post_types[ $id ] = $type;
2722 - }
2723 -
2724 - LP_Object_Cache::set( 'post-types', $post_types, 'learn-press' );
2725 -}*/
2726 -
2727 -/**
2728 - * @depecated 4.1.7.2
2729 - */
2730 -/*function learn_press_has_option( $name ) {
2731 - global $wpdb;
2732 -
2733 - $query = $wpdb->prepare( "SELECT option_id FROM {$wpdb->options} WHERE option_name = %s", $name );
2734 -
2735 - return $wpdb->get_var( $query ) > 0;
2736 -}*/
2737 -
2738 -/**
2739 2046 * Update option to enable shuffle themes for ad.
2740 2047 *
2741 2048 * @since 3.2.1
2742 2049 */
@@ -2746,102 +2053,36 @@
2746 2053
2747 2054 add_action( 'learn-press/schedule-enable-shuffle-themes', '_learn_press_schedule_enable_shuffle_themes' );
2748 2055
2749 2056 /**
2750 - * @depecated 4.1.7.2
2751 - */
2752 -/*function learn_press_show_log() {
2753 - if ( trim( LP_Request::get( 'show_log' ) ) === md5( AUTH_KEY ) ) {
2754 - call_user_func_array( 'learn_press_debug', func_get_args() );
2755 - }
2756 -}*/
2757 -
2758 -/**
2057 + * Return localize script data for admin.
2058 + *
2759 2059 * @return array
2760 2060 * @since 3.2.6
2061 + * @version 1.0.1
2761 2062 */
2762 -function learn_press_global_script_params() {
2763 - $js = array(
2764 - 'ajax' => admin_url( 'admin-ajax.php' ),
2765 - 'plugin_url' => LearnPress::instance()->plugin_url(),
2766 - 'siteurl' => home_url(),
2767 - 'current_url' => learn_press_get_current_url(),
2768 - 'theme' => get_stylesheet(),
2769 - 'localize' => array(
2063 +function learn_press_global_script_params(): array {
2064 + $localize = [
2065 + 'ajax' => admin_url( 'admin-ajax.php' ),
2066 + 'plugin_url' => LearnPress::instance()->plugin_url(),
2067 + 'siteurl' => home_url(),
2068 + //'current_url' => learn_press_get_current_url(),
2069 + 'theme' => get_stylesheet(),
2070 + 'localize' => array(
2770 2071 'button_ok' => __( 'OK', 'learnpress' ),
2771 2072 'button_cancel' => __( 'Cancel', 'learnpress' ),
2772 2073 'button_yes' => __( 'Yes', 'learnpress' ),
2773 2074 'button_no' => __( 'No', 'learnpress' ),
2774 2075 ),
2775 - 'root' => esc_url_raw( rest_url() ),
2776 - 'nonce' => wp_create_nonce( 'wp_rest' ),
2777 - );
2076 + 'rest' => esc_url_raw( rest_url() ),
2077 + 'nonce' => wp_create_nonce( 'wp_rest' ),
2078 + 'is_admin' => current_user_can( ADMIN_ROLE ),
2079 + ];
2778 2080
2779 - return $js;
2081 + return apply_filters( 'lp/admin/localize/scripts', $localize );
2780 2082 }
2781 2083
2782 2084 /**
2783 - * Get url for setup cron job on server.
2784 - *
2785 - * @return string
2786 - * @since 3.3.0
2787 - * @depecated 4.1.7.2
2788 - */
2789 -/*function learn_press_get_cron_url() {
2790 - $nonce = get_option( 'learnpress_cron_url_nonce' );
2791 -
2792 - if ( ! $nonce ) {
2793 - $nonce = md5( microtime( true ) );
2794 - update_option( 'learnpress_cron_url_nonce', $nonce );
2795 - }
2796 - $url = add_query_arg(
2797 - array(
2798 - 'lp-ajax' => 'cron',
2799 - 'sid' => $nonce,
2800 - ),
2801 - get_home_url()
2802 - );
2803 -
2804 - return $url;
2805 -}*/
2806 -
2807 -/**
2808 - * Get courses expired.
2809 - *
2810 - * @return array
2811 - * @since 3.3.0
2812 - * @depecated 4.1.7.2
2813 - */
2814 -/*function learn_press_get_expired_courses() {
2815 - global $wpdb;
2816 -
2817 - $query = $wpdb->prepare(
2818 - "
2819 - SELECT X.*
2820 - FROM(
2821 - SELECT ui.*
2822 - FROM {$wpdb->learnpress_user_items} ui
2823 - LEFT JOIN {$wpdb->learnpress_user_items} uix
2824 - ON ui.item_id = uix.item_id
2825 - AND ui.user_id = uix.user_id
2826 - AND ui.user_item_id < uix.user_item_id
2827 - WHERE uix.user_item_id IS NULL
2828 - ) X
2829 - INNER JOIN {$wpdb->users} u ON u.ID = X.user_id
2830 - INNER JOIN {$wpdb->posts} p ON p.ID = X.item_id
2831 - WHERE X.item_type = %s
2832 - AND X.status = %s
2833 - #AND expiration_time_gmt <= UTC_TIMESTAMP()
2834 - AND expiration_time <= UTC_TIMESTAMP()
2835 - LIMIT 0, 10
2836 - ",
2837 - LP_COURSE_CPT,
2838 - 'enrolled'
2839 - );
2840 -
2841 -}*/
2842 -
2843 -/**
2844 2085 * Return list types of questions that support answer options.
2845 2086 *
2846 2087 * @return array
2847 2088 * @since 3.3.0
@@ -2875,85 +2116,15 @@
2875 2116 return $questions;
2876 2117 }
2877 2118
2878 2119 /**
2879 - * Helper function to output html for rendering a 'circle progress bar'
2120 + * LP Cookie
2880 2121 *
2881 - * @param int $percent
2882 - * @param int $width
2883 - * @param int $border
2884 - * @param string $color
2122 + * @param $name
2123 + * @param $namespace
2885 2124 *
2886 - * @since 3.3.0
2887 - * @depecated 4.1.7.2
2125 + * @return mixed|null
2888 2126 */
2889 -/*function learn_press_circle_progress_html( $percent = 0, $width = 32, $border = 4, $color = '' ) {
2890 - $radius = $width / 2;
2891 - $r = ( $width - $border ) / 2;
2892 - $circumference = $r * 2 * pi();
2893 - $offset = $circumference - $percent / 100 * $circumference;
2894 -
2895 - printf(
2896 - '<svg class="circle-progress-bar" width="%d" height="%d">
2897 - <circle class="circle-progress-bar__circle"
2898 - stroke="%s"
2899 - stroke-width="%d"
2900 - style="stroke-dasharray:%s %s; stroke-dashoffset:%s;"
2901 - fill="transparent"
2902 - r="%d" cx="%d" cy="%d"></circle>
2903 - </svg>',
2904 - $width,
2905 - $width,
2906 - $color,
2907 - $border,
2908 - $circumference,
2909 - $circumference,
2910 - $offset,
2911 - $r,
2912 - $radius,
2913 - $radius
2914 - );
2915 -}*/
2916 -
2917 -/**
2918 - * @depecated 4.1.7.2
2919 - */
2920 -/*function learn_press_is_page( $page_name ) {
2921 - $page_id = learn_press_get_page_id( $page_name );
2922 -
2923 - return $page_id && is_page( $page_id );
2924 -}*/
2925 -
2926 -/**
2927 - * Get end-date from start date with a duration.
2928 - *
2929 - * @param string|int $duration
2930 - * @param string|int $start
2931 - *
2932 - * @return false|string
2933 - * @since 3.x.x
2934 - * @depecated 4.1.7.2
2935 - */
2936 -/*function learn_press_date_end_from( $duration, $start = '' ) {
2937 - $format = 'Y-m-d H:i:s';
2938 -
2939 - if ( ! $start ) {
2940 - $start = time();
2941 - } elseif ( ! is_numeric( $start ) ) {
2942 - $start = strtotime( $start );
2943 - }
2944 -
2945 - // is LP duration format, e.g: 10 weeks
2946 - if ( preg_match( '/^[0-9]+ [a-z]+$/', $duration ) ) {
2947 - $duration = ( new LP_Duration( $duration ) )->get();
2948 - } elseif ( ! is_numeric( $duration ) ) {
2949 - // 10 days 5 hours ...
2950 - $duration = strtotime( $duration, 0 );
2951 - }
2952 -
2953 - return date( $format, $start + $duration );
2954 -}*/
2955 -
2956 2127 function learn_press_cookie_get( $name, $namespace = 'LP' ) {
2957 2128 if ( $namespace ) {
2958 2129 $cookie = ! empty( $_COOKIE[ $namespace ] ) ? (array) json_decode( LP_Helper::sanitize_params_submitted( stripslashes( $_COOKIE[ $namespace ] ), 'html' ) ) : array();
2959 2130 } else {
@@ -2971,67 +2142,76 @@
2971 2142 * @return array
2972 2143 * @since 3.x.x
2973 2144 */
2974 2145 function learn_press_course_evaluation_methods( $postid, $return = '', $final_quizz_passing = '' ) {
2975 - $course_tip = '<span class="learn-press-tip">%s</span>';
2976 - $final_quiz_btn = '<a href="#" class="lp-metabox-get-final-quiz" data-postid="' . $postid . '" data-loading="' . esc_attr__(
2977 - 'Loading...',
2978 - 'learnpress'
2979 - ) . '">' . esc_html__( 'Get Passing Grade', 'learnpress' ) . '</a>';
2146 + $final_quiz_btn = sprintf(
2147 + '<a href="#" class="lp-metabox-get-final-quiz" data-postid="%d" data-loading="%s">%s</a>',
2148 + $postid,
2149 + esc_attr__( 'Loading...', 'learnpress' ),
2150 + esc_html__( 'Get A Passing Grade', 'learnpress' )
2151 + );
2980 2152
2981 - $course_desc = array(
2153 + $evaluations_desc = array(
2982 2154 'evaluate_lesson' => sprintf(
2983 2155 '<p>%s<br/>%s</p>',
2984 - __( 'Evaluate by the number of lessons completed per total number of lessons.', 'learnpress' ),
2985 - __( 'E.g: Course has 10 lessons and user completed 5 lessons then the result = 5/10 (50.%)', 'learnpress' )
2156 + __( 'Evaluate by the number of completed lessons per the total number of lessons.', 'learnpress' ),
2157 + __( 'E.g: If a course has 10 lessons and a user completes 5 lessons, then the result is 5/10 (50%).', 'learnpress' )
2986 2158 ),
2987 2159 'evaluate_final_quiz' => __(
2988 - 'Evaluate by result of final quiz in the course. You have to add a quiz to the end of the course.',
2160 + 'Evaluate by the result of the final quiz in the course. You have to add a quiz at the end of the course.',
2989 2161 'learnpress'
2990 2162 ),
2991 2163 'evaluate_quiz' => sprintf(
2992 2164 '<p>%s<br/>%s</p>',
2993 - __( 'Evaluate by the number of quizzes passed per total number of quizzes.', 'learnpress' ),
2165 + __( 'Evaluate by the number of passed quizzes per the total number of quizzes.', 'learnpress' ),
2994 2166 __(
2995 - 'E.g: The course has 10 quizzes and the user passed 5 quizzes then the result = 5/10 (50%).',
2167 + 'E.g: If the course has 10 quizzes and the user passes 5 quizzes, then the result is 5/10 (50%).',
2996 2168 'learnpress'
2997 2169 )
2998 2170 ),
2999 2171 'evaluate_questions' => sprintf(
3000 2172 '<p>%s<br/>%s</p>',
3001 - __( 'Evaluate by total number of correct answers per total number of questions.', 'learnpress' ),
2173 + __( 'Evaluate by the number of correct answers per the total number of questions.', 'learnpress' ),
3002 2174 __(
3003 - 'E.g: Course has 10 questions. User correct 5 questions. Result is 5/10 (50%).',
2175 + 'E.g: If the course has 10 questions and the user corrects 5 questions, then the result is 5/10 (50%).',
3004 2176 'learnpress'
3005 2177 )
3006 2178 ),
3007 - 'evaluate_mark' => __( 'Evaluate by total score achieved per total score of the questions.', 'learnpress' ),
2179 + 'evaluate_mark' => __( 'Evaluate by the number of achieved scores per the total score of the questions.', 'learnpress' ),
3008 2180 );
3009 2181
3010 2182 $methods = apply_filters(
3011 2183 'learnpress/course-evaluation/methods',
3012 2184 array(
3013 - 'evaluate_lesson' => __(
3014 - 'Evaluate via lessons',
3015 - 'learnpress'
3016 - ) . learn_press_quick_tip( $course_desc['evaluate_lesson'], false ),
3017 - 'evaluate_final_quiz' => __( 'Evaluate via results of the final quiz', 'learnpress' ) . sprintf(
3018 - $course_tip,
3019 - $course_desc['evaluate_final_quiz']
3020 - ) . $final_quiz_btn . $final_quizz_passing,
3021 - 'evaluate_quiz' => __( 'Evaluate via quizzes passed', 'learnpress' ) . sprintf(
3022 - $course_tip,
3023 - $course_desc['evaluate_quiz']
2185 + 'evaluate_lesson' => sprintf(
2186 + '%s %s',
2187 + __( 'Evaluate via lessons', 'learnpress' ),
2188 + learn_press_quick_tip( $evaluations_desc['evaluate_lesson'], false )
3024 2189 ),
3025 - 'evaluate_questions' => __( 'Evaluate via questions', 'learnpress' ) . sprintf(
3026 - $course_tip,
3027 - $course_desc['evaluate_questions']
2190 + 'evaluate_final_quiz' => sprintf(
2191 + '%s %s %s %s',
2192 + __( 'Evaluate via results of the final quiz', 'learnpress' ),
2193 + learn_press_quick_tip( $evaluations_desc['evaluate_final_quiz'], false ),
2194 + $final_quiz_btn,
2195 + $final_quizz_passing
3028 2196 ),
3029 - 'evaluate_mark' => __( 'Evaluate via mark', 'learnpress' ) . sprintf(
3030 - $course_tip,
3031 - $course_desc['evaluate_mark']
2197 + 'evaluate_quiz' => sprintf(
2198 + '%s %s',
2199 + __( 'Evaluate via passed quizzes', 'learnpress' ),
2200 + learn_press_quick_tip( $evaluations_desc['evaluate_quiz'], false )
3032 2201 ),
3033 - )
2202 + 'evaluate_questions' => sprintf(
2203 + '%s %s',
2204 + __( 'Evaluate via questions', 'learnpress' ),
2205 + learn_press_quick_tip( $evaluations_desc['evaluate_questions'], false )
2206 + ),
2207 + 'evaluate_mark' => sprintf(
2208 + '%s %s',
2209 + __( 'Evaluate via mark', 'learnpress' ),
2210 + learn_press_quick_tip( $evaluations_desc['evaluate_mark'], false )
2211 + ),
2212 + ),
2213 + $postid
3034 2214 );
3035 2215
3036 2216 return apply_filters(
3037 2217 'learn-press/course-evaluation-methods',
@@ -3040,34 +2220,8 @@
3040 2220 );
3041 2221 }
3042 2222
3043 2223 /**
3044 - * Convert time from GMT to local.
3045 - *
3046 - * @param string|int|LP_Datetime $gmt_time
3047 - * @param string $format
3048 - *
3049 - * @return false|int|string
3050 - * @since 4.0.0
3051 - * @depecated 4.1.7.2
3052 - */
3053 -/*function learn_press_time_from_gmt( $gmt_time, $format = 'Y-m-d H:i:s' ) {
3054 - if ( is_string( $gmt_time ) ) {
3055 - $gmt_time = strtotime( $gmt_time );
3056 - } elseif ( $gmt_time instanceof LP_Datetime ) {
3057 - $gmt_time = strtotime( $gmt_time . '' );
3058 - }
3059 -
3060 - $current_time = $gmt_time + get_option( 'gmt_offset' ) * HOUR_IN_SECONDS;
3061 -
3062 - if ( $format ) {
3063 - return date( $format, $current_time );
3064 - }
3065 -
3066 - return $current_time;
3067 -}*/
3068 -
3069 -/**
3070 2224 * Get max retrying quiz allowed.
3071 2225 *
3072 2226 * @param int $quiz_id
3073 2227 * @param int $course_id
@@ -3079,21 +2233,8 @@
3079 2233 return apply_filters( 'learn-press/max-retry-quiz-allowed', 1, $quiz_id, $course_id );
3080 2234 }
3081 2235
3082 2236 /**
3083 - * Get max retrying course allowed.
3084 - *
3085 - * @param int $course_id
3086 - *
3087 - * @return int
3088 - * @since 4.0.0
3089 - * @depecated 4.1.7.2
3090 - */
3091 -/*function learn_press_get_course_max_retrying( $course_id ) {
3092 - return apply_filters( 'learn-press/max-retry-course-allowed', 1, $course_id );
3093 -}*/
3094 -
3095 -/**
3096 2237 * Get slug for status of course/lesson/quiz if user
3097 2238 * completed/finished and graduation is passed.
3098 2239 *
3099 2240 * @param string $type
@@ -3141,82 +2282,24 @@
3141 2282 }
3142 2283
3143 2284 //require_once dirname( __FILE__ ) . '/lp-custom-hooks.php';
3144 2285
3145 -
3146 -/**
3147 - * Disable auto update
3148 - *
3149 - * @param $update
3150 - * @param $item
3151 - *
3152 - * @return false
3153 - * @author hungkv
3154 - */
3155 -/*function learnpress_disable_auto_update( $update, $item ) {
3156 - $plugins = array( // Plugins to auto-update
3157 - 'learnpress',
3158 - );
3159 - // Auto-update specified plugins
3160 - if ( in_array( $item->slug, $plugins ) ) {
3161 - return false;
3162 - }
3163 -}
3164 -add_filter( 'auto_update_plugin', 'learnpress_disable_auto_update', 10, 2 );*/
3165 -
3166 -add_action(
2286 +// Notify update message for LearnPress plugin
2287 +/*add_action(
3167 2288 'in_plugin_update_message-learnpress/learnpress.php',
3168 2289 function ( $plugin_data ) {
3169 - version_update_warning( LEARNPRESS_VERSION, $plugin_data['new_version'] );
3170 - }
3171 -);
3172 -/**
3173 - * Custom message warning have new version
3174 - *
3175 - * @param $current_version
3176 - * @param $new_version
3177 - * @author hungkv
3178 - */
3179 -function version_update_warning( $current_version, $new_version ) {
3180 - $current_version_minor_part = explode( '.', $current_version )[1];
3181 - $new_version_minor_part = explode( '.', $new_version )[1];
3182 - if ( $current_version_minor_part === $new_version_minor_part ) {
3183 - return;
3184 - }
3185 -
3186 - $info = get_plugin_data( LP_PLUGIN_FILE );
3187 - ?>
3188 - <hr class="lp-update--warning__separator"/>
3189 - <div class="lp-update--warning">
3190 - <div>
3191 - <div class="lp-update-warning__title">
3192 - <?php echo esc_html__( 'Heads up, Please backup before upgrade!', 'learnpress' ); ?>
3193 - </div>
3194 - <div class="lp-update-warning__message">
3195 - <?php echo esc_html__( 'The latest update includes some substantial changes across different areas of the plugin. We highly recommend you backup your site before upgrading, and make sure you first update in a staging environment', 'learnpress' ); ?>
3196 - <?php echo esc_html__( 'Learners require WordPress version ' . $info['Requires at least'] . ' or higher.', 'learnpress' ); ?>
3197 - </div>
3198 - </div>
3199 - </div>
3200 -
3201 - <?php
3202 -}
3203 -
3204 -// If profile content don't have shortcode profile.
3205 -function lp_add_shortcode_profile() {
3206 - global $post;
3207 -
3208 - if ( learn_press_is_profile() && is_object( $post ) ) {
3209 - if ( ! has_shortcode( $post->post_content, 'learn_press_profile' ) ) {
3210 - $post->post_content .= '<!-- wp:shortcode -->[' . apply_filters( 'learn-press/shortcode/profile/tag', 'learn_press_profile' ) . ']<!-- /wp:shortcode -->';
2290 + if ( version_compare( $plugin_data['new_version'], LEARNPRESS_VERSION, '<=' ) ) {
2291 + return;
3211 2292 }
3212 2293
3213 - wp_update_post( $post );
2294 + echo sprintf(
2295 + '<hr/><h3>%s</h3><div>%s</div>',
2296 + esc_html__( 'Heads up! Please backup before upgrading!', 'learnpress' ),
2297 + esc_html__( 'The latest update includes some substantial changes across different areas of the plugin. We highly recommend you backup your site before upgrading, and make sure you first update in a staging environment', 'learnpress' )
2298 + );
3214 2299 }
3215 -}
2300 +);*/
3216 2301
3217 -add_action( 'template_redirect', 'lp_add_shortcode_profile' );
3218 -
3219 2302 /**
3220 2303 * If Elementor Pro set Theme builder type "Archive", will not show content on page "Archive course"
3221 2304 *
3222 2305 * @editor tungnx
@@ -3226,9 +2309,9 @@
3226 2309 * @version 1.0.1
3227 2310 */
3228 2311 add_filter(
3229 2312 'elementor/theme/get_location_templates/template_id',
3230 - function( $theme_template_id ) {
2313 + function ( $theme_template_id ) {
3231 2314 $elementor_template_type = get_post_meta( $theme_template_id, '_elementor_template_type', true );
3232 2315
3233 2316 if ( in_array( $elementor_template_type, array( 'archive' ) ) ) {
3234 2317 if ( LP_PAGE_COURSES === LP_Page_Controller::page_current() && class_exists( 'ElementorPro\Modules\ThemeBuilder\Conditions\Archive' ) ) {