PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.8
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.8
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 4.2.0 All 139 releases
← All changes | inc/lp-core-functions.php +176 -1067 4.1.7.34.4.8 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 - * @deprecated 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 - * @deprecated 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
@@ -1792,10 +1298,12 @@
1792 1298 * @param string
1793 1299 * @param string
1794 1300 *
1795 1301 * @return mixed
1302 + * @deprecated 4.2.5
1796 1303 */
1797 1304 function learn_press_add_notice( $message, $type = 'updated' ) {
1305 + _deprecated_function( __FUNCTION__, '4.2.5' );
1798 1306 LP_Admin_Notice::instance()->add( $message, $type );
1799 1307 }
1800 1308
1801 1309 /**
@@ -1800,29 +1308,29 @@
1800 1308
1801 1309 /**
1802 1310 * Set user's cookie
1803 1311 *
1804 - * @param $name
1805 - * @param $value
1806 - * @param int $expire
1807 - * @param bool $secure
1312 + * @param string $name
1313 + * @param mixed $value
1314 + * @param int $expire
1315 + * @param bool $httponly
1808 1316 *
1809 1317 * @editor tungnx
1810 - * @version 1.0.2
1318 + * @version 1.0.3
1811 1319 */
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 );
1320 +function learn_press_setcookie( string $name = '', string $value = '', int $expire = 0, bool $httponly = true ) {
1321 + @setcookie( $name, $value, $expire, COOKIEPATH ?: '/', COOKIE_DOMAIN, is_ssl(), $httponly );
1816 1322 }
1817 1323
1818 1324 /**
1819 1325 * Clear cookie
1820 1326 *
1821 - * @param $name
1327 + * @param string $name
1822 1328 */
1823 -function learn_press_remove_cookie( $name ) {
1824 - setcookie( $name, '', time() - YEAR_IN_SECONDS, COOKIEPATH ? COOKIEPATH : '/', COOKIE_DOMAIN );
1329 +function learn_press_remove_cookie( string $name = '' ) {
1330 + if ( ! empty( $name ) ) {
1331 + setcookie( $name, '', time() - YEAR_IN_SECONDS, COOKIEPATH ? COOKIEPATH : '/', COOKIE_DOMAIN, is_ssl(), true );
1332 + }
1825 1333
1826 1334 if ( array_key_exists( $name, $_COOKIE ) ) {
1827 1335 unset( $_COOKIE[ $name ] );
1828 1336 }
@@ -1828,9 +1336,9 @@
1828 1336 }
1829 1337 }
1830 1338
1831 1339 /**
1832 - * Filter the login url so third-party can be customize
1340 + * Filter the login url so third-party can be customized
1833 1341 *
1834 1342 * @param string $redirect
1835 1343 *
1836 1344 * @return mixed
@@ -1880,45 +1388,12 @@
1880 1388 return apply_filters( 'learn_press_get_endpoint_url', esc_url_raw( $url ), $name, $value, $url );
1881 1389 }
1882 1390
1883 1391 /**
1884 - * Add all endpoints from settings to the pages.
1392 + * @deprecated 4.2.3
1885 1393 */
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 1394 function learn_press_is_yes( $value ) {
1395 + _deprecated_function( __FUNCTION__, '4.2.3' );
1921 1396 return ( $value === 1 ) || ( $value === '1' ) || ( $value == 'yes' ) || ( $value == true ) || ( $value == 'on' );
1922 1397 }
1923 1398
1924 1399 /**
@@ -1924,10 +1399,12 @@
1924 1399 /**
1925 1400 * @param mixed $value
1926 1401 *
1927 1402 * @return bool
1403 + * @deprecated 4.2.3
1928 1404 */
1929 1405 function _is_false_value( $value ) {
1406 + _deprecated_function( __FUNCTION__, '4.2.3' );
1930 1407 if ( is_numeric( $value ) ) {
1931 1408 return $value == 0;
1932 1409 } elseif ( is_string( $value ) ) {
1933 1410 return ( empty( $value ) || is_null( $value ) || in_array( $value, array( 'no', 'off', 'false' ) ) );
@@ -1967,54 +1444,18 @@
1967 1444 }
1968 1445 }
1969 1446
1970 1447 /**
1971 - * @param string $handle
1972 - * @param bool $hash
1973 - *
1974 - * @return string
1975 - * @deprecated 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 1448 * Get the cart object in checkout page
1987 1449 *
1988 1450 * @return LP_Cart
1451 + * @deprecated 4.2.0
1989 1452 */
1990 1453 function learn_press_get_checkout_cart() {
1454 + _deprecated_function( __FUNCTION__, '4.2.0', 'LearnPress::instance()->cart' );
1991 1455 return apply_filters( 'learn_press_checkout_cart', LearnPress::instance()->cart );
1992 1456 }
1993 1457
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 1458 function learn_press_user_time( $time, $format = 'timestamp' ) {
2018 1459 if ( is_string( $time ) ) {
2019 1460 $time = @strtotime( $time );
2020 1461 }
@@ -2040,8 +1481,10 @@
2040 1481 *
2041 1482 * @param bool $default
2042 1483 *
2043 1484 * @return mixed|string
1485 + * @deprecated 4.2.2
1486 + * addon commission 4.0.2 still use this function
2044 1487 */
2045 1488 function learn_press_get_current_profile_tab( $default = true ) {
2046 1489 global $wp_query, $wp;
2047 1490 $current = '';
@@ -2046,12 +1489,9 @@
2046 1489 global $wp_query, $wp;
2047 1490 $current = '';
2048 1491
2049 1492 // Only load on profile page.
2050 - $page_profile_option = untrailingslashit( get_the_permalink( learn_press_get_page_id( 'profile' ) ) );
2051 - $page_profile_option = str_replace( '/', '\/', $page_profile_option );
2052 - $pattern = '/' . $page_profile_option . '/';
2053 - if ( ! preg_match( $pattern, LP_Helper::getUrlCurrent() ) ) {
1493 + if ( ! LP_Page_Controller::is_page_profile() ) {
2054 1494 return false;
2055 1495 }
2056 1496
2057 1497 if ( ! empty( $_REQUEST['tab'] ) ) {
@@ -2075,9 +1515,9 @@
2075 1515
2076 1516 return $current;
2077 1517 }
2078 1518
2079 -add_action( 'init', 'learn_press_get_current_profile_tab' );
1519 +//add_action( 'init', 'learn_press_get_current_profile_tab' );
2080 1520
2081 1521 function learn_press_profile_tab_exists( $tab ) {
2082 1522 $tabs = learn_press_get_user_profile_tabs();
2083 1523
@@ -2087,40 +1527,8 @@
2087 1527
2088 1528 return false;
2089 1529 }
2090 1530
2091 -/**
2092 - * Replace the spacing with the + (plus) char.
2093 - *
2094 - * @param string $string
2095 - *
2096 - * @return string
2097 - * @deprecated 4.1.7.2
2098 - */
2099 -/*function _learn_press_urlencode( $string ) {
2100 - return preg_replace( '/\s/', '+', $string );
2101 -}*/
2102 -
2103 -/**
2104 - * Point the archive post type link to course page if current
2105 - * post type is course and the page for displaying course is
2106 - * setup.
2107 - *
2108 - * @param string $link
2109 - * @param string $post_type
2110 - *
2111 - * @return string
2112 - * @deprecated 4.1.7.2
2113 - */
2114 -/*function learn_press_post_type_archive_link( $link, $post_type ) {
2115 - if ( $post_type == LP_COURSE_CPT && learn_press_get_page_id( 'courses' ) ) {
2116 - $link = learn_press_get_page_link( 'courses' );
2117 - }
2118 -
2119 - return $link;
2120 -}*/
2121 -//add_filter( 'post_type_archive_link', 'learn_press_post_type_archive_link', 10, 2 );
2122 -
2123 1531 function learn_press_single_term_title( $prefix = '', $display = true ) {
2124 1532 $term = get_queried_object();
2125 1533
2126 1534 if ( ! $term ) {
@@ -2367,33 +1775,8 @@
2367 1775 die( __FUNCTION__ );
2368 1776 }
2369 1777 }
2370 1778
2371 -/**
2372 - * Get current time to user for calculate remaining time of quiz.
2373 - *
2374 - * @return int
2375 - * @deprecated 4.1.7.2
2376 - */
2377 -/*function learn_press_get_current_time() {
2378 - $current_time = apply_filters( 'learn_press_get_current_time', 0 );
2379 -
2380 - if ( $current_time > 0 ) {
2381 - return $current_time;
2382 - }
2383 -
2384 - $a = current_time( 'timestamp' );
2385 - $b = time();
2386 - $c = current_time( 'mysql' );
2387 - $d = strtotime( $c );
2388 -
2389 - if ( $d == $a ) {
2390 - return $a;
2391 - } else {
2392 - return $b;
2393 - }
2394 -}*/
2395 -
2396 1779 function learn_press_get_requested_post_type() {
2397 1780 global $pagenow;
2398 1781 if ( $pagenow == 'post-new.php' && ! empty( $_REQUEST['post_type'] ) ) {
2399 1782 $post_type = LP_Helper::sanitize_params_submitted( $_REQUEST['post_type'] );
@@ -2533,30 +1916,14 @@
2533 1916 echo '<span class="learn-press-tooltip" data-tooltip="' . esc_attr( $tooltip ) . '"></span>';
2534 1917 }
2535 1918
2536 1919 /**
2537 - * Get timezone offset from wp settings.
2538 - *
2539 - * @return float|int
2540 - * @since 3.0.0
2541 - * @deprecated 4.1.7.2
2542 - */
2543 -/*function learn_press_timezone_offset() {
2544 - if ( $tz = get_option( 'timezone_string' ) ) {
2545 - $timezone = new DateTimeZone( $tz );
2546 -
2547 - return $timezone->getOffset( new DateTime( 'now' ) );
2548 - } else {
2549 - return floatval( get_option( 'gmt_offset', 0 ) ) * HOUR_IN_SECONDS;
2550 - }
2551 -}*/
2552 -
2553 -/**
2554 1920 * Get default static pages of LP.
2555 1921 *
2556 1922 * @return array
2557 1923 *
2558 1924 * @since 3.0.0
1925 + * @deprecated 4.2.3
2559 1926 */
2560 1927 function learn_press_static_page_ids() {
2561 1928 $pages = LP_Object_Cache::get( 'static-page-ids', 'learn-press' );
2562 1929
@@ -2580,35 +1947,8 @@
2580 1947 return apply_filters( 'learn-press/static-page-ids', $pages );
2581 1948 }
2582 1949
2583 1950 /**
2584 - * Get default static pages of LP.
2585 - *
2586 - * @param bool $name - Optional. TRUE will return name only.
2587 - *
2588 - * @return array
2589 - *
2590 - * @since 3.0.0
2591 - */
2592 -function learn_press_static_pages( $name = false ) {
2593 - $pages = apply_filters(
2594 - 'learn-press/static-pages',
2595 - array(
2596 - 'checkout' => _x( 'Checkout', 'static-page-name', 'learnpress' ),
2597 - 'courses' => _x( 'Courses', 'static-page-name', 'learnpress' ),
2598 - 'profile' => _x( 'Profile', 'static-page-name', 'learnpress' ),
2599 - 'become_a_teacher' => _x( 'Become a Teacher', 'static-page-name', 'learnpress' ),
2600 - )
2601 - );
2602 -
2603 - if ( $name ) {
2604 - return array_keys( $pages );
2605 - }
2606 -
2607 - return $pages;
2608 -}
2609 -
2610 -/**
2611 1951 * Callback function for sorting to array|object by key|prop priority.
2612 1952 *
2613 1953 * @param array|object $a
2614 1954 * @param array|object $b
@@ -2614,10 +1954,11 @@
2614 1954 * @param array|object $b
2615 1955 *
2616 1956 * @return int
2617 1957 * @since 3.0.0
1958 + * @deprecated 4.4.5
2618 1959 */
2619 -function learn_press_sort_list_by_priority_callback( $a, $b ) {
1960 +/*function learn_press_sort_list_by_priority_callback( $a, $b ) {
2620 1961 $a_priority = null;
2621 1962 $b_priority = null;
2622 1963
2623 1964 if ( is_array( $a ) && array_key_exists( 'priority', $a ) ) {
@@ -2644,26 +1985,32 @@
2644 1985 return 0;
2645 1986 }
2646 1987
2647 1988 return ( $a_priority < $b_priority ) ? - 1 : 1;
2648 -}
1989 +}*/
2649 1990
2650 1991 /**
2651 1992 * Localize date with custom format.
2652 1993 *
2653 - * @param string $timestamp
1994 + * @param int|bool $timestamp
2654 1995 * @param string $format
2655 1996 * @param bool $gmt
2656 1997 *
2657 1998 * @return string
2658 1999 * @since 3.0.0
2000 + * @deprcated 4.2.6 use LP_Datetime format instead
2659 2001 */
2660 -function learn_press_date_i18n( $timestamp = '', $format = '', $gmt = false ) {
2002 +function learn_press_date_i18n( $timestamp = 0, string $format = '', bool $gmt = false ): string {
2661 2003 if ( ! $format ) {
2662 2004 $format = get_option( 'date_format' );
2663 2005 }
2664 2006
2665 - return date_i18n( $format, $timestamp, $gmt );
2007 + $date_str = date_i18n( $format, $timestamp, $gmt );
2008 + if ( ! is_string( $date_str ) ) {
2009 + $date_str = '';
2010 + }
2011 +
2012 + return $date_str;
2666 2013 }
2667 2014
2668 2015 /**
2669 2016 * Get item types of course support for blocking. Default is lp_lesson
@@ -2709,42 +2056,8 @@
2709 2056 return $post_type;
2710 2057 }
2711 2058
2712 2059 /**
2713 - * Add post type of a post into cache
2714 - *
2715 - * @param int|array $id
2716 - * @param string $type
2717 - *
2718 - * @since 3.1.0
2719 - * @deprecated 4.1.7.2
2720 - */
2721 -/*function learn_press_cache_add_post_type( $id, $type = '' ) {
2722 - if ( false === ( $post_types = LP_Object_Cache::get( 'post-types', 'learn-press' ) ) ) {
2723 - $post_types = array();
2724 - }
2725 -
2726 - if ( func_num_args() == 1 && is_array( $id ) ) {
2727 - $post_types = $post_types + $id;
2728 - } else {
2729 - $post_types[ $id ] = $type;
2730 - }
2731 -
2732 - LP_Object_Cache::set( 'post-types', $post_types, 'learn-press' );
2733 -}*/
2734 -
2735 -/**
2736 - * @deprecated 4.1.7.2
2737 - */
2738 -/*function learn_press_has_option( $name ) {
2739 - global $wpdb;
2740 -
2741 - $query = $wpdb->prepare( "SELECT option_id FROM {$wpdb->options} WHERE option_name = %s", $name );
2742 -
2743 - return $wpdb->get_var( $query ) > 0;
2744 -}*/
2745 -
2746 -/**
2747 2060 * Update option to enable shuffle themes for ad.
2748 2061 *
2749 2062 * @since 3.2.1
2750 2063 */
@@ -2754,102 +2067,36 @@
2754 2067
2755 2068 add_action( 'learn-press/schedule-enable-shuffle-themes', '_learn_press_schedule_enable_shuffle_themes' );
2756 2069
2757 2070 /**
2758 - * @deprecated 4.1.7.2
2759 - */
2760 -/*function learn_press_show_log() {
2761 - if ( trim( LP_Request::get( 'show_log' ) ) === md5( AUTH_KEY ) ) {
2762 - call_user_func_array( 'learn_press_debug', func_get_args() );
2763 - }
2764 -}*/
2765 -
2766 -/**
2071 + * Return localize script data for admin.
2072 + *
2767 2073 * @return array
2768 2074 * @since 3.2.6
2075 + * @version 1.0.1
2769 2076 */
2770 -function learn_press_global_script_params() {
2771 - $js = array(
2772 - 'ajax' => admin_url( 'admin-ajax.php' ),
2773 - 'plugin_url' => LearnPress::instance()->plugin_url(),
2774 - 'siteurl' => home_url(),
2775 - 'current_url' => learn_press_get_current_url(),
2776 - 'theme' => get_stylesheet(),
2777 - 'localize' => array(
2077 +function learn_press_global_script_params(): array {
2078 + $localize = [
2079 + 'ajax' => admin_url( 'admin-ajax.php' ),
2080 + 'plugin_url' => LearnPress::instance()->plugin_url(),
2081 + 'siteurl' => home_url(),
2082 + //'current_url' => learn_press_get_current_url(),
2083 + 'theme' => get_stylesheet(),
2084 + 'localize' => array(
2778 2085 'button_ok' => __( 'OK', 'learnpress' ),
2779 2086 'button_cancel' => __( 'Cancel', 'learnpress' ),
2780 2087 'button_yes' => __( 'Yes', 'learnpress' ),
2781 2088 'button_no' => __( 'No', 'learnpress' ),
2782 2089 ),
2783 - 'root' => esc_url_raw( rest_url() ),
2784 - 'nonce' => wp_create_nonce( 'wp_rest' ),
2785 - );
2090 + 'rest' => esc_url_raw( rest_url() ),
2091 + 'nonce' => wp_create_nonce( 'wp_rest' ),
2092 + 'is_admin' => current_user_can( ADMIN_ROLE ),
2093 + ];
2786 2094
2787 - return $js;
2095 + return apply_filters( 'lp/admin/localize/scripts', $localize );
2788 2096 }
2789 2097
2790 2098 /**
2791 - * Get url for setup cron job on server.
2792 - *
2793 - * @return string
2794 - * @since 3.3.0
2795 - * @deprecated 4.1.7.2
2796 - */
2797 -/*function learn_press_get_cron_url() {
2798 - $nonce = get_option( 'learnpress_cron_url_nonce' );
2799 -
2800 - if ( ! $nonce ) {
2801 - $nonce = md5( microtime( true ) );
2802 - update_option( 'learnpress_cron_url_nonce', $nonce );
2803 - }
2804 - $url = add_query_arg(
2805 - array(
2806 - 'lp-ajax' => 'cron',
2807 - 'sid' => $nonce,
2808 - ),
2809 - get_home_url()
2810 - );
2811 -
2812 - return $url;
2813 -}*/
2814 -
2815 -/**
2816 - * Get courses expired.
2817 - *
2818 - * @return array
2819 - * @since 3.3.0
2820 - * @deprecated 4.1.7.2
2821 - */
2822 -/*function learn_press_get_expired_courses() {
2823 - global $wpdb;
2824 -
2825 - $query = $wpdb->prepare(
2826 - "
2827 - SELECT X.*
2828 - FROM(
2829 - SELECT ui.*
2830 - FROM {$wpdb->learnpress_user_items} ui
2831 - LEFT JOIN {$wpdb->learnpress_user_items} uix
2832 - ON ui.item_id = uix.item_id
2833 - AND ui.user_id = uix.user_id
2834 - AND ui.user_item_id < uix.user_item_id
2835 - WHERE uix.user_item_id IS NULL
2836 - ) X
2837 - INNER JOIN {$wpdb->users} u ON u.ID = X.user_id
2838 - INNER JOIN {$wpdb->posts} p ON p.ID = X.item_id
2839 - WHERE X.item_type = %s
2840 - AND X.status = %s
2841 - #AND expiration_time_gmt <= UTC_TIMESTAMP()
2842 - AND expiration_time <= UTC_TIMESTAMP()
2843 - LIMIT 0, 10
2844 - ",
2845 - LP_COURSE_CPT,
2846 - 'enrolled'
2847 - );
2848 -
2849 -}*/
2850 -
2851 -/**
2852 2099 * Return list types of questions that support answer options.
2853 2100 *
2854 2101 * @return array
2855 2102 * @since 3.3.0
@@ -2883,85 +2130,15 @@
2883 2130 return $questions;
2884 2131 }
2885 2132
2886 2133 /**
2887 - * Helper function to output html for rendering a 'circle progress bar'
2134 + * LP Cookie
2888 2135 *
2889 - * @param int $percent
2890 - * @param int $width
2891 - * @param int $border
2892 - * @param string $color
2136 + * @param $name
2137 + * @param $namespace
2893 2138 *
2894 - * @since 3.3.0
2895 - * @deprecated 4.1.7.2
2139 + * @return mixed|null
2896 2140 */
2897 -/*function learn_press_circle_progress_html( $percent = 0, $width = 32, $border = 4, $color = '' ) {
2898 - $radius = $width / 2;
2899 - $r = ( $width - $border ) / 2;
2900 - $circumference = $r * 2 * pi();
2901 - $offset = $circumference - $percent / 100 * $circumference;
2902 -
2903 - printf(
2904 - '<svg class="circle-progress-bar" width="%d" height="%d">
2905 - <circle class="circle-progress-bar__circle"
2906 - stroke="%s"
2907 - stroke-width="%d"
2908 - style="stroke-dasharray:%s %s; stroke-dashoffset:%s;"
2909 - fill="transparent"
2910 - r="%d" cx="%d" cy="%d"></circle>
2911 - </svg>',
2912 - $width,
2913 - $width,
2914 - $color,
2915 - $border,
2916 - $circumference,
2917 - $circumference,
2918 - $offset,
2919 - $r,
2920 - $radius,
2921 - $radius
2922 - );
2923 -}*/
2924 -
2925 -/**
2926 - * @deprecated 4.1.7.2
2927 - */
2928 -/*function learn_press_is_page( $page_name ) {
2929 - $page_id = learn_press_get_page_id( $page_name );
2930 -
2931 - return $page_id && is_page( $page_id );
2932 -}*/
2933 -
2934 -/**
2935 - * Get end-date from start date with a duration.
2936 - *
2937 - * @param string|int $duration
2938 - * @param string|int $start
2939 - *
2940 - * @return false|string
2941 - * @since 3.x.x
2942 - * @deprecated 4.1.7.2
2943 - */
2944 -/*function learn_press_date_end_from( $duration, $start = '' ) {
2945 - $format = 'Y-m-d H:i:s';
2946 -
2947 - if ( ! $start ) {
2948 - $start = time();
2949 - } elseif ( ! is_numeric( $start ) ) {
2950 - $start = strtotime( $start );
2951 - }
2952 -
2953 - // is LP duration format, e.g: 10 weeks
2954 - if ( preg_match( '/^[0-9]+ [a-z]+$/', $duration ) ) {
2955 - $duration = ( new LP_Duration( $duration ) )->get();
2956 - } elseif ( ! is_numeric( $duration ) ) {
2957 - // 10 days 5 hours ...
2958 - $duration = strtotime( $duration, 0 );
2959 - }
2960 -
2961 - return date( $format, $start + $duration );
2962 -}*/
2963 -
2964 2141 function learn_press_cookie_get( $name, $namespace = 'LP' ) {
2965 2142 if ( $namespace ) {
2966 2143 $cookie = ! empty( $_COOKIE[ $namespace ] ) ? (array) json_decode( LP_Helper::sanitize_params_submitted( stripslashes( $_COOKIE[ $namespace ] ), 'html' ) ) : array();
2967 2144 } else {
@@ -2979,15 +2156,16 @@
2979 2156 * @return array
2980 2157 * @since 3.x.x
2981 2158 */
2982 2159 function learn_press_course_evaluation_methods( $postid, $return = '', $final_quizz_passing = '' ) {
2983 - $course_tip = '<span class="learn-press-tip">%s</span>';
2984 - $final_quiz_btn = '<a href="#" class="lp-metabox-get-final-quiz" data-postid="' . $postid . '" data-loading="' . esc_attr__(
2985 - 'Loading...',
2986 - 'learnpress'
2987 - ) . '">' . esc_html__( 'Get A Passing Grade', 'learnpress' ) . '</a>';
2160 + $final_quiz_btn = sprintf(
2161 + '<a href="#" class="lp-metabox-get-final-quiz" data-postid="%d" data-loading="%s">%s</a>',
2162 + $postid,
2163 + esc_attr__( 'Loading...', 'learnpress' ),
2164 + esc_html__( 'Get A Passing Grade', 'learnpress' )
2165 + );
2988 2166
2989 - $course_desc = array(
2167 + $evaluations_desc = array(
2990 2168 'evaluate_lesson' => sprintf(
2991 2169 '<p>%s<br/>%s</p>',
2992 2170 __( 'Evaluate by the number of completed lessons per the total number of lessons.', 'learnpress' ),
2993 2171 __( 'E.g: If a course has 10 lessons and a user completes 5 lessons, then the result is 5/10 (50%).', 'learnpress' )
@@ -3017,29 +2195,37 @@
3017 2195
3018 2196 $methods = apply_filters(
3019 2197 'learnpress/course-evaluation/methods',
3020 2198 array(
3021 - 'evaluate_lesson' => __(
3022 - 'Evaluate via lessons',
3023 - 'learnpress'
3024 - ) . learn_press_quick_tip( $course_desc['evaluate_lesson'], false ),
3025 - 'evaluate_final_quiz' => __( 'Evaluate via results of the final quiz', 'learnpress' ) . sprintf(
3026 - $course_tip,
3027 - $course_desc['evaluate_final_quiz']
3028 - ) . $final_quiz_btn . $final_quizz_passing,
3029 - 'evaluate_quiz' => __( 'Evaluate via passed quizzes', 'learnpress' ) . sprintf(
3030 - $course_tip,
3031 - $course_desc['evaluate_quiz']
2199 + 'evaluate_lesson' => sprintf(
2200 + '%s %s',
2201 + __( 'Evaluate via lessons', 'learnpress' ),
2202 + learn_press_quick_tip( $evaluations_desc['evaluate_lesson'], false )
3032 2203 ),
3033 - 'evaluate_questions' => __( 'Evaluate via questions', 'learnpress' ) . sprintf(
3034 - $course_tip,
3035 - $course_desc['evaluate_questions']
2204 + 'evaluate_final_quiz' => sprintf(
2205 + '%s %s %s %s',
2206 + __( 'Evaluate via results of the final quiz', 'learnpress' ),
2207 + learn_press_quick_tip( $evaluations_desc['evaluate_final_quiz'], false ),
2208 + $final_quiz_btn,
2209 + $final_quizz_passing
3036 2210 ),
3037 - 'evaluate_mark' => __( 'Evaluate via mark', 'learnpress' ) . sprintf(
3038 - $course_tip,
3039 - $course_desc['evaluate_mark']
2211 + 'evaluate_quiz' => sprintf(
2212 + '%s %s',
2213 + __( 'Evaluate via passed quizzes', 'learnpress' ),
2214 + learn_press_quick_tip( $evaluations_desc['evaluate_quiz'], false )
3040 2215 ),
3041 - )
2216 + 'evaluate_questions' => sprintf(
2217 + '%s %s',
2218 + __( 'Evaluate via questions', 'learnpress' ),
2219 + learn_press_quick_tip( $evaluations_desc['evaluate_questions'], false )
2220 + ),
2221 + 'evaluate_mark' => sprintf(
2222 + '%s %s',
2223 + __( 'Evaluate via mark', 'learnpress' ),
2224 + learn_press_quick_tip( $evaluations_desc['evaluate_mark'], false )
2225 + ),
2226 + ),
2227 + $postid
3042 2228 );
3043 2229
3044 2230 return apply_filters(
3045 2231 'learn-press/course-evaluation-methods',
@@ -3048,34 +2234,8 @@
3048 2234 );
3049 2235 }
3050 2236
3051 2237 /**
3052 - * Convert time from GMT to local.
3053 - *
3054 - * @param string|int|LP_Datetime $gmt_time
3055 - * @param string $format
3056 - *
3057 - * @return false|int|string
3058 - * @since 4.0.0
3059 - * @deprecated 4.1.7.2
3060 - */
3061 -/*function learn_press_time_from_gmt( $gmt_time, $format = 'Y-m-d H:i:s' ) {
3062 - if ( is_string( $gmt_time ) ) {
3063 - $gmt_time = strtotime( $gmt_time );
3064 - } elseif ( $gmt_time instanceof LP_Datetime ) {
3065 - $gmt_time = strtotime( $gmt_time . '' );
3066 - }
3067 -
3068 - $current_time = $gmt_time + get_option( 'gmt_offset' ) * HOUR_IN_SECONDS;
3069 -
3070 - if ( $format ) {
3071 - return date( $format, $current_time );
3072 - }
3073 -
3074 - return $current_time;
3075 -}*/
3076 -
3077 -/**
3078 2238 * Get max retrying quiz allowed.
3079 2239 *
3080 2240 * @param int $quiz_id
3081 2241 * @param int $course_id
@@ -3087,21 +2247,8 @@
3087 2247 return apply_filters( 'learn-press/max-retry-quiz-allowed', 1, $quiz_id, $course_id );
3088 2248 }
3089 2249
3090 2250 /**
3091 - * Get max retrying course allowed.
3092 - *
3093 - * @param int $course_id
3094 - *
3095 - * @return int
3096 - * @since 4.0.0
3097 - * @deprecated 4.1.7.2
3098 - */
3099 -/*function learn_press_get_course_max_retrying( $course_id ) {
3100 - return apply_filters( 'learn-press/max-retry-course-allowed', 1, $course_id );
3101 -}*/
3102 -
3103 -/**
3104 2251 * Get slug for status of course/lesson/quiz if user
3105 2252 * completed/finished and graduation is passed.
3106 2253 *
3107 2254 * @param string $type
@@ -3149,62 +2296,24 @@
3149 2296 }
3150 2297
3151 2298 //require_once dirname( __FILE__ ) . '/lp-custom-hooks.php';
3152 2299
3153 -
3154 -/**
3155 - * Disable auto update
3156 - *
3157 - * @param $update
3158 - * @param $item
3159 - *
3160 - * @return false
3161 - * @author hungkv
3162 - */
3163 -/*function learnpress_disable_auto_update( $update, $item ) {
3164 - $plugins = array( // Plugins to auto-update
3165 - 'learnpress',
3166 - );
3167 - // Auto-update specified plugins
3168 - if ( in_array( $item->slug, $plugins ) ) {
3169 - return false;
3170 - }
3171 -}
3172 -add_filter( 'auto_update_plugin', 'learnpress_disable_auto_update', 10, 2 );*/
3173 -
3174 -add_action(
2300 +// Notify update message for LearnPress plugin
2301 +/*add_action(
3175 2302 'in_plugin_update_message-learnpress/learnpress.php',
3176 2303 function ( $plugin_data ) {
3177 2304 if ( version_compare( $plugin_data['new_version'], LEARNPRESS_VERSION, '<=' ) ) {
3178 2305 return;
3179 2306 }
3180 - ?>
3181 - <hr/>
3182 - <h3>
3183 - <?php echo esc_html__( 'Heads up! Please backup before upgrading!', 'learnpress' ); ?>
3184 - </h3>
3185 - <div>
3186 - <?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' ); ?>
3187 - </div>
3188 - <?php
3189 - }
3190 -);
3191 2307
3192 -// If profile content don't have shortcode profile.
3193 -function lp_add_shortcode_profile() {
3194 - global $post;
3195 -
3196 - if ( learn_press_is_profile() && is_object( $post ) ) {
3197 - if ( ! has_shortcode( $post->post_content, 'learn_press_profile' ) ) {
3198 - $post->post_content .= '<!-- wp:shortcode -->[' . apply_filters( 'learn-press/shortcode/profile/tag', 'learn_press_profile' ) . ']<!-- /wp:shortcode -->';
3199 - }
3200 -
3201 - wp_update_post( $post );
2308 + echo sprintf(
2309 + '<hr/><h3>%s</h3><div>%s</div>',
2310 + esc_html__( 'Heads up! Please backup before upgrading!', 'learnpress' ),
2311 + 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' )
2312 + );
3202 2313 }
3203 -}
2314 +);*/
3204 2315
3205 -add_action( 'template_redirect', 'lp_add_shortcode_profile' );
3206 -
3207 2316 /**
3208 2317 * If Elementor Pro set Theme builder type "Archive", will not show content on page "Archive course"
3209 2318 *
3210 2319 * @editor tungnx
@@ -3214,9 +2323,9 @@
3214 2323 * @version 1.0.1
3215 2324 */
3216 2325 add_filter(
3217 2326 'elementor/theme/get_location_templates/template_id',
3218 - function( $theme_template_id ) {
2327 + function ( $theme_template_id ) {
3219 2328 $elementor_template_type = get_post_meta( $theme_template_id, '_elementor_template_type', true );
3220 2329
3221 2330 if ( in_array( $elementor_template_type, array( 'archive' ) ) ) {
3222 2331 if ( LP_PAGE_COURSES === LP_Page_Controller::page_current() && class_exists( 'ElementorPro\Modules\ThemeBuilder\Conditions\Archive' ) ) {