PluginProbe
Tutor LMS – eLearning and online course solution / 1.9.4
Tutor LMS – eLearning and online course solution v1.9.4
4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 4.0.0 3.9.15 3.9.14 3.9.13 3.9.12 3.9.11 trunk 1.0.0 1.0.0-alpha 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 All 191 releases
← All changes | classes/Addons.php +113 -314 3.9.151.9.4 View file →
@@ -1,351 +1,150 @@
1 1 <?php
2 2 /**
3 - * Manage Addons
3 + * Addons class
4 4 *
5 + * @author: themeum
6 + * @author_uri: https://themeum.com
5 7 * @package Tutor
6 - * @author Themeum <support@themeum.com>
7 - * @link https://themeum.com
8 - * @since 1.0.0
8 + * @since v.1.0.0
9 9 */
10 10
11 +
11 12 namespace TUTOR;
12 13
13 -if ( ! defined( 'ABSPATH' ) ) {
14 +if ( ! defined( 'ABSPATH' ) )
14 15 exit;
15 -}
16 -/**
17 - * Addons Class
18 - *
19 - * @since 1.0.0
20 - */
16 +
21 17 class Addons {
22 - const OPTION_KEY = 'tutor_addons_config';
23 18
24 - /**
25 - * Constructor
26 - *
27 - * @since 1.0.0
28 - * @return void
29 - */
30 19 public function __construct() {
31 - add_filter( 'tutor_pro_addons_lists_for_display', array( $this, 'addons_lists_to_show' ) );
32 - add_action( 'wp_ajax_tutor_get_all_addons', array( $this, 'get_all_addons' ) );
33 - add_action( 'wp_ajax_addon_enable_disable', array( $this, 'addon_enable_disable' ) );
20 + add_filter('tutor_pro_addons_lists_for_display', array($this, 'tutor_addons_lists_to_show'));
34 21 }
35 22
36 - /**
37 - * Obtain addons config list.
38 - *
39 - * @since 3.0.0
40 - *
41 - * @return array
42 - */
43 - public static function get_addons_config() {
44 - $list = get_option( self::OPTION_KEY, array() );
45 - return $list;
46 - }
47 -
48 - /**
49 - * Status update of tutor addon.
50 - *
51 - * @since 3.0.0
52 - *
53 - * @param string $basename basename of addon.
54 - * @param bool $status status 0,1.
55 - * @return void
56 - */
57 - public static function update_addon_status( $basename, $status ) {
58 - $config = self::get_addons_config();
59 - if ( isset( $config[ $basename ] ) ) {
60 - $config[ $basename ]['is_enable'] = $status;
61 - update_option( self::OPTION_KEY, $config );
62 - }
63 - }
64 -
65 - /**
66 - * Get all addons data.
67 - *
68 - * @since 1.0.0
69 - * @return void
70 - */
71 - public function get_all_addons() {
72 -
73 - // Check and verify the request.
74 - tutor_utils()->checking_nonce();
75 -
76 - if ( ! User::is_admin() ) {
77 - wp_send_json_error( tutor_utils()->error_message() );
78 - }
79 -
80 - // All good, let's proceed.
81 - $all_addons = $this->prepare_addons_data();
82 -
83 - wp_send_json_success(
84 - array(
85 - 'addons' => $all_addons,
86 - )
87 - );
88 - }
89 -
90 - /**
91 - * Prepare addons data.
92 - *
93 - * @since 1.0.0
94 - * @return array
95 - */
96 - public function prepare_addons_data() {
97 - $addons = apply_filters( 'tutor_addons_lists_config', array() );
98 - $plugins_data = $addons;
99 -
100 - if ( is_array( $addons ) && count( $addons ) ) {
101 - foreach ( $addons as $base_name => $addon ) {
102 - $addon_config = tutor_utils()->get_addon_config( $base_name );
103 - $is_enabled = (bool) tutor_utils()->avalue_dot( 'is_enable', $addon_config );
104 -
105 - $plugins_data[ $base_name ]['is_enabled'] = $is_enabled;
106 -
107 - $thumbnail_url = tutor()->url . 'assets/images/tutor-plugin.png';
108 - if ( file_exists( $addon['path'] . 'assets/images/thumbnail.png' ) ) {
109 - $thumbnail_url = $addon['url'] . 'assets/images/thumbnail.png';
110 - } elseif ( file_exists( $addon['path'] . 'assets/images/thumbnail.jpg' ) ) {
111 - $thumbnail_url = $addon['url'] . 'assets/images/thumbnail.jpg';
112 - } elseif ( file_exists( $addon['path'] . 'assets/images/thumbnail.svg' ) ) {
113 - $thumbnail_url = $addon['url'] . 'assets/images/thumbnail.svg';
114 - }
115 -
116 - $plugins_data[ $base_name ]['thumb_url'] = $thumbnail_url;
117 -
118 - /**
119 - * Checking if there any dependant plugin exists
120 - */
121 - $depends = tutor_utils()->array_get( 'depend_plugins', $addon );
122 - $plugins_required = array();
123 - if ( tutor_utils()->count( $depends ) ) {
124 - foreach ( $depends as $plugin_base => $plugin_name ) {
125 - if ( ! is_plugin_active( $plugin_base ) ) {
126 - $plugins_required[ $plugin_base ] = $plugin_name;
127 - }
128 - }
129 - }
130 -
131 - $depended_plugins = array();
132 - foreach ( $plugins_required as $required_plugin ) {
133 - array_push( $depended_plugins, $required_plugin );
134 - }
135 -
136 - $plugins_data[ $base_name ]['plugins_required'] = $depended_plugins;
137 -
138 - // Check if it's notifications.
139 - if ( function_exists( 'tutor_notifications' ) && tutor_notifications()->basename === $base_name ) {
140 -
141 - $required = array();
142 - version_compare( PHP_VERSION, '7.2.5', '>=' ) ? 0 : $required[] = __( 'PHP 7.2.5 or greater is required', 'tutor' );
143 - ! is_ssl() ? $required[] = __( 'SSL certificate', 'tutor' ) : 0;
144 -
145 - foreach ( array( 'curl', 'gmp', 'mbstring', 'openssl' ) as $ext ) {
146 - ! extension_loaded( $ext ) ? $required[] = 'PHP extension <strong>' . $ext . '</strong>' : 0;
147 - }
148 -
149 - $plugins_data[ $base_name ]['ext_required'] = $required;
150 - }
151 - }
152 - }
153 -
154 - /**
155 - * Keep same sorting order.
156 - *
157 - * @since 2.2.4
158 - */
159 - $free_addon_list = apply_filters( 'tutor_pro_addons_lists_for_display', array() );
160 - $prepared_addons = array();
161 -
162 - foreach ( $free_addon_list as $addon_name => $addon ) {
163 - $key = "tutor-pro/addons/{$addon_name}/{$addon_name}.php";
164 - if ( isset( $plugins_data[ $key ] ) ) {
165 - $prepared_addons[] = $plugins_data[ $key ];
166 - }
167 - }
168 -
169 - return $prepared_addons;
170 - }
171 -
172 - /**
173 - * Method for enable / disable addons
174 - *
175 - * @since 1.0.0
176 - * @return void
177 - */
178 - public function addon_enable_disable() {
179 -
180 - tutor_utils()->checking_nonce();
181 -
182 - if ( ! current_user_can( 'manage_options' ) ) {
183 - wp_send_json_error( array( 'message' => __( 'Access Denied', 'tutor' ) ) );
184 - }
185 -
186 - $form_data = json_decode( Input::post( 'addonFieldNames' ) );
187 - $before_config = self::get_addons_config();
188 - $addons_config = array();
189 -
190 - foreach ( $form_data as $addon_field_name => $is_enable ) {
191 -
192 - $before_status = ! isset( $before_config[ $addon_field_name ] ) ? 0 : $before_config[ $addon_field_name ]['is_enable'];
193 - $after_status = $is_enable ? 1 : 0;
194 -
195 - if ( $before_status !== $after_status ) {
196 - do_action( 'tutor_addon_before_enable_disable' );
197 - if ( $is_enable ) {
198 - do_action( "tutor_addon_before_enable_{$addon_field_name}" );
199 - do_action( 'tutor_addon_before_enable', $addon_field_name );
200 -
201 - $addons_config[ $addon_field_name ]['is_enable'] = 1;
202 - update_option( self::OPTION_KEY, $addons_config );
203 -
204 - do_action( 'tutor_addon_after_enable', $addon_field_name );
205 - do_action( "tutor_addon_after_enable_{$addon_field_name}" );
206 - } else {
207 - do_action( "tutor_addon_before_disable_{$addon_field_name}" );
208 - do_action( 'tutor_addon_before_disable', $addon_field_name );
209 -
210 - $addons_config[ $addon_field_name ]['is_enable'] = 0;
211 - update_option( self::OPTION_KEY, $addons_config );
212 -
213 - do_action( 'tutor_addon_after_disable', $addon_field_name );
214 - do_action( "tutor_addon_after_disable_{$addon_field_name}" );
215 - }
216 - do_action( 'tutor_addon_after_enable_disable' );
217 - } else {
218 - $addons_config[ $addon_field_name ]['is_enable'] = $after_status;
219 - update_option( self::OPTION_KEY, $addons_config );
220 - }
221 - }
222 -
223 - wp_send_json_success();
224 - }
225 -
226 - /**
227 - * Get tutor addons list
228 - *
229 - * @since 1.0.0
230 - * @return array
231 - */
232 - public function addons_lists_to_show() {
23 + public function tutor_addons_lists_to_show(){
233 24 $addons = array(
234 - 'course-bundle' => array(
235 - 'name' => __( 'Course Bundle', 'tutor' ),
236 - 'description' => __( 'Group multiple courses to sell together.', 'tutor' ),
25 + 'buddypress' => array(
26 + 'name' => __('BuddyPress', 'tutor'),
27 + 'description' => 'Discuss about course and share your knowledge with your friends through BuddyPress',
237 28 ),
238 - 'subscription' => array(
239 - 'name' => __( 'Subscription', 'tutor' ),
240 - 'description' => __( 'Manage subscription', 'tutor' ),
29 + 'gradebook' => array(
30 + 'name' => __('Gradebook', 'tutor'),
31 + 'description' => 'Shows student progress from assignment and quiz',
241 32 ),
242 - 'content-bank' => array(
243 - 'name' => __( 'Content Bank', 'tutor' ),
244 - 'description' => __( 'Create content once and use it across multiple courses.', 'tutor' ),
245 - 'is_new' => true,
33 + 'content-drip' => array(
34 + 'name' => __('Content Drip', 'tutor'),
35 + 'description' => 'Unlock lessons by schedule or when the student meets specific condition.',
246 36 ),
247 - 'social-login' => array(
248 - 'name' => __( 'Social Login', 'tutor' ),
249 - 'description' => __( 'Let users register & login through social networks.', 'tutor' ),
37 + 'enrollments' => array(
38 + 'name' => __('Enrollments', 'tutor'),
39 + 'description' => 'Take advanced control on enrollments. Enroll the student manually.',
250 40 ),
251 - 'content-drip' => array(
252 - 'name' => __( 'Content Drip', 'tutor' ),
253 - 'description' => __( 'Unlock lessons by schedule or when students meet a specific condition.', 'tutor' ),
41 + 'wc-subscriptions' => array(
42 + 'name' => __('WooCommerce Subscriptions', 'tutor'),
43 + 'description' => 'Capture Residual Revenue with Recurring Payments.',
254 44 ),
255 - 'tutor-multi-instructors' => array(
256 - 'name' => __( 'Tutor Multi Instructors', 'tutor' ),
257 - 'description' => __( 'Collaborate and add multiple instructors to a course.', 'tutor' ),
45 + 'pmpro' => array(
46 + 'name' => __('Paid Memberships Pro', 'tutor'),
47 + 'description' => 'Maximize revenue by selling membership access to all of your courses.',
258 48 ),
259 - 'tutor-assignments' => array(
260 - 'name' => __( 'Tutor Assignments', 'tutor' ),
261 - 'description' => __( 'Assess student learning with assignments.', 'tutor' ),
49 + 'restrict-content-pro' => array(
50 + 'name' => __('Restrict Content Pro', 'tutor'),
51 + 'description' => 'Unlock Course depending on Restrict Content Pro Plugin Permission.',
262 52 ),
263 - 'tutor-course-preview' => array(
264 - 'name' => __( 'Tutor Course Preview', 'tutor' ),
265 - 'description' => __( 'Offer free previews of specific lessons before enrollment.', 'tutor' ),
53 + 'tutor-assignments' => array(
54 + 'name' => __('Tutor Assignments', 'tutor'),
55 + 'description' => 'Tutor assignments is a great way to assign tasks to students.',
266 56 ),
57 + 'tutor-certificate' => array(
58 + 'name' => __('Tutor Certificate', 'tutor'),
59 + 'description' => 'Students will be able to download a certificate after course completion.',
60 + ),
267 61 'tutor-course-attachments' => array(
268 - 'name' => __( 'Tutor Course Attachments', 'tutor' ),
269 - 'description' => __( 'Add unlimited attachments/ private files to any Tutor course', 'tutor' ),
62 + 'name' => __('Tutor Course Attachments', 'tutor'),
63 + 'description' => 'Add unlimited attachments/ private files to any Tutor course',
270 64 ),
271 - 'google-meet' => array(
272 - 'name' => __( 'Tutor Google Meet Integration', 'tutor' ),
273 - 'description' => __( 'Host live classes with Google Meet, directly from your lesson page.', 'tutor' ),
65 + 'tutor-course-preview' => array(
66 + 'name' => __('Tutor Course Preview', 'tutor'),
67 + 'description' => 'Unlock some lessons for students before enrollment.',
274 68 ),
275 - 'tutor-report' => array(
276 - 'name' => __( 'Tutor Report', 'tutor' ),
277 - 'description' => __( 'Check your course performance through Tutor Report stats.', 'tutor' ),
69 + 'tutor-email' => array(
70 + 'name' => __('Tutor E-Mail', 'tutor'),
71 + 'description' => 'Send email on various tutor events',
278 72 ),
279 - 'tutor-email' => array(
280 - 'name' => __( 'Email', 'tutor' ),
281 - 'description' => __( 'Send automated and customized emails for various Tutor events.', 'tutor' ),
73 + 'tutor-multi-instructors' => array(
74 + 'name' => __('Tutor Multi Instructors', 'tutor'),
75 + 'description' => 'Start a course with multiple instructors by Tutor Multi Instructors',
282 76 ),
283 - 'calendar' => array(
284 - 'name' => __( 'Calendar', 'tutor' ),
285 - 'description' => __( 'Enable to let students view all your course events in one place.', 'tutor' ),
77 + 'tutor-prerequisites' => array(
78 + 'name' => __('Tutor Prerequisites', 'tutor'),
79 + 'description' => 'Specific course you must complete before you can enroll new course by Tutor Prerequisites',
286 80 ),
287 - 'tutor-notifications' => array(
288 - 'name' => __( 'Notifications', 'tutor' ),
289 - 'description' => __( 'Keep students and instructors notified of course events on their dashboard.', 'tutor' ),
81 + 'tutor-report' => array(
82 + 'name' => __('Tutor Report', 'tutor'),
83 + 'description' => 'Check your course performance through Tutor Report stats.',
290 84 ),
291 - 'google-classroom' => array(
292 - 'name' => __( 'Google Classroom Integration', 'tutor' ),
293 - 'description' => __( 'Enable to integrate Tutor LMS with Google Classroom.', 'tutor' ),
85 + 'quiz-import-export' => array(
86 + 'name' => __('Quiz Export/Import', 'tutor'),
87 + 'description' => __('Save time by exporting/importing quiz data with easy options.', 'tutor'),
294 88 ),
295 - 'tutor-zoom' => array(
296 - 'name' => __( 'Tutor Zoom Integration', 'tutor' ),
297 - 'description' => __( 'Connect Tutor LMS with Zoom to host live online classes.', 'tutor' ),
89 + 'tutor-zoom' => array(
90 + 'name' => __('Tutor Zoom Integration', 'tutor'),
91 + 'description' => __('Connect Tutor LMS with Zoom to host live online classes. Students can attend live classes right from the lesson page.', 'tutor'),
298 92 ),
299 - 'quiz-import-export' => array(
300 - 'name' => __( 'Quiz Export/Import', 'tutor' ),
301 - 'description' => __( 'Save time by exporting/importing quiz data with easy options.', 'tutor' ),
93 + 'google-classroom' => array(
94 + 'name' => __('Google Classroom Integration', 'tutor'),
95 + 'description' => __('Helps connect Google Classrooms with Tutor LMS courses, allowing you to use features like Classroom streams and files directly from the Tutor LMS course.', 'tutor'),
302 96 ),
303 - 'enrollments' => array(
304 - 'name' => __( 'Enrollment', 'tutor' ),
305 - 'description' => __( 'Enable to manually enroll students in your courses.', 'tutor' ),
306 - ),
307 - 'tutor-certificate' => array(
308 - 'name' => __( 'Tutor Certificate', 'tutor' ),
309 - 'description' => __( 'Enable to award certificates upon course completion.', 'tutor' ),
310 - ),
311 - 'gradebook' => array(
312 - 'name' => __( 'Gradebook', 'tutor' ),
313 - 'description' => __( 'Track student progress with a centralized gradebook.', 'tutor' ),
314 - ),
315 - 'tutor-prerequisites' => array(
316 - 'name' => __( 'Tutor Prerequisites', 'tutor' ),
317 - 'description' => __( 'Set course prerequisites to guide learning paths effectively.', 'tutor' ),
318 - ),
319 - 'buddypress' => array(
320 - 'name' => __( 'BuddyPress', 'tutor' ),
321 - 'description' => __( 'Boost engagement with social features through BuddyPress for Tutor LMS.', 'tutor' ),
322 - ),
323 - 'wc-subscriptions' => array(
324 - 'name' => __( 'WooCommerce Subscriptions', 'tutor' ),
325 - 'description' => __( 'Capture Residual Revenue with Recurring Payments.', 'tutor' ),
326 - ),
327 - 'pmpro' => array(
328 - 'name' => __( 'Paid Memberships Pro', 'tutor' ),
329 - 'description' => __( 'Boost revenue by selling course memberships.', 'tutor' ),
330 - ),
331 - 'restrict-content-pro' => array(
332 - 'name' => __( 'Restrict Content Pro', 'tutor' ),
333 - 'description' => __( 'Enable to manage content access through Restrict Content Pro. ', 'tutor' ),
334 - ),
335 - 'tutor-weglot' => array(
336 - 'name' => __( 'Weglot', 'tutor' ),
337 - 'description' => __( 'Translate & manage multilingual courses for global reach.', 'tutor' ),
338 - ),
339 - 'tutor-wpml' => array(
340 - 'name' => __( 'WPML', 'tutor' ),
341 - 'description' => __( 'Create multilingual courses, lessons, dashboard and more.', 'tutor' ),
342 - ),
343 - 'h5p' => array(
344 - 'name' => __( 'H5P', 'tutor' ),
345 - 'description' => __( 'Integrate H5P to add interactivity and engagement to your courses.', 'tutor' ),
346 - ),
97 + 'push-notification' => array(
98 + 'name' => 'Push Notification',
99 + 'description' => 'Users will get push notification on specified events.'
100 + )
347 101 );
348 102
349 103 return $addons;
350 104 }
351 -}
105 +
106 +
107 + /**
108 + * @deprecated from alpha version
109 + */
110 +
111 + public function addons_page(){
112 +
113 + if ( false === ( $addons_themes_data = get_transient( 'tutor_addons_themes_data' ) ) ) {
114 + //Request New
115 + $api_endpoint = 'https://www.themeum.com/wp-json/addon-serve/v2/get-products';
116 + $response = wp_remote_post( $api_endpoint, array(
117 + 'method' => 'POST',
118 + 'timeout' => 45,
119 + 'user-agent' => 'Tutor/'.TUTOR_VERSION.'; '.home_url( '/' ),
120 + 'headers' => array(
121 + 'wp_blog' => home_url( '/' )
122 + ),
123 + 'body' => array('plugin_slug' => 'tutor', 'wp_blog' => home_url( '/' )),
124 + )
125 + );
126 +
127 + if ( is_wp_error( $response ) ) {
128 + $error_message = $response->get_error_message();
129 + echo "Something went wrong: $error_message";
130 + } else {
131 + if (tutor_utils()->avalue_dot('body', $response) && tutor_utils()->avalue_dot('response.code', $response) == 200 ){
132 + $api_data = tutor_utils()->avalue_dot('body', $response);
133 +
134 + $addons_themes_data = array(
135 + 'last_checked_time' => tutor_time(),
136 + 'data' => $api_data,
137 + );
138 + }
139 + }
140 +
141 + //Save the Final api call result on the database
142 + set_transient( 'tutor_addons_themes_data', $addons_themes_data, 6 * HOUR_IN_SECONDS );
143 + }
144 +
145 +
146 + //Finally Show the View Page
147 + include tutor()->path.'views/pages/addons.php';
148 + }
149 +
150 +}