LearnPress – WordPress LMS Plugin - Version 4.1.6.5

Version Description

(2022-05-16) = ~ Fixed: error with block theme 2022. ~ Fixed: error with LP Addon Frontend Editor.

Download this release

Release Info

Developer ThimPress
Plugin Icon 128x128 LearnPress – WordPress LMS Plugin
Version 4.1.6.5
Comparing to
See all releases

Code changes from version 4.1.6.4 to 4.1.6.5

block-templates/page-lp_checkout.html ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <!-- wp:template-part {"slug":"header"} /-->
2
+ <!-- wp:group {"layout":{"inherit":true}} -->
3
+ <div class="wp-block-group"><!-- wp:learnpress/template {"template":"pages/checkout"} /--></div>
4
+ <!-- /wp:group -->
5
+ <!-- wp:template-part {"slug":"footer"} /-->
inc/admin/class-lp-admin-dashboard.php CHANGED
@@ -142,7 +142,6 @@ if ( ! class_exists( 'LP_Admin_Dashboard' ) ) {
142
  * @since 2.0
143
  */
144
  private function _get_data() {
145
-
146
  require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
147
  require_once ABSPATH . 'wp-admin/includes/plugin.php';
148
 
142
  * @since 2.0
143
  */
144
  private function _get_data() {
 
145
  require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
146
  require_once ABSPATH . 'wp-admin/includes/plugin.php';
147
 
inc/admin/class-lp-admin-tools.php DELETED
@@ -1,221 +0,0 @@
1
- <?php
2
- /**
3
- * Admin tools
4
- */
5
- if ( ! class_exists( 'LP_Admin_Tools' ) ) {
6
- /**
7
- * Class LP_Admin_Tools
8
- */
9
- class LP_Admin_Tools {
10
- /**
11
- * Entry point
12
- */
13
- public static function init() {
14
- $action = learn_press_get_request( 'action' );
15
-
16
- if ( ! $action ) {
17
- return;
18
- }
19
-
20
- if ( current_user_can( 'manage_options' ) ) {
21
- switch ( $action ) {
22
- case 'learn-press-remove-data':
23
- self::remove_data();
24
- break;
25
- case 'learn-press-remove-old-data':
26
- self::remove_old_data();
27
- break;
28
- default:
29
- break;
30
- }
31
- }
32
- }
33
-
34
- /**
35
- * Clean table data
36
- */
37
- /*public static function remove_data() {
38
- global $wpdb;
39
-
40
- $nonce = learn_press_get_request( 'remove-data-nonce' );
41
-
42
- if ( ! wp_verify_nonce( $nonce, 'learn-press-remove-data' ) ) {
43
- return;
44
- }
45
-
46
- $tables = array(
47
- 'learnpress_sections',
48
- 'learnpress_section_items',
49
- 'learnpress_review_logs',
50
- 'learnpress_quiz_questions',
51
- 'learnpress_question_answers',
52
- 'learnpress_user_courses',
53
- 'learnpress_user_lessons',
54
- 'learnpress_user_quizmeta',
55
- 'learnpress_user_quizzes',
56
- 'learnpress_order_itemmeta',
57
- 'learnpress_order_items',
58
- );
59
-
60
- foreach ( $tables as $table ) {
61
- $table = $wpdb->prefix . $table;
62
- if ( $wpdb->get_var( "SHOW TABLES LIKE '{$table}'" ) === $table ) {
63
- $wpdb->query( "DELETE FROM {$table}" );
64
- }
65
- }
66
-
67
- $query = "
68
- SELECT p.ID
69
- FROM {$wpdb->posts} p
70
- WHERE p.post_type IN ('lp_course', 'lp_lesson', 'lp_quiz', 'lp_question', 'lp_order', 'lp_cert')
71
- ";
72
-
73
- $ids = $wpdb->get_col( $query );
74
-
75
- // delete all custom post types and meta data.
76
- if ( ! empty( $ids ) ) {
77
- $q = $wpdb->prepare(
78
- "
79
- DELETE FROM p, pm
80
- USING {$wpdb->posts} AS p LEFT JOIN {$wpdb->postmeta} AS pm ON p.ID = pm.post_id AND p.post_type IN('lp_course', 'lp_lesson', 'lp_quiz', 'lp_question', 'lp_order', 'lp_cert')
81
- WHERE %d AND p.ID IN (" . join( ',', $ids ) . ');
82
- ',
83
- 1
84
- );
85
- $wpdb->query( $q );
86
-
87
- $wpdb->query(
88
- $wpdb->prepare(
89
- "
90
- DELETE FROM {$wpdb->postmeta} WHERE meta_key = %s
91
- ",
92
- '_learn_press_upgraded'
93
- )
94
- );
95
- }
96
-
97
- // 1 REMOVE term_relationships of posts
98
- $q = "
99
- DELETE FROM `tr`
100
- USING {$wpdb->term_relationships} AS `tr` INNER JOIN {$wpdb->term_taxonomy} AS `tt` ON `tr`.`term_taxonomy_id`=`tt`.`term_taxonomy_id`
101
- WHERE `tt`.`taxonomy` IN ('course_tag', 'course_category')
102
- ";
103
- $wpdb->query( $q );
104
-
105
- // 2 Remove categories and tags
106
- $q = "
107
- DELETE
108
- FROM tt, t
109
- USING {$wpdb->term_taxonomy} AS tt
110
- INNER JOIN
111
- {$wpdb->terms} AS t ON tt.term_id = t.term_id
112
- WHERE
113
- tt.taxonomy IN('course_category','course_tag')";
114
- $wpdb->query( $q );
115
-
116
- // END REMOVE TERMS
117
-
118
- // DELETE all options
119
- $q = $wpdb->prepare(
120
- "
121
- DELETE FROM {$wpdb->options}
122
- WHERE
123
- option_name LIKE %s
124
- OR option_name LIKE %s;
125
- ",
126
- '%' . $wpdb->esc_like( 'learn_press' ) . '%',
127
- '%' . $wpdb->esc_like( 'learnpress' ) . '%'
128
- );
129
- $wpdb->query( $q );
130
- delete_option( 'learnpress_db_version' );
131
- delete_option( 'learnpress_version' );
132
-
133
- LP_Admin_Notice::instance()->add( __( 'All courses, lessons, quizzes and questions have been removed', 'learnpress' ), 'updated', '', true );
134
-
135
- wp_redirect( admin_url( 'admin.php?page=learn-press-tools&learn-press-remove-data=1' ) );
136
- exit();
137
- }*/
138
-
139
- /*public static function remove_old_data() {
140
- $nonce = learn_press_get_request( 'remove-old-data-nonce' );
141
-
142
- if ( ! wp_verify_nonce( $nonce, 'learn-press-remove-old-data' ) ) {
143
- return;
144
- }
145
-
146
- global $wpdb;
147
-
148
- $query = $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_type IN ( %s, %s, %s, %s, %s, %s )", 'lpr_course', 'lpr_lesson', 'lpr_quiz', 'lpr_question', 'lpr_order', 'lpr_certificate' );
149
- $ids = $wpdb->get_col( $query );
150
-
151
- if ( $ids ) {
152
- $object_terms = array();
153
- foreach ( $ids as $post_id ) {
154
- $terms = wp_get_object_terms( $post_id, array( 'course_tag', 'course_category' ) );
155
-
156
- if ( $terms ) {
157
- foreach ( $terms as $term ) {
158
- $object_terms[ $term->term_id ] = $term->term_id;
159
- }
160
- }
161
- }
162
-
163
- $wpdb->query(
164
- $wpdb->prepare(
165
- "
166
- DELETE FROM p, pm
167
- USING {$wpdb->posts} AS p INNER JOIN {$wpdb->postmeta} AS pm ON p.ID = pm.post_id AND p.post_type IN('lpr_course', 'lpr_lesson', 'lpr_quiz', 'lpr_question', 'lpr_order', 'lpr_certificate')
168
- WHERE %d AND p.ID IN (" . join( ',', $ids ) . ')
169
- ',
170
- 1
171
- )
172
- );
173
-
174
- if ( $object_terms ) {
175
- $deleted_terms = array();
176
- if ( $object_terms ) {
177
- foreach ( $object_terms as $term_id => $taxonomy ) {
178
- wp_delete_term( $term_id, $taxonomy );
179
- $deleted_terms[ $term_id ] = $taxonomy;
180
- }
181
- }
182
- }
183
- }
184
-
185
- // delete all options
186
- $wpdb->query(
187
- $wpdb->prepare(
188
- "
189
- DELETE FROM {$wpdb->options}
190
- WHERE
191
- option_name LIKE %s
192
- OR option_name LIKE %s
193
- ",
194
- '%' . $wpdb->esc_like( '_lpr_' ) . '%',
195
- $wpdb->esc_like( 'lpr_' ) . '%'
196
- )
197
- );
198
-
199
- // delete all user meta
200
- $wpdb->query(
201
- $wpdb->prepare(
202
- "
203
- DELETE FROM {$wpdb->usermeta}
204
- WHERE
205
- meta_key LIKE %s
206
- OR meta_key LIKE %s
207
- ",
208
- '%' . $wpdb->esc_like( 'lpr_' ) . '%',
209
- $wpdb->esc_like( 'lpr_' ) . '%'
210
- )
211
- );
212
-
213
- LP_Admin_Notice::instance()->add( __( 'Outdated data from version older than 1.0 has been removed', 'learnpress' ), 'updated', '', true );
214
-
215
- wp_redirect( admin_url( 'admin.php?page=learn-press-tools' ) );
216
- exit();
217
- }*/
218
- }
219
- }
220
-
221
- add_action( 'admin_init', array( 'LP_Admin_Tools', 'init' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/block-template/class-block-controller.php CHANGED
@@ -20,10 +20,29 @@ class LP_Block_Template_Controller {
20
 
21
  public function __construct() {
22
  add_action( 'template_redirect', array( $this, 'render_block_template' ) );
 
23
  add_filter( 'get_block_templates', array( $this, 'add_block_templates' ), 10, 3 );
24
  add_action( 'enqueue_block_editor_assets', array( $this, 'block_editor' ) );
25
  add_action( 'init', array( $this, 'register_block_template_post_type' ) );
26
  add_filter( 'pre_get_block_file_template', array( $this, 'maybe_return_blocks_template' ), 10, 3 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  }
28
 
29
  public function block_editor() {
@@ -53,10 +72,7 @@ class LP_Block_Template_Controller {
53
  // 'get_block_template' was introduced in WP 5.9. We need to support
54
  // 'gutenberg_get_block_template' for previous versions of WP with
55
  // Gutenberg enabled.
56
- if (
57
- ! function_exists( 'gutenberg_get_block_template' ) &&
58
- ! function_exists( 'get_block_template' )
59
- ) {
60
  return $template;
61
  }
62
  $template_name_parts = explode( '//', $id );
@@ -129,7 +145,7 @@ class LP_Block_Template_Controller {
129
  * @return false|string
130
  */
131
  public function render_content_block_template( $attributes ) {
132
- $templates = array( 'archive-course', 'single-course', 'content-single-item' );
133
  $current_page = LP_Page_Controller::page_current();
134
 
135
  if ( in_array( $attributes['template'], $templates, true ) ) {
@@ -158,16 +174,29 @@ class LP_Block_Template_Controller {
158
  add_filter( 'learnpress_has_block_template', '__return_true', 10, 0 );
159
  } elseif ( ( is_post_type_archive( LP_COURSE_CPT ) || ( ! empty( learn_press_get_page_id( 'courses' ) ) && is_page( learn_press_get_page_id( 'courses' ) ) ) ) && ! LP_Block_Template_Utils::instance()->theme_has_template( 'archive-lp_course' ) && $this->block_template_is_available( 'archive-lp_course' ) ) {
160
  add_filter( 'learnpress_has_block_template', '__return_true', 10, 0 );
 
 
161
  }
162
  }
163
 
 
 
 
 
 
 
 
 
 
164
  public function add_block_templates( $query_result, $query, $template_type ) {
165
  if ( ! LP_Block_Template_Utils::instance()->supports_block_templates() ) {
166
  return $query_result;
167
  }
168
 
169
- $post_type = isset( $query['post_type'] ) ? $query['post_type'] : '';
170
- $slugs = isset( $query['slug__in'] ) ? $query['slug__in'] : array();
 
 
171
  $template_files = $this->get_block_templates( $slugs, $template_type );
172
 
173
  // @todo: Add apply_filters to _gutenberg_get_template_files() in Gutenberg to prevent duplication of logic.
@@ -201,8 +230,7 @@ class LP_Block_Template_Controller {
201
  if ( 'custom' !== $template_file->source ) {
202
  $template = LP_Block_Template_Utils::instance()->gutenberg_build_template_result_from_file( $template_file, $template_type );
203
  } else {
204
- $template_file->title = ! LP_Block_Template_Utils::instance()->convert_slug_to_title( $template_file->slug );
205
- $query_result[] = $template_file;
206
  continue;
207
  }
208
 
@@ -225,20 +253,43 @@ class LP_Block_Template_Controller {
225
  return $query_result;
226
  }
227
 
228
- public function get_block_templates( $slugs = array(), $template_type = 'wp_template' ) {
 
 
 
 
 
 
 
 
229
  static $templates = null;
230
 
231
  if ( ! is_null( $templates ) ) {
232
  return $templates;
233
  }
234
 
 
 
 
 
 
 
235
  $templates_from_db = $this->get_block_templates_from_db( $slugs, $template_type );
 
 
236
  $templates_from_lp = $this->get_block_templates_from_learnpress( $slugs, $templates_from_db, $template_type );
237
  $templates = array_merge( $templates_from_db, $templates_from_lp );
238
 
239
  return $templates;
240
  }
241
 
 
 
 
 
 
 
 
242
  public function get_block_templates_from_learnpress( $slugs, $already_found_templates, $template_type = 'wp_template' ) {
243
  global $wp;
244
 
@@ -261,15 +312,20 @@ class LP_Block_Template_Controller {
261
 
262
  $template_slug = $template_slug === 'content-single-lp_course-item' ? 'single-lp_course' : $template_slug;
263
 
264
- // This template does not have a slug we're looking for. Skip it.
265
- if ( is_array( $slugs ) && count( $slugs ) > 0 && ! in_array( $template_slug, $slugs, true ) ) {
 
 
 
 
 
 
266
  continue;
267
  }
268
 
269
  // If the theme already has a template, or the template is already in the list (i.e. it came from the
270
  // database) then we should not overwrite it with the one from the filesystem.
271
- if (
272
- LP_Block_Template_Utils::instance()->theme_has_template( $template_slug ) ||
273
  count(
274
  array_filter(
275
  $already_found_templates,
@@ -298,6 +354,9 @@ class LP_Block_Template_Controller {
298
 
299
  // At this point the template only exists in the Blocks filesystem and has not been saved in the DB,
300
  // or superseded by the theme.
 
 
 
301
  $templates[] = LP_Block_Template_Utils::instance()->create_new_block_template_object( $template_file, $template_type, $template_slug );
302
  }
303
 
20
 
21
  public function __construct() {
22
  add_action( 'template_redirect', array( $this, 'render_block_template' ) );
23
+ // Detected file block template html.
24
  add_filter( 'get_block_templates', array( $this, 'add_block_templates' ), 10, 3 );
25
  add_action( 'enqueue_block_editor_assets', array( $this, 'block_editor' ) );
26
  add_action( 'init', array( $this, 'register_block_template_post_type' ) );
27
  add_filter( 'pre_get_block_file_template', array( $this, 'maybe_return_blocks_template' ), 10, 3 );
28
+ add_filter( 'page_template_hierarchy', array( $this, 'page_template_hierarchy' ), 10, 3 );
29
+ }
30
+
31
+ /**
32
+ * Fixed error on the function 'resolve_block_template' when call usort()
33
+ *
34
+ * apply_filters( "{$type}_template_hierarchy", $templates )
35
+ *
36
+ * @param array $templates
37
+ *
38
+ * @return array|string[]
39
+ */
40
+ public function page_template_hierarchy( array $templates = array() ): array {
41
+ if ( LP_PAGE_CHECKOUT === LP_Page_Controller::page_current() ) {
42
+ $templates = array( 'page-lp_checkout' );
43
+ }
44
+
45
+ return $templates;
46
  }
47
 
48
  public function block_editor() {
72
  // 'get_block_template' was introduced in WP 5.9. We need to support
73
  // 'gutenberg_get_block_template' for previous versions of WP with
74
  // Gutenberg enabled.
75
+ if ( ! function_exists( 'gutenberg_get_block_template' ) && ! function_exists( 'get_block_template' ) ) {
 
 
 
76
  return $template;
77
  }
78
  $template_name_parts = explode( '//', $id );
145
  * @return false|string
146
  */
147
  public function render_content_block_template( $attributes ) {
148
+ $templates = array( 'archive-course', 'single-course', 'content-single-item', 'pages/checkout' );
149
  $current_page = LP_Page_Controller::page_current();
150
 
151
  if ( in_array( $attributes['template'], $templates, true ) ) {
174
  add_filter( 'learnpress_has_block_template', '__return_true', 10, 0 );
175
  } elseif ( ( is_post_type_archive( LP_COURSE_CPT ) || ( ! empty( learn_press_get_page_id( 'courses' ) ) && is_page( learn_press_get_page_id( 'courses' ) ) ) ) && ! LP_Block_Template_Utils::instance()->theme_has_template( 'archive-lp_course' ) && $this->block_template_is_available( 'archive-lp_course' ) ) {
176
  add_filter( 'learnpress_has_block_template', '__return_true', 10, 0 );
177
+ } elseif ( LP_PAGE_CHECKOUT === LP_Page_Controller::page_current() ) {
178
+ add_filter( 'learnpress_has_block_template', '__return_true', 10, 0 );
179
  }
180
  }
181
 
182
+ /**
183
+ * Detected if a block template is available
184
+ *
185
+ * @param $query_result
186
+ * @param $query
187
+ * @param $template_type
188
+ *
189
+ * @return array|mixed
190
+ */
191
  public function add_block_templates( $query_result, $query, $template_type ) {
192
  if ( ! LP_Block_Template_Utils::instance()->supports_block_templates() ) {
193
  return $query_result;
194
  }
195
 
196
+ $post_type = $query['post_type'] ?? '';
197
+ $slugs = $query['slug__in'] ?? array();
198
+
199
+ // Get file block template html.
200
  $template_files = $this->get_block_templates( $slugs, $template_type );
201
 
202
  // @todo: Add apply_filters to _gutenberg_get_template_files() in Gutenberg to prevent duplication of logic.
230
  if ( 'custom' !== $template_file->source ) {
231
  $template = LP_Block_Template_Utils::instance()->gutenberg_build_template_result_from_file( $template_file, $template_type );
232
  } else {
233
+ $query_result[] = $template_file;
 
234
  continue;
235
  }
236
 
253
  return $query_result;
254
  }
255
 
256
+ /**
257
+ * Get content block
258
+ *
259
+ * @param array $slugs
260
+ * @param string $template_type
261
+ *
262
+ * @return mixed
263
+ */
264
+ public function get_block_templates( array $slugs = array(), string $template_type = 'wp_template' ) {
265
  static $templates = null;
266
 
267
  if ( ! is_null( $templates ) ) {
268
  return $templates;
269
  }
270
 
271
+ // Fixed page Checkout
272
+ if ( LP_PAGE_CHECKOUT === LP_Page_Controller::page_current() ) {
273
+ $slugs[] = 'page-lp_checkout';
274
+ }
275
+
276
+ // Get content template form DB on table posts, with post_type = $template_type.
277
  $templates_from_db = $this->get_block_templates_from_db( $slugs, $template_type );
278
+
279
+ // Get content from file default.
280
  $templates_from_lp = $this->get_block_templates_from_learnpress( $slugs, $templates_from_db, $template_type );
281
  $templates = array_merge( $templates_from_db, $templates_from_lp );
282
 
283
  return $templates;
284
  }
285
 
286
+ /**
287
+ * @param array $slugs
288
+ * @param $already_found_templates
289
+ * @param string $template_type
290
+ *
291
+ * @return array
292
+ */
293
  public function get_block_templates_from_learnpress( $slugs, $already_found_templates, $template_type = 'wp_template' ) {
294
  global $wp;
295
 
312
 
313
  $template_slug = $template_slug === 'content-single-lp_course-item' ? 'single-lp_course' : $template_slug;
314
 
315
+ if ( LP_PAGE_CHECKOUT === LP_Page_Controller::page_current() ) {
316
+ if ( str_contains( $template_file, 'page-lp_checkout' ) ) {
317
+ $template_slug = $slugs[0];
318
+ $templates[] = LP_Block_Template_Utils::instance()->create_new_block_template_object( $template_file, $template_type, $template_slug );
319
+ continue;
320
+ }
321
+ } elseif ( is_array( $slugs ) && count( $slugs ) > 0 && ! in_array( $template_slug, $slugs, true ) ) {
322
+ // This template does not have a slug we're looking for. Skip it.
323
  continue;
324
  }
325
 
326
  // If the theme already has a template, or the template is already in the list (i.e. it came from the
327
  // database) then we should not overwrite it with the one from the filesystem.
328
+ if ( LP_Block_Template_Utils::instance()->theme_has_template( $template_slug ) ||
 
329
  count(
330
  array_filter(
331
  $already_found_templates,
354
 
355
  // At this point the template only exists in the Blocks filesystem and has not been saved in the DB,
356
  // or superseded by the theme.
357
+ /*if ( ! isset( $templates[ $template_slug ] ) ) {
358
+ $templates[ $template_slug ] = LP_Block_Template_Utils::instance()->create_new_block_template_object( $template_file, $template_type, $template_slug );
359
+ }*/
360
  $templates[] = LP_Block_Template_Utils::instance()->create_new_block_template_object( $template_file, $template_type, $template_slug );
361
  }
362
 
inc/cart/lp-cart-functions.php CHANGED
@@ -58,7 +58,7 @@ function learn_press_clear_cart_after_payment() {
58
 
59
  if ( ! empty( $wp->query_vars['lp-order-received'] ) ) {
60
  $order_id = absint( $wp->query_vars['lp-order-received'] );
61
- $order_key = isset( $_GET['key'] ) ? $_GET['key'] : '';
62
  $order = learn_press_get_order( $order_id );
63
 
64
  if ( $order_id > 0 && $order ) {
@@ -68,7 +68,7 @@ function learn_press_clear_cart_after_payment() {
68
  }
69
  }
70
 
71
- if ( LP()->session->order_awaiting_payment > 0 ) {
72
  $order = learn_press_get_order( LP()->session->order_awaiting_payment );
73
 
74
  if ( $order && $order->id > 0 ) {
58
 
59
  if ( ! empty( $wp->query_vars['lp-order-received'] ) ) {
60
  $order_id = absint( $wp->query_vars['lp-order-received'] );
61
+ $order_key = $_GET['key'] ?? '';
62
  $order = learn_press_get_order( $order_id );
63
 
64
  if ( $order_id > 0 && $order ) {
68
  }
69
  }
70
 
71
+ if ( ! is_null( LP()->session ) && LP()->session->order_awaiting_payment > 0 ) {
72
  $order = learn_press_get_order( LP()->session->order_awaiting_payment );
73
 
74
  if ( $order && $order->id > 0 ) {
inc/class-lp-checkout.php CHANGED
@@ -94,7 +94,9 @@ class LP_Checkout {
94
  add_filter( 'learn-press/validate-checkout-fields', array( $this, 'check_validate_fields' ), 10, 3 );
95
  //add_filter( 'learn-press/payment-successful-result', array( $this, 'process_customer' ), 10, 2 );
96
 
97
- $this->_checkout_email = LP()->session->get( 'checkout-email' );
 
 
98
  }
99
 
100
  /**
94
  add_filter( 'learn-press/validate-checkout-fields', array( $this, 'check_validate_fields' ), 10, 3 );
95
  //add_filter( 'learn-press/payment-successful-result', array( $this, 'process_customer' ), 10, 2 );
96
 
97
+ if ( ! is_null( LP()->session ) ) {
98
+ $this->_checkout_email = LP()->session->get( 'checkout-email' );
99
+ }
100
  }
101
 
102
  /**
inc/class-lp-debug.php CHANGED
@@ -104,11 +104,11 @@ class LP_Debug {
104
  /**
105
  * Show value of variable
106
  *
107
- * @param $variable
108
- * @param $file_path
109
- * @param $line
110
  */
111
- public static function var_dump( $variable, $file_path, $line ) {
112
  echo '<pre>' . print_r( $variable, true ) . '</pre>';
113
  echo 'FILE:' . esc_html( $file_path ) . '<br> LINE:' . esc_html( $line );
114
  }
104
  /**
105
  * Show value of variable
106
  *
107
+ * @param mixed $variable
108
+ * @param string $file_path
109
+ * @param string $line
110
  */
111
+ public static function var_dump( $variable, string $file_path = '', string $line = '' ) {
112
  echo '<pre>' . print_r( $variable, true ) . '</pre>';
113
  echo 'FILE:' . esc_html( $file_path ) . '<br> LINE:' . esc_html( $line );
114
  }
inc/class-lp-install.php CHANGED
@@ -70,8 +70,6 @@ if ( ! function_exists( 'LP_Install' ) ) {
70
  update_option( LP_KEY_DB_VERSION, LearnPress::instance()->db_version );
71
  }
72
 
73
- update_option( 'learnpress_version', LearnPress::instance()->version );
74
-
75
  // Create pages default.
76
  self::create_pages();
77
 
70
  update_option( LP_KEY_DB_VERSION, LearnPress::instance()->db_version );
71
  }
72
 
 
 
73
  // Create pages default.
74
  self::create_pages();
75
 
inc/class-lp-page-controller.php CHANGED
@@ -641,7 +641,7 @@ class LP_Page_Controller {
641
  }
642
  } elseif ( ( is_post_type_archive( LP_COURSE_CPT ) || ( ! empty( learn_press_get_page_id( 'courses' ) ) && is_page( learn_press_get_page_id( 'courses' ) ) ) ) && ! self::has_block_template( 'archive-course' ) ) {
643
  $page_template = 'archive-course.php';
644
- } elseif ( learn_press_is_checkout() ) {
645
  $page_template = 'pages/checkout.php';
646
  }
647
 
641
  }
642
  } elseif ( ( is_post_type_archive( LP_COURSE_CPT ) || ( ! empty( learn_press_get_page_id( 'courses' ) ) && is_page( learn_press_get_page_id( 'courses' ) ) ) ) && ! self::has_block_template( 'archive-course' ) ) {
643
  $page_template = 'archive-course.php';
644
+ } elseif ( learn_press_is_checkout() && ! self::has_block_template( 'page-lp_checkout' ) ) {
645
  $page_template = 'pages/checkout.php';
646
  }
647
 
inc/class-lp-rest-response.php DELETED
@@ -1,42 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Class LP_Asset_Key
5
- *
6
- * @author tungnx
7
- * @package LearnPress/Classes
8
- * @version 1.0
9
- * @since 3.2.8
10
- */
11
-
12
- if ( ! defined( 'ABSPATH' ) ) {
13
- exit; // Exit if accessed directly
14
- }
15
-
16
- class LP_REST_Response {
17
- /**
18
- * Status.
19
- *
20
- * @var string.
21
- */
22
- public $status = 'error';
23
- /**
24
- * Message.
25
- *
26
- * @var string .
27
- */
28
- public $message = '';
29
- /**
30
- * Extra data
31
- *
32
- * @var object
33
- */
34
- public $data;
35
-
36
- /**
37
- * LP_REST_Response constructor.
38
- */
39
- public function __construct() {
40
- $this->data = new stdClass();
41
- }
42
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/class-lp-settings.php CHANGED
@@ -30,7 +30,7 @@ class LP_Settings {
30
  /**
31
  * @var bool
32
  */
33
- protected static $_instance = false;
34
 
35
  /**
36
  * Constructor.
@@ -240,7 +240,7 @@ class LP_Settings {
240
  * @return bool|LP_Settings
241
  */
242
  public static function instance() {
243
- if ( empty( self::$_instance ) ) {
244
  self::$_instance = new self();
245
  }
246
 
@@ -345,7 +345,7 @@ class LP_Settings {
345
  );
346
 
347
  $endpoints = array();
348
- $settings = LP()->settings->get( 'checkout_endpoints' );
349
 
350
  if ( $settings ) {
351
  foreach ( $settings as $k => $v ) {
@@ -379,7 +379,7 @@ class LP_Settings {
379
  $defaults = array();
380
  $endpoints = array();
381
 
382
- $settings = LP()->settings->get( 'profile_endpoints' );
383
  if ( $settings ) {
384
  foreach ( $settings as $k => $v ) {
385
  $k = preg_replace( '!_!', '-', $k );
30
  /**
31
  * @var bool
32
  */
33
+ protected static $_instance = null;
34
 
35
  /**
36
  * Constructor.
240
  * @return bool|LP_Settings
241
  */
242
  public static function instance() {
243
+ if ( is_null( self::$_instance ) ) {
244
  self::$_instance = new self();
245
  }
246
 
345
  );
346
 
347
  $endpoints = array();
348
+ $settings = LP_Settings::instance()->get( 'checkout_endpoints' );
349
 
350
  if ( $settings ) {
351
  foreach ( $settings as $k => $v ) {
379
  $defaults = array();
380
  $endpoints = array();
381
 
382
+ $settings = LP_Settings::instance()->get( 'profile_endpoints' );
383
  if ( $settings ) {
384
  foreach ( $settings as $k => $v ) {
385
  $k = preg_replace( '!_!', '-', $k );
inc/curds/class-lp-course-curd.php CHANGED
@@ -244,11 +244,12 @@ if ( ! class_exists( 'LP_Course_CURD' ) ) {
244
  * @return array
245
  */
246
  public function read_course_items( $course_id, $publish_only = true, $section_ids = array() ) {
247
- static $results = null;
 
248
 
249
  if ( ! is_null( $results ) ) {
250
  return $results;
251
- }
252
 
253
  global $wpdb;
254
  $where = '';
244
  * @return array
245
  */
246
  public function read_course_items( $course_id, $publish_only = true, $section_ids = array() ) {
247
+ // Tungnx: Comment because make not work with WPML.
248
+ /*static $results = null;
249
 
250
  if ( ! is_null( $results ) ) {
251
  return $results;
252
+ }*/
253
 
254
  global $wpdb;
255
  $where = '';
inc/custom-post-types/abstract.php CHANGED
@@ -67,9 +67,11 @@ abstract class LP_Abstract_Post_Type {
67
  * @param string
68
  * @param mixed
69
  */
70
- public function __construct( $post_type, $args = '' ) {
71
 
72
- $this->_post_type = $post_type;
 
 
73
  add_action( 'init', array( $this, '_do_register' ) );
74
  add_action( 'save_post', array( $this, '_do_save_post' ), 10, 2 );
75
  add_action( 'before_delete_post', array( $this, '_before_delete_post' ) );
@@ -150,6 +152,8 @@ abstract class LP_Abstract_Post_Type {
150
 
151
  if ( $args ) {
152
  register_post_type( $this->_post_type, $args );
 
 
153
  }
154
  }
155
 
67
  * @param string
68
  * @param mixed
69
  */
70
+ public function __construct( $post_type = '', $args = '' ) {
71
 
72
+ if ( ! empty( $post_type ) ) {
73
+ $this->_post_type = $post_type;
74
+ }
75
  add_action( 'init', array( $this, '_do_register' ) );
76
  add_action( 'save_post', array( $this, '_do_save_post' ), 10, 2 );
77
  add_action( 'before_delete_post', array( $this, '_before_delete_post' ) );
152
 
153
  if ( $args ) {
154
  register_post_type( $this->_post_type, $args );
155
+
156
+ flush_rewrite_rules();
157
  }
158
  }
159
 
inc/custom-post-types/course.php CHANGED
@@ -30,8 +30,8 @@ if ( ! class_exists( 'LP_Course_Post_Type' ) ) {
30
  *
31
  * @param string
32
  */
33
- public function __construct( $post_type ) {
34
- parent::__construct( $post_type );
35
 
36
  add_action( 'init', array( $this, 'register_taxonomy' ) );
37
  add_filter( 'posts_where_paged', array( $this, '_posts_where_paged_course_items' ), 10 );
@@ -152,8 +152,7 @@ if ( ! class_exists( 'LP_Course_Post_Type' ) ) {
152
  * Register course taxonomy.
153
  */
154
  public function register_taxonomy() {
155
-
156
- $settings = LP()->settings;
157
 
158
  $category_base = $settings->get( 'course_category_base' );
159
 
@@ -683,7 +682,7 @@ if ( ! class_exists( 'LP_Course_Post_Type' ) ) {
683
  */
684
  public static function instance() {
685
  if ( ! self::$_instance ) {
686
- self::$_instance = new self( LP_COURSE_CPT );
687
  }
688
 
689
  return self::$_instance;
30
  *
31
  * @param string
32
  */
33
+ public function __construct() {
34
+ parent::__construct();
35
 
36
  add_action( 'init', array( $this, 'register_taxonomy' ) );
37
  add_filter( 'posts_where_paged', array( $this, '_posts_where_paged_course_items' ), 10 );
152
  * Register course taxonomy.
153
  */
154
  public function register_taxonomy() {
155
+ $settings = LP_Settings::instance();
 
156
 
157
  $category_base = $settings->get( 'course_category_base' );
158
 
682
  */
683
  public static function instance() {
684
  if ( ! self::$_instance ) {
685
+ self::$_instance = new self();
686
  }
687
 
688
  return self::$_instance;
inc/custom-post-types/lesson.php CHANGED
@@ -33,14 +33,14 @@ if ( ! class_exists( 'LP_Lesson_Post_Type' ) ) {
33
  *
34
  * @param $post_type
35
  */
36
- public function __construct( $post_type ) {
37
 
38
  // $this->add_map_method( 'before_delete', 'before_delete_lesson' );
39
  // hide View Lesson link if not assigned to course
40
 
41
  add_filter( 'views_edit-' . LP_LESSON_CPT, array( $this, 'views_pages' ), 10 );
42
 
43
- parent::__construct( $post_type );
44
  }
45
 
46
  /**
@@ -326,7 +326,7 @@ if ( ! class_exists( 'LP_Lesson_Post_Type' ) ) {
326
  */
327
  public static function instance() {
328
  if ( ! self::$_instance ) {
329
- self::$_instance = new self( LP_LESSON_CPT );
330
  }
331
 
332
  return self::$_instance;
33
  *
34
  * @param $post_type
35
  */
36
+ public function __construct() {
37
 
38
  // $this->add_map_method( 'before_delete', 'before_delete_lesson' );
39
  // hide View Lesson link if not assigned to course
40
 
41
  add_filter( 'views_edit-' . LP_LESSON_CPT, array( $this, 'views_pages' ), 10 );
42
 
43
+ parent::__construct();
44
  }
45
 
46
  /**
326
  */
327
  public static function instance() {
328
  if ( ! self::$_instance ) {
329
+ self::$_instance = new self();
330
  }
331
 
332
  return self::$_instance;
inc/custom-post-types/order.php CHANGED
@@ -25,7 +25,7 @@ if ( ! class_exists( 'LP_Order_Post_Type' ) ) {
25
  *
26
  * @param $post_type
27
  */
28
- public function __construct( $post_type ) {
29
  add_action( 'init', array( $this, 'register_post_statues' ) );
30
  add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) );
31
  add_action( 'admin_init', array( $this, 'remove_box' ) );
@@ -43,7 +43,7 @@ if ( ! class_exists( 'LP_Order_Post_Type' ) ) {
43
  add_filter( 'views_edit-lp_order', array( $this, 'filter_views' ) );
44
  // add_filter( 'posts_where_paged', array( $this, 'filter_orders' ) );
45
 
46
- parent::__construct( $post_type );
47
  }
48
 
49
  /**
@@ -890,7 +890,7 @@ if ( ! class_exists( 'LP_Order_Post_Type' ) ) {
890
 
891
  public static function instance() {
892
  if ( ! self::$_instance ) {
893
- self::$_instance = new self( LP_ORDER_CPT );
894
  }
895
 
896
  return self::$_instance;
25
  *
26
  * @param $post_type
27
  */
28
+ public function __construct() {
29
  add_action( 'init', array( $this, 'register_post_statues' ) );
30
  add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) );
31
  add_action( 'admin_init', array( $this, 'remove_box' ) );
43
  add_filter( 'views_edit-lp_order', array( $this, 'filter_views' ) );
44
  // add_filter( 'posts_where_paged', array( $this, 'filter_orders' ) );
45
 
46
+ parent::__construct();
47
  }
48
 
49
  /**
890
 
891
  public static function instance() {
892
  if ( ! self::$_instance ) {
893
+ self::$_instance = new self();
894
  }
895
 
896
  return self::$_instance;
inc/custom-post-types/question.php CHANGED
@@ -31,7 +31,7 @@ if ( ! class_exists( 'LP_Question_Post_Type' ) ) {
31
  * @param $post_type
32
  * @param mixed
33
  */
34
- public function __construct( $post_type, $args = '' ) {
35
  add_action( 'wp_loaded', array( $this, 'wp_loaded' ) );
36
  add_action( 'admin_head', array( $this, 'init' ) );
37
  add_action( 'learn-press/admin/after-enqueue-scripts', array( $this, 'data_question_editor' ) );
@@ -41,7 +41,7 @@ if ( ! class_exists( 'LP_Question_Post_Type' ) ) {
41
 
42
  // $this->add_map_method( 'before_delete', 'before_delete_question' );
43
 
44
- parent::__construct( $post_type, $args );
45
  }
46
 
47
  /**
@@ -517,7 +517,7 @@ if ( ! class_exists( 'LP_Question_Post_Type' ) ) {
517
  '_lp_type' => 'true_or_false',
518
  ),
519
  );*/
520
- self::$_instance = new self( LP_QUESTION_CPT );
521
  }
522
 
523
  return self::$_instance;
31
  * @param $post_type
32
  * @param mixed
33
  */
34
+ public function __construct() {
35
  add_action( 'wp_loaded', array( $this, 'wp_loaded' ) );
36
  add_action( 'admin_head', array( $this, 'init' ) );
37
  add_action( 'learn-press/admin/after-enqueue-scripts', array( $this, 'data_question_editor' ) );
41
 
42
  // $this->add_map_method( 'before_delete', 'before_delete_question' );
43
 
44
+ parent::__construct();
45
  }
46
 
47
  /**
517
  '_lp_type' => 'true_or_false',
518
  ),
519
  );*/
520
+ self::$_instance = new self();
521
  }
522
 
523
  return self::$_instance;
inc/custom-post-types/quiz.php CHANGED
@@ -37,7 +37,7 @@ if ( ! class_exists( 'LP_Quiz_Post_Type' ) ) {
37
  * @param $post_type
38
  * @param mixed
39
  */
40
- public function __construct( $post_type, $args = '' ) {
41
 
42
  //$this->add_map_method( 'before_delete', 'before_delete_quiz' );
43
 
@@ -46,7 +46,7 @@ if ( ! class_exists( 'LP_Quiz_Post_Type' ) ) {
46
  add_filter( 'views_edit-' . LP_QUIZ_CPT, array( $this, 'views_pages' ), 10 );
47
  add_filter( 'posts_where_paged', array( $this, 'posts_where_paged' ), 10 );
48
 
49
- parent::__construct( $post_type, $args );
50
  }
51
 
52
  /**
@@ -471,7 +471,7 @@ if ( ! class_exists( 'LP_Quiz_Post_Type' ) ) {
471
  */
472
  public static function instance() {
473
  if ( ! self::$_instance ) {
474
- self::$_instance = new self( LP_QUIZ_CPT, '' );
475
  }
476
 
477
  return self::$_instance;
37
  * @param $post_type
38
  * @param mixed
39
  */
40
+ public function __construct() {
41
 
42
  //$this->add_map_method( 'before_delete', 'before_delete_quiz' );
43
 
46
  add_filter( 'views_edit-' . LP_QUIZ_CPT, array( $this, 'views_pages' ), 10 );
47
  add_filter( 'posts_where_paged', array( $this, 'posts_where_paged' ), 10 );
48
 
49
+ parent::__construct();
50
  }
51
 
52
  /**
471
  */
472
  public static function instance() {
473
  if ( ! self::$_instance ) {
474
+ self::$_instance = new self();
475
  }
476
 
477
  return self::$_instance;
inc/gateways/paypal/class-lp-gateway-paypal.php CHANGED
@@ -287,77 +287,6 @@ if ( ! class_exists( 'LP_Gateway_Paypal' ) ) {
287
  }
288
  }
289
 
290
- /**
291
- * @editor tungnx
292
- * @modify 4.1.2
293
- * @reason comment - not user
294
- */
295
- // public function process_order_paypal_standard() {
296
- //
297
- // if ( ! empty( $_REQUEST['learn-press-transaction-method'] ) && ( 'paypal-standard' == $_REQUEST['learn-press-transaction-method'] ) ) {
298
- // // if we have a paypal-nonce in $_REQUEST that meaning user has clicked go back to our site after finished the transaction
299
- // // so, create a new order
300
- // if ( ! empty( $_REQUEST['paypal-nonce'] ) && wp_verify_nonce( $_REQUEST['paypal-nonce'], 'learn-press-paypal-nonce' ) ) {
301
- // if ( ! empty( $_REQUEST['tx'] ) ) {
302
- // $transaction_id = $_REQUEST['tx'];
303
- // } elseif ( ! empty( $_REQUEST['txn_id'] ) ) {
304
- // $transaction_id = $_REQUEST['txn_id'];
305
- // } else {
306
- // $transaction_id = null;
307
- // }
308
- //
309
- // if ( ! empty( $_REQUEST['cm'] ) ) {
310
- // $transient_transaction_id = $_REQUEST['cm'];
311
- // } elseif ( ! empty( $_REQUEST['custom'] ) ) {
312
- // $transient_transaction_id = $_REQUEST['custom'];
313
- // } else {
314
- // $transient_transaction_id = null;
315
- // }
316
- //
317
- // if ( ! empty( $_REQUEST['st'] ) ) {
318
- // $transaction_status = $_REQUEST['st'];
319
- // } elseif ( ! empty( $_REQUEST['payment_status'] ) ) {
320
- // $transaction_status = $_REQUEST['payment_status'];
321
- // } else {
322
- // $transaction_status = null;
323
- // }
324
- //
325
- // if ( ! empty( $transaction_id ) && ! empty( $transient_transaction_id ) && ! empty( $transaction_status ) ) {
326
- // $user = learn_press_get_current_user();
327
- //
328
- // try {
329
- // // If the transient still exists, delete it and add the official transaction
330
- // if ( $transaction_object = learn_press_get_transient_transaction( 'lpps', $transient_transaction_id ) ) {
331
- //
332
- // learn_press_delete_transient_transaction( 'lpps', $transient_transaction_id );
333
- // $order_id = $this->get_order_id( $transaction_id );
334
- // $order_id = learn_press_add_transaction(
335
- // array(
336
- // 'order_id' => $order_id,
337
- // 'method' => 'paypal-standard',
338
- // 'method_id' => $transaction_id,
339
- // 'status' => $transaction_status,
340
- // 'user_id' => $user->get_id(),
341
- // 'transaction_object' => $transaction_object['transaction_object'],
342
- // )
343
- // );
344
- //
345
- // wp_redirect( ( $confirm_page_id = learn_press_get_page_id( 'taken_course_confirm' ) ) && get_post( $confirm_page_id ) ? learn_press_get_order_confirm_url( $order_id ) : get_home_url() /* SITE_URL */ );
346
- // die();
347
- // }
348
- // } catch ( Exception $e ) {
349
- // return false;
350
- //
351
- // }
352
- // } elseif ( is_null( $transaction_id ) && is_null( $transient_transaction_id ) && is_null( $transaction_status ) ) {
353
- // }
354
- // }
355
- // }
356
- //
357
- // wp_redirect( get_home_url() );
358
- // die();
359
- // }
360
-
361
  /**
362
  * Handle a completed payment
363
  *
@@ -411,7 +340,8 @@ if ( ! class_exists( 'LP_Gateway_Paypal' ) ) {
411
 
412
  protected function prepare_line_items() {
413
  $this->line_items = array();
414
- if ( $items = LP()->get_cart()->get_items() ) {
 
415
  foreach ( $items as $item ) {
416
  $this->add_line_item( get_the_title( $item['item_id'] ), $item['quantity'], $item['total'] );
417
  }
287
  }
288
  }
289
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
290
  /**
291
  * Handle a completed payment
292
  *
340
 
341
  protected function prepare_line_items() {
342
  $this->line_items = array();
343
+ $items = LP()->get_cart()->get_items();
344
+ if ( $items ) {
345
  foreach ( $items as $item ) {
346
  $this->add_line_item( get_the_title( $item['item_id'] ), $item['quantity'], $item['total'] );
347
  }
inc/lp-core-functions.php CHANGED
@@ -1000,6 +1000,7 @@ add_action( 'transition_post_status', 'learn_press_publish_course', 10, 3 );
1000
  * @param $user_id
1001
  *
1002
  * @return WP_Query
 
1003
  */
1004
  function learn_press_get_enrolled_courses( $user_id ) {
1005
  return LP()->get_user( $user_id )->get( 'enrolled-courses' );
@@ -2054,23 +2055,26 @@ function learn_press_get_endpoint_url( $name, $value, $url ) {
2054
  * Add all endpoints from settings to the pages.
2055
  */
2056
  function learn_press_add_endpoints() {
2057
- $settings = LP()->settings();
2058
 
2059
- if ( $endpoints = $settings->get_checkout_endpoints() ) {
 
2060
  foreach ( $endpoints as $endpoint => $value ) {
2061
  LP()->query_vars[ $endpoint ] = $value;
2062
  add_rewrite_endpoint( $value, EP_PAGES );
2063
  }
2064
  }
2065
 
2066
- if ( $endpoints = $settings->get_profile_endpoints() ) {
 
2067
  foreach ( $endpoints as $endpoint => $value ) {
2068
  LP()->query_vars[ $endpoint ] = $value;
2069
  add_rewrite_endpoint( $value, EP_PAGES );
2070
  }
2071
  }
2072
 
2073
- if ( $endpoints = LP()->settings->get( 'quiz_endpoints' ) ) {
 
2074
  foreach ( $endpoints as $endpoint => $value ) {
2075
  $endpoint = preg_replace( '!_!', '-', $endpoint );
2076
  LP()->query_vars[ $endpoint ] = $value;
1000
  * @param $user_id
1001
  *
1002
  * @return WP_Query
1003
+ * @depecated 4.1.6.4
1004
  */
1005
  function learn_press_get_enrolled_courses( $user_id ) {
1006
  return LP()->get_user( $user_id )->get( 'enrolled-courses' );
2055
  * Add all endpoints from settings to the pages.
2056
  */
2057
  function learn_press_add_endpoints() {
2058
+ $settings = LP_Settings::instance();
2059
 
2060
+ $endpoints = $settings->get_checkout_endpoints();
2061
+ if ( $endpoints ) {
2062
  foreach ( $endpoints as $endpoint => $value ) {
2063
  LP()->query_vars[ $endpoint ] = $value;
2064
  add_rewrite_endpoint( $value, EP_PAGES );
2065
  }
2066
  }
2067
 
2068
+ $endpoints = $settings->get_profile_endpoints();
2069
+ if ( $endpoints ) {
2070
  foreach ( $endpoints as $endpoint => $value ) {
2071
  LP()->query_vars[ $endpoint ] = $value;
2072
  add_rewrite_endpoint( $value, EP_PAGES );
2073
  }
2074
  }
2075
 
2076
+ $endpoints = $settings->get( 'quiz_endpoints' );
2077
+ if ( $endpoints ) {
2078
  foreach ( $endpoints as $endpoint => $value ) {
2079
  $endpoint = preg_replace( '!_!', '-', $endpoint );
2080
  LP()->query_vars[ $endpoint ] = $value;
inc/lp-template-hooks.php CHANGED
@@ -504,6 +504,9 @@ add_action( 'learn-press/user-profile', LP()->template( 'profile' )->func( 'logi
504
  add_action( 'learn-press/user-profile', LP()->template( 'profile' )->func( 'register_form' ), 15 );
505
 
506
  /** BEGIN: Checkout page */
 
 
 
507
  add_action( 'learn-press/before-checkout-form', LP()->template( 'checkout' )->func( 'review_order' ), 10 );
508
  add_action( 'learn-press/after-checkout-form', LP()->template( 'checkout' )->func( 'account_logged_in' ), 20 );
509
  add_action( 'learn-press/after-checkout-form', LP()->template( 'checkout' )->func( 'account_register' ), 30 );
504
  add_action( 'learn-press/user-profile', LP()->template( 'profile' )->func( 'register_form' ), 15 );
505
 
506
  /** BEGIN: Checkout page */
507
+ /**
508
+ * @see LP_Template_Checkout::review_order()
509
+ */
510
  add_action( 'learn-press/before-checkout-form', LP()->template( 'checkout' )->func( 'review_order' ), 10 );
511
  add_action( 'learn-press/after-checkout-form', LP()->template( 'checkout' )->func( 'account_logged_in' ), 20 );
512
  add_action( 'learn-press/after-checkout-form', LP()->template( 'checkout' )->func( 'account_register' ), 30 );
inc/shortcodes/class-lp-shortcode-checkout.php CHANGED
@@ -42,7 +42,7 @@ if ( ! class_exists( 'LP_Shortcode_Checkout' ) ) {
42
  $checkout_cart = learn_press_get_checkout_cart();
43
 
44
  // Check cart has contents
45
- if ( $checkout_cart->is_empty() ) {
46
  learn_press_get_template( 'checkout/empty-cart.php' );
47
  } else {
48
  learn_press_get_template( 'checkout/form.php' );
42
  $checkout_cart = learn_press_get_checkout_cart();
43
 
44
  // Check cart has contents
45
+ if ( $checkout_cart && $checkout_cart->is_empty() ) {
46
  learn_press_get_template( 'checkout/empty-cart.php' );
47
  } else {
48
  learn_press_get_template( 'checkout/form.php' );
inc/templates/class-lp-template-checkout.php CHANGED
@@ -17,7 +17,8 @@ class LP_Template_Checkout extends LP_Abstract_Template {
17
  }
18
 
19
  public function review_order() {
20
- learn_press_get_template( 'checkout/review-order' );
 
21
  }
22
 
23
  public function payment() {
17
  }
18
 
19
  public function review_order() {
20
+ $cart = learn_press_get_checkout_cart();
21
+ learn_press_get_template( 'checkout/review-order', compact( 'cart' ) );
22
  }
23
 
24
  public function payment() {
inc/user/lp-user-functions.php CHANGED
@@ -113,7 +113,7 @@ if ( ! function_exists( 'learn_press_get_user' ) ) {
113
  */
114
  function learn_press_get_user( $user_id, $current = false, $force_new = false ) {
115
  $is_guest = false;
116
- if ( $user_id != LP()->session->guest_user_id ) {
117
  if ( $current && ! get_user_by( 'id', $user_id ) ) {
118
  $user_id = get_current_user_id();
119
  }
@@ -159,7 +159,7 @@ if ( ! function_exists( 'learn_press_get_user' ) ) {
159
  */
160
  function learn_press_add_user_roles() {
161
 
162
- $settings = LP()->settings;
163
 
164
  /* translators: user role */
165
  _x( 'LP Instructor', 'User role' );
113
  */
114
  function learn_press_get_user( $user_id, $current = false, $force_new = false ) {
115
  $is_guest = false;
116
+ if ( ! is_null( LP()->session ) && $user_id != LP()->session->guest_user_id ) {
117
  if ( $current && ! get_user_by( 'id', $user_id ) ) {
118
  $user_id = get_current_user_id();
119
  }
159
  */
160
  function learn_press_add_user_roles() {
161
 
162
+ $settings = LP_Settings::instance();
163
 
164
  /* translators: user role */
165
  _x( 'LP Instructor', 'User role' );
learnpress.php CHANGED
@@ -4,10 +4,10 @@
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: 4.1.6.4
8
  * Author URI: http://thimpress.com
9
  * Requires at least: 5.6
10
- * Tested up to: 5.9
11
  * Requires PHP: 7.0
12
  * Text Domain: learnpress
13
  * Domain Path: /languages/
@@ -142,6 +142,8 @@ if ( ! class_exists( 'LearnPress' ) ) {
142
  }
143
  self::$_instance = $this;
144
 
 
 
145
  // Define constant .
146
  $this->plugin_defines();
147
 
@@ -449,8 +451,9 @@ if ( ! class_exists( 'LearnPress' ) ) {
449
  // Add links setting|document|addon on plugins page.
450
  add_filter( 'plugin_action_links_' . LP_PLUGIN_BASENAME, array( $this, 'plugin_links' ) );
451
 
452
- add_action( 'activate_' . LP_PLUGIN_BASENAME, array( $this, 'on_activate' ) );
453
- add_action( 'deactivate_' . LP_PLUGIN_BASENAME, array( $this, 'on_deactivate' ) );
 
454
 
455
  if ( ! LP_Install::instance()->tables_install_done() ) {
456
  return;
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: 4.1.6.5
8
  * Author URI: http://thimpress.com
9
  * Requires at least: 5.6
10
+ * Tested up to: 6.0
11
  * Requires PHP: 7.0
12
  * Text Domain: learnpress
13
  * Domain Path: /languages/
142
  }
143
  self::$_instance = $this;
144
 
145
+ update_option( 'learnpress_version', $this->version );
146
+
147
  // Define constant .
148
  $this->plugin_defines();
149
 
451
  // Add links setting|document|addon on plugins page.
452
  add_filter( 'plugin_action_links_' . LP_PLUGIN_BASENAME, array( $this, 'plugin_links' ) );
453
 
454
+ register_activation_hook( LP_PLUGIN_FILE, array( $this, 'on_activate' ) );
455
+ register_deactivation_hook( LP_PLUGIN_FILE, array( $this, 'on_deactivate' ) );
456
+ // add_action( 'deactivate_' . LP_PLUGIN_BASENAME, array( $this, 'on_deactivate' ) );
457
 
458
  if ( ! LP_Install::instance()->tables_install_done() ) {
459
  return;
readme.txt CHANGED
@@ -3,9 +3,9 @@ Contributors: thimpress, tungnx89, nhamdv, hungkv, manhnl, tunnhn, phonglq.foobl
3
  Donate link:
4
  Tags: elearning, education, course, lms, learning management system
5
  Requires at least: 5.6
6
- Tested up to: 5.9
7
  Requires PHP: 7.0
8
- Stable tag: 4.1.6.4
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -203,6 +203,10 @@ https://www.transifex.com/projects/p/learnpress/
203
 
204
  == Changelog ==
205
 
 
 
 
 
206
  = 4.1.6.4 (2022-05-05) =
207
  ~ Modified: setup require tables for LearnPress when activate plugin.
208
  ~ Modified: setup wizard.
3
  Donate link:
4
  Tags: elearning, education, course, lms, learning management system
5
  Requires at least: 5.6
6
+ Tested up to: 6.0
7
  Requires PHP: 7.0
8
+ Stable tag: 4.1.6.5
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
203
 
204
  == Changelog ==
205
 
206
+ = 4.1.6.5 (2022-05-16) =
207
+ ~ Fixed: error with block theme 2022.
208
+ ~ Fixed: error with LP Addon Frontend Editor.
209
+
210
  = 4.1.6.4 (2022-05-05) =
211
  ~ Modified: setup require tables for LearnPress when activate plugin.
212
  ~ Modified: setup wizard.
templates/checkout/payment.php CHANGED
@@ -19,7 +19,7 @@ defined( 'ABSPATH' ) || exit();
19
  do_action( 'learn-press/before-payment-methods' );
20
 
21
  // Show payments if cart total > 0 and have at least one payment method.
22
- if ( LP()->cart->needs_payment() && $available_gateways ) {
23
  ?>
24
  <h4>
25
  <?php esc_html_e( 'Payment', 'learnpress' ); ?>
19
  do_action( 'learn-press/before-payment-methods' );
20
 
21
  // Show payments if cart total > 0 and have at least one payment method.
22
+ if ( LP()->cart && LP()->cart->needs_payment() && $available_gateways ) {
23
  ?>
24
  <h4>
25
  <?php esc_html_e( 'Payment', 'learnpress' ); ?>
templates/checkout/review-order.php CHANGED
@@ -6,12 +6,16 @@
6
  *
7
  * @author ThimPress
8
  * @package Learnpress/Templates
9
- * @version 4.0.0
10
  */
11
 
12
  defined( 'ABSPATH' ) || exit();
13
 
14
- $cart = learn_press_get_checkout_cart();
 
 
 
 
15
  ?>
16
 
17
  <div id="checkout-order" class="lp-checkout-block right">
6
  *
7
  * @author ThimPress
8
  * @package Learnpress/Templates
9
+ * @version 4.0.1
10
  */
11
 
12
  defined( 'ABSPATH' ) || exit();
13
 
14
+ // $cart = learn_press_get_checkout_cart();
15
+
16
+ if ( ! isset( $cart ) ) {
17
+ return;
18
+ }
19
  ?>
20
 
21
  <div id="checkout-order" class="lp-checkout-block right">
templates/pages/checkout.php CHANGED
@@ -9,7 +9,9 @@
9
 
10
  defined( 'ABSPATH' ) or die;
11
 
12
- get_header();
 
 
13
 
14
  do_action( 'learn-press/before-main-content' );
15
  do_action( 'learnpress/template/pages/checkout/before-content' );
@@ -44,4 +46,6 @@ do_action( 'learnpress/template/pages/checkout/before-content' );
44
  do_action( 'learnpress/template/pages/checkout/after-content' );
45
  do_action( 'learn-press/after-main-content' );
46
 
47
- get_footer();
 
 
9
 
10
  defined( 'ABSPATH' ) or die;
11
 
12
+ if ( empty( $is_block_theme ) ) {
13
+ get_header();
14
+ }
15
 
16
  do_action( 'learn-press/before-main-content' );
17
  do_action( 'learnpress/template/pages/checkout/before-content' );
46
  do_action( 'learnpress/template/pages/checkout/after-content' );
47
  do_action( 'learn-press/after-main-content' );
48
 
49
+ if ( empty( $is_block_theme ) ) {
50
+ get_footer();
51
+ }