Skip to content

Commit

Permalink
= 4.2.7.5 =
Browse files Browse the repository at this point in the history
~ Tweak: method get_meta_value_by_key on CourseModel class.
  • Loading branch information
tungnxt89 committed Dec 12, 2024
1 parent 528ee85 commit 45b2545
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 4 additions & 8 deletions inc/Models/CourseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -673,18 +673,14 @@ public function has_no_enroll_requirement(): bool {
*
* @return false|mixed
* @since 4.2.6.9
* @version 1.0.0
* @version 1.0.1
*/
public function get_meta_value_by_key( string $key, $default_value = false ) {
if ( ! empty( $this->meta_data ) && isset( $this->meta_data->{$key} ) ) {
$value = $this->meta_data->{$key};
if ( $this->meta_data instanceof stdClass && isset( $this->meta_data->{$key} ) ) {
$value = maybe_unserialize( $this->meta_data->{$key} );
} else {
$coursePost = new CoursePostModel( $this );
$value = $coursePost->get_meta_value_by_key( $key );
}

if ( empty( $value ) ) {
$value = $default_value;
$value = $coursePost->get_meta_value_by_key( $key, $default_value );
}

$this->meta_data->{$key} = $value;
Expand Down
6 changes: 5 additions & 1 deletion templates/single-course.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* @version 4.0.1
*/

use LearnPress\Models\CourseModel;

defined( 'ABSPATH' ) || exit;

/**
Expand Down Expand Up @@ -48,8 +50,10 @@
include $template_404;
}
} else {
$courseModel = CourseModel::find( $post->ID, true );

// hook from @since 4.2.7.5
do_action( 'learn-press/single-course/layout' );
do_action( 'learn-press/single-course/layout', $courseModel );

learn_press_get_template( 'content-single-course' );
}
Expand Down

0 comments on commit 45b2545

Please sign in to comment.