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.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 11 months ago Admin.php 8 months ago Ajax.php 9 months ago Announcements.php 1 year ago Assets.php 7 months ago Backend_Page_Trait.php 1 year ago BaseController.php 1 year ago Config.php 11 months ago Container.php 11 months ago Course.php 5 months ago Course_Embed.php 3 years ago Course_Filter.php 1 year ago Course_List.php 5 months ago Course_Settings_Tabs.php 1 year ago Course_Widget.php 1 year ago Custom_Validation.php 3 years ago Dashboard.php 1 year ago Earnings.php 9 months ago FormHandler.php 2 years ago Frontend.php 1 year ago Gutenberg.php 1 year ago Icon.php 8 months ago Input.php 1 year ago Instructor.php 1 year ago Instructors_List.php 11 months ago Lesson.php 8 months ago Options_V2.php 7 months ago Permalink.php 2 years ago Post_types.php 1 year ago Private_Course_Access.php 1 year ago Q_And_A.php 10 months ago Question_Answers_List.php 11 months ago Quiz.php 5 months ago QuizBuilder.php 11 months ago Quiz_Attempts_List.php 9 months ago RestAPI.php 2 years ago Reviews.php 9 months ago Rewrite_Rules.php 2 years ago Shortcode.php 9 months ago Singleton.php 1 year ago Student.php 1 year ago Students_List.php 1 year ago Taxonomies.php 1 year ago Template.php 9 months ago Theme_Compatibility.php 3 years ago Tools.php 1 year ago Tools_V2.php 1 year ago Tutor.php 7 months ago TutorEDD.php 1 year ago Tutor_Base.php 2 years ago Tutor_Setup.php 8 months ago Upgrader.php 9 months ago User.php 5 months ago Utils.php 5 months ago Video_Stream.php 3 years ago WhatsNew.php 9 months ago Withdraw.php 1 year ago Withdraw_Requests_List.php 11 months ago WooCommerce.php 7 months ago
Addons.php
352 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 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16 /**
17 * Addons Class
18 *
19 * @since 1.0.0
20 */
21 class Addons {
22 const OPTION_KEY = 'tutor_addons_config';
23
24 /**
25 * Constructor
26 *
27 * @since 1.0.0
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 * @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() {
233 $addons = array(
234 'course-bundle' => array(
235 'name' => __( 'Course Bundle', 'tutor' ),
236 'description' => __( 'Group multiple courses to sell together.', 'tutor' ),
237 ),
238 'subscription' => array(
239 'name' => __( 'Subscription', 'tutor' ),
240 'description' => __( 'Manage subscription', 'tutor' ),
241 ),
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,
246 ),
247 'social-login' => array(
248 'name' => __( 'Social Login', 'tutor' ),
249 'description' => __( 'Let users register & login through social networks.', 'tutor' ),
250 ),
251 'content-drip' => array(
252 'name' => __( 'Content Drip', 'tutor' ),
253 'description' => __( 'Unlock lessons by schedule or when students meet a specific condition.', 'tutor' ),
254 ),
255 'tutor-multi-instructors' => array(
256 'name' => __( 'Tutor Multi Instructors', 'tutor' ),
257 'description' => __( 'Collaborate and add multiple instructors to a course.', 'tutor' ),
258 ),
259 'tutor-assignments' => array(
260 'name' => __( 'Tutor Assignments', 'tutor' ),
261 'description' => __( 'Assess student learning with assignments.', 'tutor' ),
262 ),
263 'tutor-course-preview' => array(
264 'name' => __( 'Tutor Course Preview', 'tutor' ),
265 'description' => __( 'Offer free previews of specific lessons before enrollment.', 'tutor' ),
266 ),
267 'tutor-course-attachments' => array(
268 'name' => __( 'Tutor Course Attachments', 'tutor' ),
269 'description' => __( 'Add unlimited attachments/ private files to any Tutor course', 'tutor' ),
270 ),
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' ),
274 ),
275 'tutor-report' => array(
276 'name' => __( 'Tutor Report', 'tutor' ),
277 'description' => __( 'Check your course performance through Tutor Report stats.', 'tutor' ),
278 ),
279 'tutor-email' => array(
280 'name' => __( 'Email', 'tutor' ),
281 'description' => __( 'Send automated and customized emails for various Tutor events.', 'tutor' ),
282 ),
283 'calendar' => array(
284 'name' => __( 'Calendar', 'tutor' ),
285 'description' => __( 'Enable to let students view all your course events in one place.', 'tutor' ),
286 ),
287 'tutor-notifications' => array(
288 'name' => __( 'Notifications', 'tutor' ),
289 'description' => __( 'Keep students and instructors notified of course events on their dashboard.', 'tutor' ),
290 ),
291 'google-classroom' => array(
292 'name' => __( 'Google Classroom Integration', 'tutor' ),
293 'description' => __( 'Enable to integrate Tutor LMS with Google Classroom.', 'tutor' ),
294 ),
295 'tutor-zoom' => array(
296 'name' => __( 'Tutor Zoom Integration', 'tutor' ),
297 'description' => __( 'Connect Tutor LMS with Zoom to host live online classes.', 'tutor' ),
298 ),
299 'quiz-import-export' => array(
300 'name' => __( 'Quiz Export/Import', 'tutor' ),
301 'description' => __( 'Save time by exporting/importing quiz data with easy options.', 'tutor' ),
302 ),
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 ),
347 );
348
349 return $addons;
350 }
351 }
352