LearnPress – WordPress LMS Plugin - Version 2.1.0

Version Description

  • Fixed bugs related to AJAX calling
  • Fixed bugs related to updating user profile
  • Fixed open question to new tab in quiz editor
Download this release

Release Info

Developer tunnhn
Plugin Icon 128x128 LearnPress – WordPress LMS Plugin
Version 2.1.0
Comparing to
See all releases

Code changes from version 2.0.9 to 2.1.0

assets/css/admin/meta-box-course.css CHANGED
@@ -404,7 +404,6 @@
404
.rwmb-curriculum-wrapper .rwmb-input {
405
width: auto !important;
406
display: block;
407
- float: none;
408
}
409
.column-lp_course .row-actions {
410
display: inline-block;
404
.rwmb-curriculum-wrapper .rwmb-input {
405
width: auto !important;
406
display: block;
407
}
408
.column-lp_course .row-actions {
409
display: inline-block;
assets/css/admin/meta-box-course.less CHANGED
@@ -496,7 +496,6 @@
496
.rwmb-curriculum-wrapper .rwmb-input {
497
width: auto !important;
498
display: block;
499
- float: none;
500
}
501
502
.column-lp_course .row-actions {
496
.rwmb-curriculum-wrapper .rwmb-input {
497
width: auto !important;
498
display: block;
499
}
500
501
.column-lp_course .row-actions {
inc/admin/views/meta-boxes/quiz/question.php CHANGED
@@ -27,7 +27,7 @@ if ( empty ( $question->id ) ) {
27
<p class="quiz-question-actions lp-button-actions">
28
<a href="" data-action="expand" class="dashicons dashicons-arrow-down <?php echo $is_hidden ? '' : 'hide-if-js'; ?>" title="<?php _e( 'Expand', 'learnpress' ); ?>"></a>
29
<a href="" data-action="collapse" class="dashicons dashicons-arrow-up <?php echo !$is_hidden ? '' : 'hide-if-js'; ?>" title="<?php _e( 'Collapse', 'learnpress' ); ?>"></a>
30
- <a href="<?php echo get_edit_post_link( $question->id ); ?>" class="dashicons dashicons-edit" data-action="" title="<?php _e( 'Edit', 'learnpress' ); ?>"></a>
31
<a href="" data-action="duplicate" class="dashicons-before dashicons-admin-page" title="<?php _e( 'Duplicate', 'learnpress' ); ?>" data-id="<?php echo esc_attr( $question->id ); ?>" data-quiz="<?php echo esc_attr( $post->ID ) ?>"></a>
32
<a href="<?php echo wp_nonce_url( admin_url( 'admin-ajax.php?action=learnpress_remove_quiz_question&quiz_id=' . $post->ID . '&question_id=' . $question->id ), 'remove_quiz_question', 'remove-nonce' ); ?>"
33
class="dashicons dashicons-trash"
27
<p class="quiz-question-actions lp-button-actions">
28
<a href="" data-action="expand" class="dashicons dashicons-arrow-down <?php echo $is_hidden ? '' : 'hide-if-js'; ?>" title="<?php _e( 'Expand', 'learnpress' ); ?>"></a>
29
<a href="" data-action="collapse" class="dashicons dashicons-arrow-up <?php echo !$is_hidden ? '' : 'hide-if-js'; ?>" title="<?php _e( 'Collapse', 'learnpress' ); ?>"></a>
30
+ <a href="<?php echo get_edit_post_link( $question->id ); ?>" class="dashicons dashicons-edit" data-action="" title="<?php _e( 'Edit', 'learnpress' ); ?>" target="_blank"></a>
31
<a href="" data-action="duplicate" class="dashicons-before dashicons-admin-page" title="<?php _e( 'Duplicate', 'learnpress' ); ?>" data-id="<?php echo esc_attr( $question->id ); ?>" data-quiz="<?php echo esc_attr( $post->ID ) ?>"></a>
32
<a href="<?php echo wp_nonce_url( admin_url( 'admin-ajax.php?action=learnpress_remove_quiz_question&quiz_id=' . $post->ID . '&question_id=' . $question->id ), 'remove_quiz_question', 'remove-nonce' ); ?>"
33
class="dashicons dashicons-trash"
inc/cart/class-lp-cart.php CHANGED
@@ -226,7 +226,7 @@ class LP_Cart {
226
$checkout_results = LP_Checkout::instance()->process_checkout();
227
}
228
$redirect = $checkout_results['redirect'];
229
- /*if ( is_ajax() ) {
230
learn_press_send_json(
231
$checkout_results
232
);
@@ -265,7 +265,7 @@ class LP_Cart {
265
266
$redirect = apply_filters( 'learn_press_add_to_cart_redirect', $redirect, $course_id );
267
268
- if ( is_ajax() ) {
269
learn_press_send_json(
270
array(
271
'redirect' => $redirect,
226
$checkout_results = LP_Checkout::instance()->process_checkout();
227
}
228
$redirect = $checkout_results['redirect'];
229
+ /*if ( learn_press_is_ajax() ) {
230
learn_press_send_json(
231
$checkout_results
232
);
265
266
$redirect = apply_filters( 'learn_press_add_to_cart_redirect', $redirect, $course_id );
267
268
+ if ( learn_press_is_ajax() ) {
269
learn_press_send_json(
270
array(
271
'redirect' => $redirect,
inc/class-lp-ajax.php CHANGED
@@ -116,7 +116,7 @@ if ( !class_exists( 'LP_AJAX' ) ) {
116
$message = apply_filters( 'learn_press_enroll_course_failed_message', sprintf( __( 'Sorry! The course <strong>%s</strong> you want to enroll has failed! Please contact site\'s administrator for more information.', 'learnpress' ), get_the_title( $course_id ) ), $course_id, LP()->user->id );
117
learn_press_add_message( $message, 'error' );
118
}
119
- if ( is_ajax() ) {
120
learn_press_send_json( $response );
121
}
122
@@ -238,7 +238,7 @@ if ( !class_exists( 'LP_AJAX' ) ) {
238
'result' => 'success',
239
'redirect' => learn_press_get_checkout_url()
240
);
241
- if ( is_ajax() ) {
242
learn_press_send_json( $return );
243
} else {
244
wp_redirect( $return['redirect'] );
116
$message = apply_filters( 'learn_press_enroll_course_failed_message', sprintf( __( 'Sorry! The course <strong>%s</strong> you want to enroll has failed! Please contact site\'s administrator for more information.', 'learnpress' ), get_the_title( $course_id ) ), $course_id, LP()->user->id );
117
learn_press_add_message( $message, 'error' );
118
}
119
+ if ( learn_press_is_ajax() ) {
120
learn_press_send_json( $response );
121
}
122
238
'result' => 'success',
239
'redirect' => learn_press_get_checkout_url()
240
);
241
+ if ( learn_press_is_ajax() ) {
242
learn_press_send_json( $return );
243
} else {
244
wp_redirect( $return['redirect'] );
inc/class-lp-checkout.php CHANGED
@@ -288,7 +288,7 @@ class LP_Checkout {
288
// Redirect to success/confirmation/payment page
289
if ( $success === true ) {
290
$result = apply_filters( 'learn_press_checkout_success_result', $result, $order_id );
291
- if ( is_ajax() ) {
292
learn_press_send_json( $result );
293
} else {
294
wp_redirect( $result['redirect'] );
288
// Redirect to success/confirmation/payment page
289
if ( $success === true ) {
290
$result = apply_filters( 'learn_press_checkout_success_result', $result, $order_id );
291
+ if ( learn_press_is_ajax() ) {
292
learn_press_send_json( $result );
293
} else {
294
wp_redirect( $result['redirect'] );
inc/course/lp-course-functions.php CHANGED
@@ -735,6 +735,10 @@ if ( !function_exists( 'learn_press_item_sample_permalink' ) ) {
735
736
function learn_press_item_sample_permalink( $permalink, $post_id, $title, $name, $post ){
737
738
$permalink = str_replace( '/' .$post->post_name, '/%pagename%' , $permalink );
739
return $permalink;
740
}
735
736
function learn_press_item_sample_permalink( $permalink, $post_id, $title, $name, $post ){
737
738
+ if ( $post->post_type !== LP_QUIZ_CPT && $post->post_type !== LP_LESSON_CPT) {
739
+ return $permalink;
740
+ }
741
+
742
$permalink = str_replace( '/' .$post->post_name, '/%pagename%' , $permalink );
743
return $permalink;
744
}
inc/custom-post-types/course.php CHANGED
@@ -327,7 +327,7 @@ if ( !class_exists( 'LP_Course_Post_Type' ) ) {
327
if ( empty( $post_id ) ) {
328
return;
329
}
330
- if ( self::$_enable_review ) {
331
if ( !empty( $_POST ) && learn_press_get_current_user()->is_instructor() && 'yes' == get_post_meta( $post_id, '_lp_submit_for_reviewer', true ) ) {
332
LP_Admin_Notice::add_redirect( __( 'Sorry! You can not update a course while it is viewing!', 'learnpress' ), 'error' );
333
wp_redirect( admin_url( 'post.php?post=' . $post_id . '&action=edit' ) );
@@ -667,7 +667,7 @@ if ( !class_exists( 'LP_Course_Post_Type' ) ) {
667
'name' => __( 'Course payment', 'learnpress' ),
668
'id' => "{$prefix}payment",
669
'type' => 'yes_no',
670
- 'desc' => __( 'If it is checked, An administrator will review then set course price and commission.', 'learnpress' ),
671
'std' => 'no',
672
'class' => 'lp-course-payment-field'
673
)
@@ -677,18 +677,24 @@ if ( !class_exists( 'LP_Course_Post_Type' ) ) {
677
$payment = get_post_meta( $course_id, '_lp_payment', true );
678
679
if ( current_user_can( 'manage_options' ) ) {
680
- $message = '';//__( 'If free, this field is empty or set 0. (Only admin can edit this field)', 'learnpress' );
681
- $price = get_post_meta( $course_id, '_lp_price', true );;
682
$sale_price = 0;
683
$start_date = '';
684
$end_date = '';
685
686
if ( isset( $_GET['post'] ) ) {
687
- $course_id = $_GET['post'];
688
if ( $payment != 'free' ) {
689
- $suggest_price = get_post_meta( $course_id, '_lp_suggestion_price', true );
690
- if ( isset( $suggest_price ) ) {
691
- //$message = sprintf( __( 'This course is requires enrollment and the suggested price is <strong>%s</strong>', 'learnpress' ), learn_press_format_price( $suggest_price, true ) );
692
$price = $suggest_price;
693
}
694
@@ -705,7 +711,7 @@ if ( !class_exists( 'LP_Course_Post_Type' ) ) {
705
'name' => __( 'Price', 'learnpress' ),
706
'id' => "{$prefix}price",
707
'type' => 'number',
708
- 'min' => 0,
709
'step' => 0.01,
710
'desc' => $message,
711
'std' => $price,
@@ -738,7 +744,14 @@ if ( !class_exists( 'LP_Course_Post_Type' ) ) {
738
)
739
);
740
} else {
741
-
742
$meta_box['fields'][] = array(
743
'name' => __( 'Course Suggestion Price', 'learnpress' ),
744
'id' => "{$prefix}suggestion_price",
@@ -749,14 +762,7 @@ if ( !class_exists( 'LP_Course_Post_Type' ) ) {
749
'class' => 'lp-course-price-field' . ( $payment != 'yes' ? ' hide-if-js' : '' ),
750
'std' => 0
751
);
752
- $price = get_post_meta( $course_id, '_lp_price', true );
753
- $meta_box['fields'][] = array(
754
- 'name' => __( 'Price set by Admin', 'learnpress' ),
755
- 'id' => "{$prefix}price",
756
- 'type' => 'html',
757
- 'class' => 'lp-course-price-field' . ( $payment != 'yes' ? ' hide-if-js' : '' ),
758
- 'html' => $price !== '' ? sprintf( '<strong>%s</strong>', learn_press_format_price( $price, true ) ) : __( 'Not set', 'learnpress' )
759
- );
760
}
761
$meta_box['fields'] = array_merge(
762
$meta_box['fields'],
@@ -1130,6 +1136,10 @@ if ( !class_exists( 'LP_Course_Post_Type' ) ) {
1130
delete_post_meta( $post->ID, '_lp_submit_for_reviewer', 'yes' );
1131
}
1132
} elseif ( $user->is_instructor() ) { // Course is submitted by instructor
1133
if ( ( $submit_for_review || ( $old_status != $new_status ) ) && $post->post_status != 'auto-draft' ) {
1134
$action = 'for_reviewer';
1135
update_post_meta( $post->ID, '_lp_submit_for_reviewer', 'yes' );
@@ -1220,16 +1230,17 @@ if ( !class_exists( 'LP_Course_Post_Type' ) ) {
1220
}
1221
1222
public
1223
- function before_save_curriculum() {
1224
1225
global $post, $pagenow;
1226
1227
// Ensure that we are editing course in admin side
1228
if ( ( $pagenow != 'post.php' ) || ( get_post_type() != LP_COURSE_CPT ) ) {
1229
return;
1230
}
1231
1232
- remove_action( 'save_post', array( $this, 'before_save_curriculum' ), 1000 );
1233
//remove_action( 'rwmb_course_curriculum_before_save_post', array( $this, 'before_save_curriculum' ) );
1234
1235
$user = LP()->user;
@@ -1244,6 +1255,7 @@ if ( !class_exists( 'LP_Course_Post_Type' ) ) {
1244
),
1245
array( '%d', '%s' )
1246
);
1247
}
1248
1249
$new_status = get_post_status( $post->ID );
327
if ( empty( $post_id ) ) {
328
return;
329
}
330
+ if ( self::$_enable_review ) {
331
if ( !empty( $_POST ) && learn_press_get_current_user()->is_instructor() && 'yes' == get_post_meta( $post_id, '_lp_submit_for_reviewer', true ) ) {
332
LP_Admin_Notice::add_redirect( __( 'Sorry! You can not update a course while it is viewing!', 'learnpress' ), 'error' );
333
wp_redirect( admin_url( 'post.php?post=' . $post_id . '&action=edit' ) );
667
'name' => __( 'Course payment', 'learnpress' ),
668
'id' => "{$prefix}payment",
669
'type' => 'yes_no',
670
+ 'desc' => __( '', 'learnpress' ),
671
'std' => 'no',
672
'class' => 'lp-course-payment-field'
673
)
677
$payment = get_post_meta( $course_id, '_lp_payment', true );
678
679
if ( current_user_can( 'manage_options' ) ) {
680
+ // $message = __( 'If free, this field is empty or set 0. (Only admin can edit this field)', 'learnpress' );
681
+ $message = '';
682
+ $price = get_post_meta( $course_id, '_lp_price', true );
683
$sale_price = 0;
684
$start_date = '';
685
$end_date = '';
686
687
if ( isset( $_GET['post'] ) ) {
688
+ $course_id = $_GET['post'];
689
+
690
if ( $payment != 'free' ) {
691
+ $suggest_price = get_post_meta( $course_id, '_lp_suggestion_price', true );
692
+ $course = get_post( $course_id );
693
+
694
+ $author = get_userdata( $course->post_author ) ;
695
+
696
+ if ( isset( $suggest_price ) && $author->roles[0] === 'lp_teacher' ) {
697
+ $message = sprintf( __( 'This course is requires enrollment and the suggested price is <strong>%s</strong>', 'learnpress' ), learn_press_format_price( $suggest_price, true ) );
698
$price = $suggest_price;
699
}
700
711
'name' => __( 'Price', 'learnpress' ),
712
'id' => "{$prefix}price",
713
'type' => 'number',
714
+ 'min' => 0.01,
715
'step' => 0.01,
716
'desc' => $message,
717
'std' => $price,
744
)
745
);
746
} else {
747
+ $price = get_post_meta( $course_id, '_lp_price', true );
748
+ $meta_box['fields'][] = array(
749
+ 'name' => __( 'Price set by Admin', 'learnpress' ),
750
+ 'id' => "{$prefix}price",
751
+ 'type' => 'html',
752
+ 'class' => 'lp-course-price-field' . ( $payment != 'yes' ? ' hide-if-js' : '' ),
753
+ 'html' => $price !== '' ? sprintf( '<strong>%s</strong>', learn_press_format_price( $price, true ) ) : __( 'Not set', 'learnpress' )
754
+ );
755
$meta_box['fields'][] = array(
756
'name' => __( 'Course Suggestion Price', 'learnpress' ),
757
'id' => "{$prefix}suggestion_price",
762
'class' => 'lp-course-price-field' . ( $payment != 'yes' ? ' hide-if-js' : '' ),
763
'std' => 0
764
);
765
+
766
}
767
$meta_box['fields'] = array_merge(
768
$meta_box['fields'],
1136
delete_post_meta( $post->ID, '_lp_submit_for_reviewer', 'yes' );
1137
}
1138
} elseif ( $user->is_instructor() ) { // Course is submitted by instructor
1139
+
1140
+ if ( $enable_edit_published && ( $old_status == $new_status && $new_status == 'publish' ) ) {
1141
+ $submit_for_review = false;
1142
+ }
1143
if ( ( $submit_for_review || ( $old_status != $new_status ) ) && $post->post_status != 'auto-draft' ) {
1144
$action = 'for_reviewer';
1145
update_post_meta( $post->ID, '_lp_submit_for_reviewer', 'yes' );
1230
}
1231
1232
public
1233
+ function before_save_curriculum() {
1234
1235
global $post, $pagenow;
1236
1237
// Ensure that we are editing course in admin side
1238
+
1239
if ( ( $pagenow != 'post.php' ) || ( get_post_type() != LP_COURSE_CPT ) ) {
1240
return;
1241
}
1242
1243
+ remove_action( 'save_post', array( $this, 'before_save_curriculum' ), 1 );
1244
//remove_action( 'rwmb_course_curriculum_before_save_post', array( $this, 'before_save_curriculum' ) );
1245
1246
$user = LP()->user;
1255
),
1256
array( '%d', '%s' )
1257
);
1258
+
1259
}
1260
1261
$new_status = get_post_status( $post->ID );
inc/custom-post-types/order.php CHANGED
@@ -506,14 +506,6 @@ if ( !class_exists( 'LP_Order_Post_Type' ) ) {
506
'show_in_admin_status_list' => true,
507
'label_count' => _n_noop( 'Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'learnpress' )
508
);
509
- $lp_order_statuses['lp-on-hold'] = array(
510
- 'label' => _x( 'On Hold', 'Order status', 'learnpress' ),
511
- 'public' => false,
512
- 'exclude_from_search' => false,
513
- 'show_in_admin_all_list' => true,
514
- 'show_in_admin_status_list' => true,
515
- 'label_count' => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'learnpress' )
516
- );
517
$lp_order_statuses['lp-cancelled'] = array(
518
'label' => _x( 'Cancelled', 'Order status', 'learnpress' ),
519
'public' => false,
@@ -522,22 +514,30 @@ if ( !class_exists( 'LP_Order_Post_Type' ) ) {
522
'show_in_admin_status_list' => true,
523
'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'learnpress' )
524
);
525
- $lp_order_statuses['lp-refunded'] = array(
526
- 'label' => _x( 'Refunded', 'Order status', 'learnpress' ),
527
- 'public' => false,
528
- 'exclude_from_search' => false,
529
- 'show_in_admin_all_list' => true,
530
- 'show_in_admin_status_list' => true,
531
- 'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'learnpress' )
532
- );
533
- $lp_order_statuses['lp-failed'] = array(
534
- 'label' => _x( 'Failed', 'Order status', 'learnpress' ),
535
- 'public' => false,
536
- 'exclude_from_search' => false,
537
- 'show_in_admin_all_list' => true,
538
- 'show_in_admin_status_list' => true,
539
- 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'learnpress' )
540
- );
541
foreach ( $lp_order_statuses as $status => $args ) {
542
register_post_status( $status, $args );
543
}
506
'show_in_admin_status_list' => true,
507
'label_count' => _n_noop( 'Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'learnpress' )
508
);
509
$lp_order_statuses['lp-cancelled'] = array(
510
'label' => _x( 'Cancelled', 'Order status', 'learnpress' ),
511
'public' => false,
514
'show_in_admin_status_list' => true,
515
'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'learnpress' )
516
);
517
+ // $lp_order_statuses['lp-on-hold'] = array(
518
+ // 'label' => _x( 'On Hold', 'Order status', 'learnpress' ),
519
+ // 'public' => false,
520
+ // 'exclude_from_search' => false,
521
+ // 'show_in_admin_all_list' => true,
522
+ // 'show_in_admin_status_list' => true,
523
+ // 'label_count' => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'learnpress' )
524
+ // );
525
+ // $lp_order_statuses['lp-refunded'] = array(
526
+ // 'label' => _x( 'Refunded', 'Order status', 'learnpress' ),
527
+ // 'public' => false,
528
+ // 'exclude_from_search' => false,
529
+ // 'show_in_admin_all_list' => true,
530
+ // 'show_in_admin_status_list' => true,
531
+ // 'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'learnpress' )
532
+ // );
533
+ // $lp_order_statuses['lp-failed'] = array(
534
+ // 'label' => _x( 'Failed', 'Order status', 'learnpress' ),
535
+ // 'public' => false,
536
+ // 'exclude_from_search' => false,
537
+ // 'show_in_admin_all_list' => true,
538
+ // 'show_in_admin_status_list' => true,
539
+ // 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'learnpress' )
540
+ // );
541
foreach ( $lp_order_statuses as $status => $args ) {
542
register_post_status( $status, $args );
543
}
inc/custom-post-types/quiz.php CHANGED
@@ -553,10 +553,6 @@ if ( !class_exists( 'LP_Quiz_Post_Type' ) ) {
553
554
public function get_sample_permalink_html( $return, $post_id , $new_title, $new_slug, $post ) {
555
556
- if ( $post->post_type == 'lp_quiz' ) {
557
- var_dump($return);
558
- }
559
-
560
return $return;
561
562
}
553
554
public function get_sample_permalink_html( $return, $post_id , $new_title, $new_slug, $post ) {
555
556
return $return;
557
558
}
inc/lp-constants.php CHANGED
@@ -4,7 +4,7 @@
4
*/
5
$upload_dir = wp_upload_dir();
6
// version
7
- define( 'LEARNPRESS_VERSION', '2.0.9.1' );
8
9
define( 'LP_WP_CONTENT', basename( WP_CONTENT_DIR ) );
10
4
*/
5
$upload_dir = wp_upload_dir();
6
// version
7
+ define( 'LEARNPRESS_VERSION', '2.1.0' );
8
9
define( 'LP_WP_CONTENT', basename( WP_CONTENT_DIR ) );
10
inc/lp-core-functions.php CHANGED
@@ -22,7 +22,7 @@ function learn_press_get_post() {
22
if ( empty( $post_id ) ) {
23
$post_id = learn_press_get_request( 'post_ID' );
24
}
25
- return absint($post_id);
26
}
27
28
/**
@@ -418,88 +418,88 @@ add_action( 'admin_footer', 'learn_press_print_script' );
418
/* Advertise in page admin */
419
if ( !function_exists( 'leanrpress_advertise_in_admin' ) ) {
420
421
- function leanrpress_advertise_in_admin() {
422
-
423
- $admin_post_type = array(
424
- 'lp_course',
425
- 'lp_lesson',
426
- 'lp_quiz',
427
- 'lp_question',
428
- 'lp_order'
429
- );
430
- $pages = array(
431
- 'learnpress_page_learn-press-statistics',
432
- 'learnpress_page_learn-press-settings',
433
- 'learnpress_page_learn-press-tools'
434
-
435
- );
436
- $themes_id = array(
437
- '14058034' => 'eduma',
438
- '17097658' => 'coach',
439
- '11797847' => 'lms'
440
- );
441
-
442
- $screen = get_current_screen();
443
444
if ( ( in_array( $screen->post_type, $admin_post_type ) && $screen->base === 'edit' )
445
|| ( in_array( $screen->id, $pages ) )
446
) {
447
448
- $current_theme = wp_get_theme();
449
-
450
- // Get items education
451
- $list_themes = learn_press_related_theme();
452
-
453
- foreach( $list_themes as $key => $theme ) {
454
-
455
- if ( !array_key_exists( $theme['id'], $themes_id ) || $themes_id[$theme['id']] === $current_theme->name ) {
456
- unset($list_themes[$key]);
457
- }
458
- }
459
- shuffle($list_themes);
460
- ?>
461
- <div id="learn-press-add-ons-wrap" class="learnpress-advertis-admin">
462
- <?php
463
- foreach ( $list_themes as $theme ) {
464
- $theme['url'] .= '?ref=ThimPress&utm_source=lp-backend&utm_medium=lp-addondashboard';
465
- $url_demo = $theme['attributes'][4]['value'] . '?ref=ThimPress&utm_source=lp-backend&utm_medium=lp-addondashboard';
466
-
467
- $theme['description'] = preg_replace( '/(?<=\S,)(?=\S)/', ' ', $theme['description'] );
468
- $theme['description'] = str_replace( "\n", ' ', $theme['description'] );
469
- $theme['description'] = explode(" ", $theme['description']);
470
- $theme['description'] = array_splice($theme['description'], 0, sizeof($theme['description']) - 1);
471
- $theme['description'] = implode(" ", $theme['description'])." ...";
472
- ?>
473
- <div id="thimpress-<?php echo esc_attr($theme['id']); ?>" class="item">
474
- <div class="theme-thumbnail">
475
- <a href="<?php echo esc_url($theme['url']); ?>">
476
- <img src="<?php echo esc_url($theme['previews']['landscape_preview']['landscape_url'])?>" />
477
- </a>
478
- </div>
479
-
480
- <div class="theme-detail">
481
- <h2><a href="<?php echo esc_url($theme['url']); ?>"><?php echo $theme['name']; ?></a></h2>
482
- <p class="learpress-description">
483
- <?php echo wp_kses_post($theme['description']); ?>
484
- </p>
485
- <p class="theme-controls">
486
- <a href="<?php echo esc_url($theme['url']); ?>" class="button button-primary" target="_blank"><?php _e( 'Get it now', 'learnpress' ); ?></a>
487
- <a href="<?php echo esc_url($url_demo); ?>" class="button" target="_blank"><?php _e( 'View Demo', 'learnpress' ); ?></a>
488
- </p>
489
- </div>
490
-
491
- </div>
492
- <?php
493
- }
494
- ?>
495
- </div>
496
- <?php
497
- }
498
-
499
- }
500
- }
501
-
502
- add_action( 'admin_footer', 'leanrpress_advertise_in_admin', -10 );
503
504
/**
505
* @param string $str
@@ -509,7 +509,7 @@ function learn_press_email_new_line( $lines = 1, $str = "\r\n" ) {
509
echo str_repeat( $str, $lines );
510
}
511
512
- if ( !function_exists( 'is_ajax' ) ) {
513
514
/**
515
* is_ajax - Returns true when the page is loaded via ajax.
@@ -517,7 +517,7 @@ if ( !function_exists( 'is_ajax' ) ) {
517
* @access public
518
* @return bool
519
*/
520
- function is_ajax() {
521
return defined( 'LP_DOING_AJAX' ) && LP_DOING_AJAX;
522
}
523
}
@@ -1495,10 +1495,7 @@ function learn_press_send_json( $data ) {
1495
@header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
1496
echo wp_json_encode( $data );
1497
echo '<!-- LP_AJAX_END -->';
1498
- if ( defined( 'LP_DOING_AJAX' ) && LP_DOING_AJAX )
1499
- wp_die();
1500
- else
1501
- die;
1502
}
1503
1504
/**
@@ -2652,7 +2649,7 @@ function learn_press_get_students_list_filter() {
2652
}
2653
2654
2655
- function learn_press_debug_hidden(){
2656
$args = func_get_args();
2657
echo '<div class="learn-press-debug-hidden" style="display:none;">';
2658
call_user_func_array( 'learn_press_debug', $args );
22
if ( empty( $post_id ) ) {
23
$post_id = learn_press_get_request( 'post_ID' );
24
}
25
+ return absint( $post_id );
26
}
27
28
/**
418
/* Advertise in page admin */
419
if ( !function_exists( 'leanrpress_advertise_in_admin' ) ) {
420
421
+ function leanrpress_advertise_in_admin() {
422
+
423
+ $admin_post_type = array(
424
+ 'lp_course',
425
+ 'lp_lesson',
426
+ 'lp_quiz',
427
+ 'lp_question',
428
+ 'lp_order'
429
+ );
430
+ $pages = array(
431
+ 'learnpress_page_learn-press-statistics',
432
+ 'learnpress_page_learn-press-settings',
433
+ 'learnpress_page_learn-press-tools'
434
+
435
+ );
436
+ $themes_id = array(
437
+ '14058034' => 'eduma',
438
+ '17097658' => 'coach',
439
+ '11797847' => 'lms'
440
+ );
441
+
442
+ $screen = get_current_screen();
443
444
if ( ( in_array( $screen->post_type, $admin_post_type ) && $screen->base === 'edit' )
445
|| ( in_array( $screen->id, $pages ) )
446
) {
447
448
+ $current_theme = wp_get_theme();
449
+
450
+ // Get items education
451
+ $list_themes = learn_press_related_theme();
452
+
453
+ foreach ( $list_themes as $key => $theme ) {
454
+
455
+ if ( !array_key_exists( $theme['id'], $themes_id ) || $themes_id[$theme['id']] === $current_theme->name ) {
456
+ unset( $list_themes[$key] );
457
+ }
458
+ }
459
+ shuffle( $list_themes );
460
+ ?>
461
+ <div id="learn-press-add-ons-wrap" class="learnpress-advertis-admin">
462
+ <?php
463
+ foreach ( $list_themes as $theme ) {
464
+ $theme['url'] .= '?ref=ThimPress&utm_source=lp-backend&utm_medium=lp-addondashboard';
465
+ $url_demo = $theme['attributes'][4]['value'] . '?ref=ThimPress&utm_source=lp-backend&utm_medium=lp-addondashboard';
466
+
467
+ $theme['description'] = preg_replace( '/(?<=\S,)(?=\S)/', ' ', $theme['description'] );
468
+ $theme['description'] = str_replace( "\n", ' ', $theme['description'] );
469
+ $theme['description'] = explode( " ", $theme['description'] );
470
+ $theme['description'] = array_splice( $theme['description'], 0, sizeof( $theme['description'] ) - 1 );
471
+ $theme['description'] = implode( " ", $theme['description'] ) . " ...";
472
+ ?>
473
+ <div id="thimpress-<?php echo esc_attr( $theme['id'] ); ?>" class="item">
474
+ <div class="theme-thumbnail">
475
+ <a href="<?php echo esc_url( $theme['url'] ); ?>">
476
+ <img src="<?php echo esc_url( $theme['previews']['landscape_preview']['landscape_url'] ) ?>" />
477
+ </a>
478
+ </div>
479
+
480
+ <div class="theme-detail">
481
+ <h2><a href="<?php echo esc_url( $theme['url'] ); ?>"><?php echo $theme['name']; ?></a></h2>
482
+ <p class="learpress-description">
483
+ <?php echo wp_kses_post( $theme['description'] ); ?>
484
+ </p>
485
+ <p class="theme-controls">
486
+ <a href="<?php echo esc_url( $theme['url'] ); ?>" class="button button-primary" target="_blank"><?php _e( 'Get it now', 'learnpress' ); ?></a>
487
+ <a href="<?php echo esc_url( $url_demo ); ?>" class="button" target="_blank"><?php _e( 'View Demo', 'learnpress' ); ?></a>
488
+ </p>
489
+ </div>
490
+
491
+ </div>
492
+ <?php
493
+ }
494
+ ?>
495
+ </div>
496
+ <?php
497
+ }
498
+
499
+ }
500
+ }
501
+
502
+ add_action( 'admin_footer', 'leanrpress_advertise_in_admin', - 10 );
503
504
/**
505
* @param string $str
509
echo str_repeat( $str, $lines );
510
}
511
512
+ if ( !function_exists( 'learn_press_is_ajax' ) ) {
513
514
/**
515
* is_ajax - Returns true when the page is loaded via ajax.
517
* @access public
518
* @return bool
519
*/
520
+ function learn_press_is_ajax() {
521
return defined( 'LP_DOING_AJAX' ) && LP_DOING_AJAX;
522
}
523
}
1495
@header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
1496
echo wp_json_encode( $data );
1497
echo '<!-- LP_AJAX_END -->';
1498
+ die;
1499
}
1500
1501
/**
2649
}
2650
2651
2652
+ function learn_press_debug_hidden() {
2653
$args = func_get_args();
2654
echo '<div class="learn-press-debug-hidden" style="display:none;">';
2655
call_user_func_array( 'learn_press_debug', $args );
inc/order/lp-order-functions.php CHANGED
@@ -655,11 +655,11 @@ function learn_press_get_order_statuses( $prefix = true ) {
655
$prefix . 'pending' => _x( 'Pending', 'Order status', 'learnpress' ),
656
$prefix . 'processing' => _x( 'Processing', 'Order status', 'learnpress' ),
657
$prefix . 'completed' => _x( 'Completed', 'Order status', 'learnpress' ),
658
- $prefix . 'on-hold' => _x( 'On Hold', 'Order status', 'learnpress' ),
659
- $prefix . 'refunded' => _x( 'Refunded', 'Order status', 'learnpress' ),
660
- $prefix . 'failed' => _x( 'Failed', 'Order status', 'learnpress' ),
661
$prefix . 'cancelled' => _x( 'Cancelled', 'Order status', 'learnpress' )
662
- );
663
664
return apply_filters( 'learn_press_order_statuses', $order_statuses );
665
}
@@ -668,12 +668,12 @@ function _learn_press_get_order_status_description( $status ) {
668
static $descriptions = null;
669
$descriptions = array(
670
'lp-pending' => __( 'Order received in case user buy a course but doesn\'t finalise the order.', 'learnpress' ),
671
- 'lp-failed' => __( 'Payment failed or was declined (unpaid).', 'learnpress' ),
672
'lp-processing' => __( 'Payment received and the order is awaiting fulfillment.', 'learnpress' ),
673
'lp-completed' => __( 'Order fulfilled and complete.', 'learnpress' ),
674
- 'lp-on-hold' => __( 'Awaiting payment.', 'learnpress' ),
675
- 'lp-cancelled' => __( 'The order is cancelled by an admin or the customer.', 'learnpress' ),
676
- 'lp-refunded' => __( 'Refunded is to indicate that the refund to the customer has been sent.', 'learnpress' )
677
);
678
return apply_filters( 'learn_press_order_status_description', !empty( $descriptions[$status] ) ? $descriptions[$status] : '' );
679
}
655
$prefix . 'pending' => _x( 'Pending', 'Order status', 'learnpress' ),
656
$prefix . 'processing' => _x( 'Processing', 'Order status', 'learnpress' ),
657
$prefix . 'completed' => _x( 'Completed', 'Order status', 'learnpress' ),
658
$prefix . 'cancelled' => _x( 'Cancelled', 'Order status', 'learnpress' )
659
+ // $prefix . 'refunded' => _x( 'Refunded', 'Order status', 'learnpress' ),
660
+ // $prefix . 'failed' => _x( 'Failed', 'Order status', 'learnpress' ),
661
+ // $prefix . 'on-hold' => _x( 'On Hold', 'Order status', 'learnpress' ),
662
+ );
663
664
return apply_filters( 'learn_press_order_statuses', $order_statuses );
665
}
668
static $descriptions = null;
669
$descriptions = array(
670
'lp-pending' => __( 'Order received in case user buy a course but doesn\'t finalise the order.', 'learnpress' ),
671
'lp-processing' => __( 'Payment received and the order is awaiting fulfillment.', 'learnpress' ),
672
'lp-completed' => __( 'Order fulfilled and complete.', 'learnpress' ),
673
+ 'lp-cancelled' => __( 'The order is cancelled by an admin or the customer.', 'learnpress' )
674
+ // 'lp-on-hold' => __( 'Awaiting payment.', 'learnpress' ),
675
+ // 'lp-failed' => __( 'Payment failed or was declined (unpaid).', 'learnpress' ),
676
+ // 'lp-refunded' => __( 'Refunded is to indicate that the refund to the customer has been sent.', 'learnpress' )
677
);
678
return apply_filters( 'learn_press_order_status_description', !empty( $descriptions[$status] ) ? $descriptions[$status] : '' );
679
}
inc/user/lp-user-functions.php CHANGED
@@ -925,7 +925,7 @@ function _learn_press_before_purchase_course_handler( $course_id, $cart ) {
925
if ( $redirect !== false ) {
926
learn_press_add_message( __( 'Please login to enroll this course', 'learnpress' ) );
927
928
- if ( is_ajax() ) {
929
learn_press_send_json(
930
array(
931
'redirect' => $redirect,
925
if ( $redirect !== false ) {
926
learn_press_add_message( __( 'Please login to enroll this course', 'learnpress' ) );
927
928
+ if ( learn_press_is_ajax() ) {
929
learn_press_send_json(
930
array(
931
'redirect' => $redirect,
learnpress.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: LearnPress
4
Plugin URI: http://thimpress.com/learnpress
5
Description: LearnPress is a WordPress complete solution for creating a Learning Management System (LMS). It can help you to create courses, lessons and quizzes.
6
Author: ThimPress
7
- Version: 2.0.9.1
8
Author URI: http://thimpress.com
9
Requires at least: 3.8
10
Tested up to: 4.7
4
Plugin URI: http://thimpress.com/learnpress
5
Description: LearnPress is a WordPress complete solution for creating a Learning Management System (LMS). It can help you to create courses, lessons and quizzes.
6
Author: ThimPress
7
+ Version: 2.1.0
8
Author URI: http://thimpress.com
9
Requires at least: 3.8
10
Tested up to: 4.7
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link:
4
Tags: WordPress LMS, LMS, eLearning, e-Learning, Learning Management System, LMS WordPress, Course, Courses, Quiz, Quizzes, Training, Guru, Sell Courses
5
Requires at least: 3.8
6
Tested up to: 4.7
7
- Stable tag: 2.0.9
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
@@ -193,8 +193,10 @@ https://www.transifex.com/projects/p/learnpress/
193
8. Add-ons of LearnPress.
194
195
== Changelog ==
196
- = 2.0.9.1 =
197
- + Fixed several bugs
198
199
= 2.0.9 =
200
+ Improved some sections in admin
4
Tags: WordPress LMS, LMS, eLearning, e-Learning, Learning Management System, LMS WordPress, Course, Courses, Quiz, Quizzes, Training, Guru, Sell Courses
5
Requires at least: 3.8
6
Tested up to: 4.7
7
+ Stable tag: 2.1.0
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
193
8. Add-ons of LearnPress.
194
195
== Changelog ==
196
+ = 2.1.0 =
197
+ + Fixed bugs related to AJAX calling
198
+ + Fixed bugs related to updating user profile
199
+ + Fixed open question to new tab in quiz editor
200
201
= 2.0.9 =
202
+ Improved some sections in admin