PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.1.6.9.3
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.1.6.9.3
4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 4.2.0 All 139 releases
learnpress / inc / course / class-lp-course-utils.php

class-lp-course-utils.php in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.1.6.9.3, at inc/course/class-lp-course-utils.php

108 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Class LP_Course_Utils
4 *
5 * @depecated 4.1.6.9
6 */
7 class LP_Course_Utils {
8
9 /**
10 * Get section data from cache.
11 *
12 * @param int $course_id
13 * @param string $return
14 *
15 * @return false|mixed
16 * @since 4.0.0
17 */
18 public static function get_cached_db_sections( $course_id, $return = '' ) {
19 if ( $return === 'ids' ) {
20 return LP_Object_Cache::get( $course_id, 'learn-press/course-sections-ids' );
21
22 }
23
24 return LP_Object_Cache::get( 'course-' . $course_id, 'learn-press/course-sections' );
25 }
26
27 /**
28 * Set section data to cache.
29 *
30 * @param $course_id
31 * @param $sections
32 *
33 * @return bool
34 * @since 4.0.0
35 */
36 public static function set_cache_db_sections( $course_id, $sections ) {
37 if ( ! $sections ) {
38 LP_Object_Cache::delete( $course_id, 'learn-press/course-sections' );
39 LP_Object_Cache::delete( $course_id, 'learn-press/course-sections-ids' );
40
41 return false;
42 }
43
44 LP_Object_Cache::set( 'course-' . $course_id, $sections, 'learn-press/course-sections' );
45 LP_Object_Cache::set( $course_id, wp_list_pluck( $sections, 'section_id' ), 'learn-press/course-sections-ids' );
46
47 return true;
48 }
49
50 public static function get_cached_section( $section_id ) {
51 return LP_Object_Cache::get( $section_id, 'learn-press/course-sections-objects' );
52 }
53
54 public static function set_cached_section( $section_id, $section_object ) {
55 if ( $section_object === false ) {
56 return LP_Object_Cache::delete( $section_id, 'learn-press/course-sections-objects' );
57 }
58 LP_Object_Cache::set( $section_id, $section_object, 'learn-press/course-sections-objects' );
59
60 return true;
61 }
62
63 /**
64 * Return ids of all items inside a course from cache.
65 *
66 * @param int $course_id
67 *
68 * @return false|mixed
69 */
70 public static function get_course_items( $course_id ) {
71 return LP_Object_Cache::get( $course_id, 'learn-press/course-item-ids' );
72 }
73
74 /**
75 * Set ids of all items read from db of a course to cache.
76 *
77 * @param int $course_id
78 * @param array $items
79 */
80 public static function set_course_items( $course_id, $items ) {
81 LP_Object_Cache::set( $course_id, $items, 'learn-press/course-item-ids' );
82 }
83
84 public static function set_course_item_types( $course_id, $items ) {
85 LP_Object_Cache::set( 'course-' . $course_id, $items, 'learn-press/course-item-types' );
86 }
87
88 public static function get_course_item_types( $course_id ) {
89 return LP_Object_Cache::get( 'course-' . $course_id, 'learn-press/course-item-types' );
90 }
91
92 public static function set_course_items_group_types( $course_id, $items ) {
93 LP_Object_Cache::set( 'course-' . $course_id, $items, 'learn-press/course-item-group-types' );
94 }
95
96 public static function get_course_items_group_types( $course_id ) {
97 return LP_Object_Cache::set( 'course-' . $course_id, 'learn-press/course-item-group-types' );
98 }
99
100 public static function set_section_items( $section_id, $items ) {
101 LP_Object_Cache::set( 'section-' . $section_id, $items, 'learn-press/section-items' );
102 }
103
104 public static function get_section_items( $section_id ) {
105 return LP_Object_Cache::set( 'section-' . $section_id, 'learn-press/section-items' );
106 }
107 }
108