LearnPress – WordPress LMS Plugin - Version 3.2.3

Version Description

~ Removed un-security code in PP library. ~ Fixed get curriculum item types doesn't work properly. ~ Fixed sort sections/items wrong in SQL query.

Download this release

Release Info

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

Code changes from version 3.2.2 to 3.2.3

inc/class-lp-schedules.php CHANGED
@@ -131,7 +131,8 @@ class LP_Schedules {
131
  return;
132
  }
133
  $this->_update_user_course_items_expired( $course, $user );
134
- $item_meta_id = $user->finish_course( $course->get_id(), true );
 
135
  if ( $item_meta_id ) {
136
  learn_press_update_user_item_meta( $item_meta_id, 'finishing_type', 'automation' );
137
  do_action( 'learn_press_user_finish_course_automation', $course->get_id(), $item_meta_id, $user->get_id() );
131
  return;
132
  }
133
  $this->_update_user_course_items_expired( $course, $user );
134
+ $user_course = $user->get_course_data( $course->get_id() );
135
+ $item_meta_id = $user_course->finish();
136
  if ( $item_meta_id ) {
137
  learn_press_update_user_item_meta( $item_meta_id, 'finishing_type', 'automation' );
138
  do_action( 'learn_press_user_finish_course_automation', $course->get_id(), $item_meta_id, $user->get_id() );
inc/course/abstract-course.php CHANGED
@@ -317,11 +317,12 @@ if ( ! function_exists( 'LP_Abstract_Course' ) ) {
317
 
318
  $key = $this->get_id() . '-' . md5( serialize( func_get_args() ) );
319
  if ( false === ( $items = LP_Object_Cache::get( 'course-' . $key, 'learn-press/course-items' ) ) ) {
320
-
321
  $items = array();
 
322
  foreach ( $type as $t ) {
323
- if ( $items_by_type = LP_Object_Cache::get( 'course-' . $this->get_id(), 'learn-press/course-' . $t ) ) {
324
- $items = array_merge( $items, $items_by_type );
325
  }
326
  }
327
 
@@ -329,7 +330,7 @@ if ( ! function_exists( 'LP_Abstract_Course' ) ) {
329
  $items = array_diff( $items, $preview_items );
330
  }
331
 
332
- LP_Object_Cache::set( 'course-' . $key, $items, 'learn-press/course-items' );
333
 
334
  }
335
  }
@@ -1795,7 +1796,7 @@ if ( ! function_exists( 'LP_Abstract_Course' ) ) {
1795
  INNER JOIN {$wpdb->learnpress_section_items} section_items ON course_sections.section_id = section_items.section_id
1796
  INNER JOIN {$wpdb->posts} item ON item.ID = section_items.item_id
1797
  WHERE course.ID = %d
1798
- ORDER BY course_sections.section_id, course_sections.section_order,section_items.section_item_id, section_items.item_order ASC
1799
  ", $id );
1800
 
1801
  $all_items = $wpdb->get_results( $query );
317
 
318
  $key = $this->get_id() . '-' . md5( serialize( func_get_args() ) );
319
  if ( false === ( $items = LP_Object_Cache::get( 'course-' . $key, 'learn-press/course-items' ) ) ) {
320
+
321
  $items = array();
322
+ $item_types = $this->get_item_types(true);
323
  foreach ( $type as $t ) {
324
+ if( isset($item_types[$t]) && !empty($item_types[$t]) ) {
325
+ $items = array_merge( $items, $item_types[$t] );
326
  }
327
  }
328
 
330
  $items = array_diff( $items, $preview_items );
331
  }
332
 
333
+ LP_Object_Cache::set( 'course-' . $key, $items, 'learn-press/course-items' );// this line not correct when $type != ''
334
 
335
  }
336
  }
1796
  INNER JOIN {$wpdb->learnpress_section_items} section_items ON course_sections.section_id = section_items.section_id
1797
  INNER JOIN {$wpdb->posts} item ON item.ID = section_items.item_id
1798
  WHERE course.ID = %d
1799
+ ORDER BY course_sections.section_order, course_sections.section_id, section_items.item_order,section_items.section_item_id ASC
1800
  ", $id );
1801
 
1802
  $all_items = $wpdb->get_results( $query );
inc/custom-post-types/order.php CHANGED
@@ -487,6 +487,17 @@ if ( ! class_exists( 'LP_Order_Post_Type' ) ) {
487
  global $wpdb, $wp_query;
488
 
489
  if ( ! $this->_is_archive() || ! $this->_is_search() ) {
 
 
 
 
 
 
 
 
 
 
 
490
  return $where;
491
  }
492
 
487
  global $wpdb, $wp_query;
488
 
489
  if ( ! $this->_is_archive() || ! $this->_is_search() ) {
490
+ if(is_admin() && !$wp_query->query['post_status']){
491
+ $statuses = array_keys(learn_press_get_register_order_statuses());
492
+ $search = "{$wpdb->posts}.post_status = 'publish' ";
493
+ $tmps = array($search);
494
+ $tmp = "{$wpdb->posts}.post_status = %s ";
495
+ foreach($statuses as $status ){
496
+ $tmps[]=$wpdb->prepare( $tmp, $status );
497
+ }
498
+ $replace = implode(' OR ',$tmps);
499
+ $where = str_replace($search, $replace, $where);
500
+ }
501
  return $where;
502
  }
503
 
inc/gateways/paypal/class-lp-gateway-paypal.php CHANGED
@@ -284,7 +284,9 @@ if ( ! class_exists( 'LP_Gateway_Paypal' ) ) {
284
  if ( ! isset( $_REQUEST['ipn'] ) ) {
285
  return;
286
  }
287
- require_once( 'paypal-ipn/ipn.php' );
 
 
288
  }
289
 
290
  public function process_order_paypal_standard() {
284
  if ( ! isset( $_REQUEST['ipn'] ) ) {
285
  return;
286
  }
287
+
288
+ // Not use
289
+ //require_once( 'paypal-ipn/ipn.php' );
290
  }
291
 
292
  public function process_order_paypal_standard() {
inc/gateways/paypal/paypal-ipn/ipn.php CHANGED
@@ -11,100 +11,77 @@
11
  * This code is available at github:
12
  * https://github.com/Quixotix/PHP-PayPal-IPN
13
  *
14
- * @package PHP-PayPal-IPN
15
- * @author Micah Carrick
16
- * @copyright (c) 2011 - Micah Carrick
17
- * @license http://opensource.org/licenses/gpl-3.0.html
18
  */
19
 
 
20
 
21
  /*
22
  Since this script is executed on the back end between the PayPal server and this
23
  script, you will want to log errors to a file or email. Do not try to use echo
24
- or print--it will not work!
 
25
  Here I am turning on PHP error logging to a file called "ipn_errors.log". Make
26
- sure your web server has permissions to write to that file. In a production
27
  environment it is better to have that log file outside of the web root.
28
  */
29
- ini_set( 'log_errors', true );
30
- ini_set( 'error_log', dirname( __FILE__ ) . '/ipn_errors.log' );
31
- // instantiate the IpnListener class
32
- ob_start();
33
- print_r( $_REQUEST );
34
- file_put_contents( 'ipn.txt', ob_get_clean() );
35
- die( );
36
- if ( isset( $_POST ) ) {
37
-
38
- return;
39
- $post_password = substr( 'lpr_order_' . $_POST['txn_id'], 0, 20 );
40
- $date = gmdate( 'Y-m-d H:i:s', ( strtotime( $_POST['payment_date'] ) + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ) );
41
- $purchased_items = array();
42
- $purchased_items[] = array(
43
- 'course_id' => $_POST['item_number'],
44
- 'cost' => $_POST['mc_gross']
45
- );
46
- $order_data = array(
47
- 'ID' => $order_id, //Order ID
48
- 'post_author' => $_POST['custom'], //Buyer ID
49
- 'post_date' => $date, //Course ID
50
- 'post_type' => LP_ORDER_CPT,
51
- 'post_password' => $post_password,
52
- 'post_title' => __( 'Order on ', 'learnpress' ) . ' ' . date( "l jS F Y h:i:s A", strtotime( $date ) )
53
- );
54
- $order_meta = array(
55
- 'lpr_cost' => $_POST['mc_gross'], //Total price
56
- 'lpr_methods' => 'paypal', //Payment methods
57
- 'lpr_items' => $purchased_items,
58
- 'lpr_status' => 0,
59
- 'lpr_courses' => $_POST['item_number'],
60
- 'lpr_information' => $_POST
61
- );
62
-
63
- learn_press_update_order( $order_data, $order_meta, $purchased_items );
64
 
65
- }
66
- include( 'ipnlistener.php' );
 
67
  $listener = new IpnListener();
 
 
68
  /*
69
  When you are testing your IPN script you should be using a PayPal "Sandbox"
70
  account: https://developer.paypal.com
71
  When you are ready to go live change use_sandbox to false.
72
  */
73
  $listener->use_sandbox = true;
 
74
  /*
75
  By default the IpnListener object is going going to post the data back to PayPal
76
  using cURL over a secure SSL connection. This is the recommended way to post
77
  the data back, however, some people may have connections problems using this
78
- method.
 
79
  To post over standard HTTP connection, use:
80
  $listener->use_ssl = false;
 
81
  To post using the fsockopen() function rather than cURL, use:
82
  $listener->use_curl = false;
83
  */
 
84
  /*
85
  The processIpn() method will encode the POST variables sent by PayPal and then
86
- POST them back to the PayPal server. An exception will be thrown if there is
87
  a fatal error (cannot connect, your server is not configured properly, etc.).
88
  Use a try/catch block to catch these fatal errors and log to the ipn_errors.log
89
  file we setup at the top of this file.
 
90
  The processIpn() method will send the raw data on 'php://input' to PayPal. You
91
  can optionally pass the data to processIpn() yourself:
92
  $verified = $listener->processIpn($my_post_data);
93
  */
94
-
95
  try {
96
  $listener->requirePostMethod();
97
  $verified = $listener->processIpn();
98
- } catch ( Exception $e ) {
99
- error_log( $e->getMessage() );
100
- exit( 0 );
101
  }
 
 
102
  /*
103
  The processIpn() method returned true if the IPN was "VERIFIED" and false if it
104
  was "INVALID".
105
  */
106
- if ( $verified ) {
107
- return;
108
  /*
109
  Once you have a verified IPN you need to do a few more checks on the POST
110
  fields--typically against data you stored in your database during when the
@@ -121,34 +98,15 @@ if ( $verified ) {
121
  example and just send an email using the getTextReport() method to get all
122
  of the details about the IPN.
123
  */
124
- if ( strtoupper( $_POST['payment_status'] ) == 'COMPLETED' ) {
125
- global $wpdb;
126
- $course_id = $_POST['item_number'];
127
- $params = get_option( '_lpr_general_settings', array() );
128
- $course_price = get_post_meta( $course_id, '_lpr_course_price', true );
129
- if ( $course_price == $_POST['mc_gross'] && $params['currency'] == $_POST['mc_currency'] ) {
130
- $user_id = $_POST['custom'];
131
- learn_press_update_user_course( $user_id, $course_id );
132
- }
133
- $purchased_items = array();
134
- $post_password = substr( 'lpr_order_' . $_POST['txn_id'], 0, 20 );
135
- $order_id = $wpdb->get_var(
136
- $wpdb->prepare(
137
- "SELECT ID FROM $wpdb->posts
138
- WHERE post_password=%s",
139
- $post_password
140
- )
141
- );
142
- if ( $order_id ) {
143
- learn_press_update_order_status( $order_id, 2 );
144
- }
145
- }
146
  } else {
147
  /*
148
  An Invalid IPN *may* be caused by a fraudulent transaction attempt. It's
149
  a good idea to have a developer or sys admin manually investigate any
150
  invalid IPN.
151
  */
152
-
153
  }
 
154
  ?>
11
  * This code is available at github:
12
  * https://github.com/Quixotix/PHP-PayPal-IPN
13
  *
14
+ * @package PHP-PayPal-IPN
15
+ * @author Micah Carrick
16
+ * @copyright (c) 2011 - Micah Carrick
17
+ * @license http://opensource.org/licenses/gpl-3.0.html
18
  */
19
 
20
+ defined('ABSPATH') or die();
21
 
22
  /*
23
  Since this script is executed on the back end between the PayPal server and this
24
  script, you will want to log errors to a file or email. Do not try to use echo
25
+ or print--it will not work!
26
+
27
  Here I am turning on PHP error logging to a file called "ipn_errors.log". Make
28
+ sure your web server has permissions to write to that file. In a production
29
  environment it is better to have that log file outside of the web root.
30
  */
31
+ ini_set('log_errors', true);
32
+ ini_set('error_log', dirname(__FILE__).'/ipn_errors.log');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
 
34
+
35
+ // instantiate the IpnListener class
36
+ include('ipnlistener.php');
37
  $listener = new IpnListener();
38
+
39
+
40
  /*
41
  When you are testing your IPN script you should be using a PayPal "Sandbox"
42
  account: https://developer.paypal.com
43
  When you are ready to go live change use_sandbox to false.
44
  */
45
  $listener->use_sandbox = true;
46
+
47
  /*
48
  By default the IpnListener object is going going to post the data back to PayPal
49
  using cURL over a secure SSL connection. This is the recommended way to post
50
  the data back, however, some people may have connections problems using this
51
+ method.
52
+
53
  To post over standard HTTP connection, use:
54
  $listener->use_ssl = false;
55
+
56
  To post using the fsockopen() function rather than cURL, use:
57
  $listener->use_curl = false;
58
  */
59
+
60
  /*
61
  The processIpn() method will encode the POST variables sent by PayPal and then
62
+ POST them back to the PayPal server. An exception will be thrown if there is
63
  a fatal error (cannot connect, your server is not configured properly, etc.).
64
  Use a try/catch block to catch these fatal errors and log to the ipn_errors.log
65
  file we setup at the top of this file.
66
+
67
  The processIpn() method will send the raw data on 'php://input' to PayPal. You
68
  can optionally pass the data to processIpn() yourself:
69
  $verified = $listener->processIpn($my_post_data);
70
  */
 
71
  try {
72
  $listener->requirePostMethod();
73
  $verified = $listener->processIpn();
74
+ } catch (Exception $e) {
75
+ error_log($e->getMessage());
76
+ exit(0);
77
  }
78
+
79
+
80
  /*
81
  The processIpn() method returned true if the IPN was "VERIFIED" and false if it
82
  was "INVALID".
83
  */
84
+ if ($verified) {
 
85
  /*
86
  Once you have a verified IPN you need to do a few more checks on the POST
87
  fields--typically against data you stored in your database during when the
98
  example and just send an email using the getTextReport() method to get all
99
  of the details about the IPN.
100
  */
101
+ mail('YOUR EMAIL ADDRESS', 'Verified IPN', $listener->getTextReport());
102
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  } else {
104
  /*
105
  An Invalid IPN *may* be caused by a fraudulent transaction attempt. It's
106
  a good idea to have a developer or sys admin manually investigate any
107
  invalid IPN.
108
  */
109
+ mail('YOUR EMAIL ADDRESS', 'Invalid IPN', $listener->getTextReport());
110
  }
111
+
112
  ?>
inc/lp-constants.php CHANGED
@@ -4,7 +4,7 @@
4
  */
5
  $upload_dir = wp_upload_dir();
6
  // version
7
- define( 'LEARNPRESS_VERSION', '3.2.2' );
8
 
9
  define( 'LP_WP_CONTENT', basename( WP_CONTENT_DIR ) );
10
 
4
  */
5
  $upload_dir = wp_upload_dir();
6
  // version
7
+ define( 'LEARNPRESS_VERSION', '3.2.3' );
8
 
9
  define( 'LP_WP_CONTENT', basename( WP_CONTENT_DIR ) );
10
 
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: 3.2.2
8
  Author URI: http://thimpress.com
9
  Requires at least: 3.8
10
  Tested up to: 5.0.2
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: 3.2.3
8
  Author URI: http://thimpress.com
9
  Requires at least: 3.8
10
  Tested up to: 5.0.2
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: thimpress, tunnhn, phonglq.foobla, thongta, kendy73, leehld
3
  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.9.5
7
- Stable tag: 3.2.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -199,6 +199,11 @@ https://www.transifex.com/projects/p/learnpress/
199
  8. Add-ons of LearnPress.
200
 
201
  == Changelog ==
 
 
 
 
 
202
  = 3.2.2 =
203
  ~ Fixed review quiz doesn't work properly.
204
  ~ Fixed table session create a lot of rows.
3
  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: 5.0.2
7
+ Stable tag: 3.2.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
199
  8. Add-ons of LearnPress.
200
 
201
  == Changelog ==
202
+ = 3.2.3 =
203
+ ~ Removed un-security code in PP library.
204
+ ~ Fixed get curriculum item types doesn't work properly.
205
+ ~ Fixed sort sections/items wrong in SQL query.
206
+
207
  = 3.2.2 =
208
  ~ Fixed review quiz doesn't work properly.
209
  ~ Fixed table session create a lot of rows.