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.0 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.8.0 3.8.1 3.8.2 3.8.3 3.9.0 3.9.1 3.9.10 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9
tutor / classes / Addons.php
tutor / classes Last commit date
Addons.php 1 day ago Admin.php 1 day ago Ajax.php 1 day ago Announcements.php 1 day ago Assets.php 1 day ago Backend_Page_Trait.php 1 year ago BaseController.php 1 year ago Config.php 1 day ago Container.php 11 months ago Course.php 1 day ago Course_Embed.php 3 years ago Course_Filter.php 1 day ago Course_List.php 1 day ago Course_Settings_Tabs.php 1 day ago Course_Widget.php 1 year ago Custom_Validation.php 1 day ago Dashboard.php 1 day ago Earnings.php 9 months ago FormHandler.php 1 day ago Frontend.php 1 day ago Gutenberg.php 1 year ago Icon.php 1 day ago Input.php 1 day ago Instructor.php 1 day ago Instructors_List.php 1 day ago Lesson.php 1 day ago Options_V2.php 1 day ago Permalink.php 1 day ago Post_types.php 2 days ago Private_Course_Access.php 1 day ago Q_And_A.php 1 day ago Question_Answers_List.php 11 months ago Quiz.php 1 day ago QuizBuilder.php 1 day ago Quiz_Attempts_List.php 1 day ago RestAPI.php 2 years ago Reviews.php 1 day ago Rewrite_Rules.php 2 years ago SampleCourse.php 1 day ago Shortcode.php 1 day ago Singleton.php 1 year ago Student.php 1 day ago Students_List.php 1 year ago Taxonomies.php 1 year ago Template.php 1 day ago Theme_Compatibility.php 3 years ago Tools.php 1 year ago Tools_V2.php 4 weeks ago Tutor.php 1 day ago TutorEDD.php 1 day ago Tutor_Base.php 2 years ago Tutor_Setup.php 1 day ago Upgrader.php 1 day ago User.php 1 day ago UserPreference.php 1 day ago Utils.php 1 day ago Video_Stream.php 3 years ago WhatsNew.php 10 months ago Withdraw.php 1 day ago Withdraw_Requests_List.php 11 months ago WooCommerce.php 1 day ago
Addons.php
355 lines
1 <?php
2 /**
3 * Manage Addons
4 *
5 * @package Tutor
6 * @author Themeum <support@themeum.com>
7 * @link https://themeum.com
8 * @since 1.0.0
9 */
10
11 namespace TUTOR;
12
13 defined( 'ABSPATH' ) || exit;
14
15 /**
16 * Addons Class
17 *
18 * @since 1.0.0
19 */
20 class Addons {
21 const OPTION_KEY = 'tutor_addons_config';
22
23 /**
24 * Constructor
25 *
26 * @since 1.0.0
27 *
28 * @return void
29 */
30 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' ) );
34 }
35
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 *
56 * @return void
57 */
58 public static function update_addon_status( $basename, $status ) {
59 $config = self::get_addons_config();
60 if ( isset( $config[ $basename ] ) ) {
61 $config[ $basename ]['is_enable'] = $status;
62 update_option( self::OPTION_KEY, $config );
63 }
64 }
65
66 /**
67 * Get all addons data.
68 *
69 * @since 1.0.0
70 *
71 * @return void
72 */
73 public function get_all_addons() {
74
75 // Check and verify the request.
76 tutor_utils()->checking_nonce();
77
78 if ( ! User::can() ) {
79 wp_send_json_error( tutor_utils()->error_message() );
80 }
81
82 // All good, let's proceed.
83 $all_addons = $this->prepare_addons_data();
84
85 wp_send_json_success(
86 array(
87 'addons' => $all_addons,
88 )
89 );
90 }
91
92 /**
93 * Prepare addons data.
94 *
95 * @since 1.0.0
96 * @return array
97 */
98 public function prepare_addons_data() {
99 $addons = apply_filters( 'tutor_addons_lists_config', array() );
100 $plugins_data = $addons;
101
102 if ( is_array( $addons ) && count( $addons ) ) {
103 foreach ( $addons as $base_name => $addon ) {
104 $addon_config = tutor_utils()->get_addon_config( $base_name );
105 $is_enabled = (bool) tutor_utils()->avalue_dot( 'is_enable', $addon_config );
106
107 $plugins_data[ $base_name ]['is_enabled'] = $is_enabled;
108
109 $thumbnail_url = tutor()->url . 'assets/images/tutor-plugin.png';
110 if ( file_exists( $addon['path'] . 'assets/images/thumbnail.png' ) ) {
111 $thumbnail_url = $addon['url'] . 'assets/images/thumbnail.png';
112 } elseif ( file_exists( $addon['path'] . 'assets/images/thumbnail.jpg' ) ) {
113 $thumbnail_url = $addon['url'] . 'assets/images/thumbnail.jpg';
114 } elseif ( file_exists( $addon['path'] . 'assets/images/thumbnail.svg' ) ) {
115 $thumbnail_url = $addon['url'] . 'assets/images/thumbnail.svg';
116 }
117
118 $plugins_data[ $base_name ]['thumb_url'] = $thumbnail_url;
119
120 /**
121 * Checking if there any dependant plugin exists
122 */
123 $depends = tutor_utils()->array_get( 'depend_plugins', $addon );
124 $plugins_required = array();
125 if ( tutor_utils()->count( $depends ) ) {
126 foreach ( $depends as $plugin_base => $plugin_name ) {
127 if ( ! is_plugin_active( $plugin_base ) ) {
128 $plugins_required[ $plugin_base ] = $plugin_name;
129 }
130 }
131 }
132
133 $depended_plugins = array();
134 foreach ( $plugins_required as $required_plugin ) {
135 array_push( $depended_plugins, $required_plugin );
136 }
137
138 $plugins_data[ $base_name ]['plugins_required'] = $depended_plugins;
139
140 // Check if it's notifications.
141 if ( function_exists( 'tutor_notifications' ) && tutor_notifications()->basename === $base_name ) {
142
143 $required = array();
144 version_compare( PHP_VERSION, '7.2.5', '>=' ) ? 0 : $required[] = __( 'PHP 7.2.5 or greater is required', 'tutor' );
145 ! is_ssl() ? $required[] = __( 'SSL certificate', 'tutor' ) : 0;
146
147 foreach ( array( 'curl', 'gmp', 'mbstring', 'openssl' ) as $ext ) {
148 ! extension_loaded( $ext ) ? $required[] = 'PHP extension <strong>' . $ext . '</strong>' : 0;
149 }
150
151 $plugins_data[ $base_name ]['ext_required'] = $required;
152 }
153 }
154 }
155
156 /**
157 * Keep same sorting order.
158 *
159 * @since 2.2.4
160 */
161 $free_addon_list = apply_filters( 'tutor_pro_addons_lists_for_display', array() );
162 $prepared_addons = array();
163
164 foreach ( $free_addon_list as $addon_name => $addon ) {
165 $key = "tutor-pro/addons/{$addon_name}/{$addon_name}.php";
166 if ( isset( $plugins_data[ $key ] ) ) {
167 $prepared_addons[] = $plugins_data[ $key ];
168 }
169 }
170
171 return $prepared_addons;
172 }
173
174 /**
175 * Method for enable / disable addons
176 *
177 * @since 1.0.0
178 * @return void
179 */
180 public function addon_enable_disable() {
181
182 tutor_utils()->checking_nonce();
183
184 if ( ! User::can() ) {
185 wp_send_json_error( tutor_utils()->error_message() );
186 }
187
188 $form_data = json_decode( Input::post( 'addonFieldNames' ) );
189 $before_config = self::get_addons_config();
190 $addons_config = array();
191
192 foreach ( $form_data as $addon_field_name => $is_enable ) {
193
194 $before_status = ! isset( $before_config[ $addon_field_name ] ) ? 0 : $before_config[ $addon_field_name ]['is_enable'];
195 $after_status = $is_enable ? 1 : 0;
196
197 if ( $before_status !== $after_status ) {
198 do_action( 'tutor_addon_before_enable_disable' );
199 if ( $is_enable ) {
200 do_action( "tutor_addon_before_enable_{$addon_field_name}" );
201 do_action( 'tutor_addon_before_enable', $addon_field_name );
202
203 $addons_config[ $addon_field_name ]['is_enable'] = 1;
204 update_option( self::OPTION_KEY, $addons_config );
205
206 do_action( 'tutor_addon_after_enable', $addon_field_name );
207 do_action( "tutor_addon_after_enable_{$addon_field_name}" );
208 } else {
209 do_action( "tutor_addon_before_disable_{$addon_field_name}" );
210 do_action( 'tutor_addon_before_disable', $addon_field_name );
211
212 $addons_config[ $addon_field_name ]['is_enable'] = 0;
213 update_option( self::OPTION_KEY, $addons_config );
214
215 do_action( 'tutor_addon_after_disable', $addon_field_name );
216 do_action( "tutor_addon_after_disable_{$addon_field_name}" );
217 }
218 do_action( 'tutor_addon_after_enable_disable' );
219 } else {
220 $addons_config[ $addon_field_name ]['is_enable'] = $after_status;
221 update_option( self::OPTION_KEY, $addons_config );
222 }
223 }
224
225 wp_send_json_success();
226 }
227
228 /**
229 * Get tutor addons list
230 *
231 * @since 1.0.0
232 *
233 * @return array
234 */
235 public function addons_lists_to_show() {
236 $addons = array(
237 'course-bundle' => array(
238 'name' => __( 'Course Bundle', 'tutor' ),
239 'description' => __( 'Group multiple courses to sell together.', 'tutor' ),
240 ),
241 'subscription' => array(
242 'name' => __( 'Subscription', 'tutor' ),
243 'description' => __( 'Manage subscription', 'tutor' ),
244 ),
245 'content-bank' => array(
246 'name' => __( 'Content Bank', 'tutor' ),
247 'description' => __( 'Create content once and use it across multiple courses.', 'tutor' ),
248 'is_new' => true,
249 ),
250 'social-login' => array(
251 'name' => __( 'Social Login', 'tutor' ),
252 'description' => __( 'Let users register & login through social networks.', 'tutor' ),
253 ),
254 'content-drip' => array(
255 'name' => __( 'Content Drip', 'tutor' ),
256 'description' => __( 'Unlock lessons by schedule or when students meet a specific condition.', 'tutor' ),
257 ),
258 'tutor-multi-instructors' => array(
259 'name' => __( 'Tutor Multi Instructors', 'tutor' ),
260 'description' => __( 'Collaborate and add multiple instructors to a course.', 'tutor' ),
261 ),
262 'tutor-assignments' => array(
263 'name' => __( 'Tutor Assignments', 'tutor' ),
264 'description' => __( 'Assess student learning with assignments.', 'tutor' ),
265 ),
266 'tutor-course-preview' => array(
267 'name' => __( 'Tutor Course Preview', 'tutor' ),
268 'description' => __( 'Offer free previews of specific lessons before enrollment.', 'tutor' ),
269 ),
270 'tutor-course-attachments' => array(
271 'name' => __( 'Tutor Course Attachments', 'tutor' ),
272 'description' => __( 'Add unlimited attachments/ private files to any Tutor course', 'tutor' ),
273 ),
274 'google-meet' => array(
275 'name' => __( 'Tutor Google Meet Integration', 'tutor' ),
276 'description' => __( 'Host live classes with Google Meet, directly from your lesson page.', 'tutor' ),
277 ),
278 'tutor-report' => array(
279 'name' => __( 'Tutor Report', 'tutor' ),
280 'description' => __( 'Check your course performance through Tutor Report stats.', 'tutor' ),
281 ),
282 'tutor-email' => array(
283 'name' => __( 'Email', 'tutor' ),
284 'description' => __( 'Send automated and customized emails for various Tutor events.', 'tutor' ),
285 ),
286 'calendar' => array(
287 'name' => __( 'Calendar', 'tutor' ),
288 'description' => __( 'Enable to let students view all your course events in one place.', 'tutor' ),
289 ),
290 'tutor-notifications' => array(
291 'name' => __( 'Notifications', 'tutor' ),
292 'description' => __( 'Keep students and instructors notified of course events on their dashboard.', 'tutor' ),
293 ),
294 'google-classroom' => array(
295 'name' => __( 'Google Classroom Integration', 'tutor' ),
296 'description' => __( 'Enable to integrate Tutor LMS with Google Classroom.', 'tutor' ),
297 ),
298 'tutor-zoom' => array(
299 'name' => __( 'Tutor Zoom Integration', 'tutor' ),
300 'description' => __( 'Connect Tutor LMS with Zoom to host live online classes.', 'tutor' ),
301 ),
302 'quiz-import-export' => array(
303 'name' => __( 'Quiz Export/Import', 'tutor' ),
304 'description' => __( 'Save time by exporting/importing quiz data with easy options.', 'tutor' ),
305 ),
306 'enrollments' => array(
307 'name' => __( 'Enrollment', 'tutor' ),
308 'description' => __( 'Enable to manually enroll students in your courses.', 'tutor' ),
309 ),
310 'tutor-certificate' => array(
311 'name' => __( 'Tutor Certificate', 'tutor' ),
312 'description' => __( 'Enable to award certificates upon course completion.', 'tutor' ),
313 ),
314 'gradebook' => array(
315 'name' => __( 'Gradebook', 'tutor' ),
316 'description' => __( 'Track student progress with a centralized gradebook.', 'tutor' ),
317 ),
318 'tutor-prerequisites' => array(
319 'name' => __( 'Tutor Prerequisites', 'tutor' ),
320 'description' => __( 'Set course prerequisites to guide learning paths effectively.', 'tutor' ),
321 ),
322 'buddypress' => array(
323 'name' => __( 'BuddyPress', 'tutor' ),
324 'description' => __( 'Boost engagement with social features through BuddyPress for Tutor LMS.', 'tutor' ),
325 ),
326 'wc-subscriptions' => array(
327 'name' => __( 'WooCommerce Subscriptions', 'tutor' ),
328 'description' => __( 'Capture Residual Revenue with Recurring Payments.', 'tutor' ),
329 ),
330 'pmpro' => array(
331 'name' => __( 'Paid Memberships Pro', 'tutor' ),
332 'description' => __( 'Boost revenue by selling course memberships.', 'tutor' ),
333 ),
334 'restrict-content-pro' => array(
335 'name' => __( 'Restrict Content Pro', 'tutor' ),
336 'description' => __( 'Enable to manage content access through Restrict Content Pro. ', 'tutor' ),
337 ),
338 'tutor-weglot' => array(
339 'name' => __( 'Weglot', 'tutor' ),
340 'description' => __( 'Translate & manage multilingual courses for global reach.', 'tutor' ),
341 ),
342 'tutor-wpml' => array(
343 'name' => __( 'WPML', 'tutor' ),
344 'description' => __( 'Create multilingual courses, lessons, dashboard and more.', 'tutor' ),
345 ),
346 'h5p' => array(
347 'name' => __( 'H5P', 'tutor' ),
348 'description' => __( 'Integrate H5P to add interactivity and engagement to your courses.', 'tutor' ),
349 ),
350 );
351
352 return $addons;
353 }
354 }
355