PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.2.0
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.2.0
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 4.2.1 All 138 releases
learnpress / inc / admin / editor / class-lp-admin-editor.php

class-lp-admin-editor.php in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.2.0, at inc/admin/editor/class-lp-admin-editor.php

96 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Class LP_Admin_Editor
4 *
5 * @since 3.0.2
6 */
7 class LP_Admin_Editor {
8
9 /**
10 * @var array
11 */
12 protected static $editors = array();
13
14 /**
15 * @var bool
16 */
17 protected $result = false;
18
19 /**
20 * Get admin editor type
21 *
22 * @param string $type
23 *
24 * @return bool|mixed
25 */
26 public static function get( $type ) {
27 if ( empty( self::$editors[ $type ] ) ) {
28 $suffix = preg_replace( '~\s+~', '_', ucfirst( str_replace( '-', ' ', $type ) ) );
29 $class = "LP_Admin_Editor_{$suffix}";
30
31 if ( ! class_exists( $class ) ) {
32 $file = "class-lp-admin-editor-{$type}.php";
33 include_once $file;
34 }
35
36 if ( class_exists( $class ) ) {
37 self::$editors[ $type ] = new $class();
38 }
39 }
40
41 return ! empty( self::$editors[ $type ] ) ? self::$editors[ $type ] : false;
42 }
43
44 public function call( $type, $args = array() ) {
45 $func = str_replace( '-', '_', $type );
46 $callback = array( $this, $func );
47
48 if ( is_callable( $callback ) ) {
49 //LP_Hard_Cache::flush();
50
51 return call_user_func_array( $callback, $args );
52 }
53
54 return false;
55 }
56
57 public function heartbeat( $args = array() ) {
58 $this->result = true;
59 }
60
61 /**
62 * @return mixed|WP_Error
63 */
64 public function get_result() {
65 return $this->result;
66 }
67
68 /**
69 * @return bool|WP_Error
70 */
71 public function dispatch() {
72 return false;
73 }
74
75 /**
76 * @return LP_Admin_Editor_Course
77 */
78 public static function get_editor_course() {
79 return self::get( 'course' );
80 }
81
82 /**
83 * @return LP_Admin_Editor_Quiz
84 */
85 public static function get_editor_quiz() {
86 return self::get( 'quiz' );
87 }
88
89 /**
90 * @return LP_Admin_Editor_Question
91 */
92 public static function get_editor_question() {
93 return self::get( 'question' );
94 }
95 }
96