| Server IP : 172.67.147.195 / Your IP : 216.73.216.142 Web Server : Apache/2 System : Linux hosting8537.lvs 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 User : mienphi ( 1014) PHP Version : 8.2.14 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/mienphi/public_html/wp-content/plugins/learnpress/inc/Models/ |
Upload File : |
<?php
/**
* Class Lesson Post Model
*
* @package LearnPress/Classes
* @version 1.0.0
* @since 4.2.7.6
*/
namespace LearnPress\Models;
use LP_Cache;
use LP_Post_Type_Filter;
class LessonPostModel extends PostModel {
/**
* @var string Post Type
*/
public $post_type = LP_LESSON_CPT;
/**
* Const meta key
*/
const META_KEY_DURATION = '_lp_duration';
const META_KEY_PREVIEW = '_lp_preview';
/**
* Get post assignment by ID
*
* @param int $post_id
* @param bool $check_cache
*
* @return false|static
*/
public static function find( int $post_id, bool $check_cache = false ) {
$filter_post = new LP_Post_Type_Filter();
$filter_post->ID = $post_id;
$filter_post->post_type = LP_LESSON_CPT;
$key_cache = "lessonPostModel/find/{$post_id}";
$lpLessonCache = new LP_Cache();
// Check cache
if ( $check_cache ) {
$lessonPostModel = $lpLessonCache->get_cache( $key_cache );
if ( $lessonPostModel instanceof self ) {
return $lessonPostModel;
}
}
$lessonPostModel = self::get_item_model_from_db( $filter_post );
// Set cache
if ( $lessonPostModel instanceof LessonPostModel ) {
$lpLessonCache->set_cache( $key_cache, $lessonPostModel );
}
return $lessonPostModel;
}
/**
* Get duration lesson
*
* @return string
*/
public function get_duration(): string {
return $this->get_meta_value_by_key( self::META_KEY_DURATION, '0 minute' );
}
/**
* Check lesson enable preview
*
* @return bool
*/
public function has_preview(): bool {
return $this->get_meta_value_by_key( self::META_KEY_PREVIEW, 'no' ) === 'yes';
}
}