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'; } /** * Set lesson is preview or not * * @param bool $enable * * @return void * @throws Exception * @version 1.0.1 * @since 4.2.8.6 */ public function set_preview( bool $enable = true ) { $this->save_meta_value_by_key( LessonPostModel::META_KEY_PREVIEW, $enable ? 'yes' : 'no' ); } }