[ Avaa Bypassed ]




Upload:

Command:

hmhc3928@3.12.163.23: ~ $
<?php
/**
 * Manage Addons
 *
 * @package Tutor
 * @author Themeum <support@themeum.com>
 * @link https://themeum.com
 * @since 1.0.0
 */

namespace TUTOR;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
/**
 * Addons Class
 *
 * @since 1.0.0
 */
class Addons {
	const OPTION_KEY = 'tutor_addons_config';

	/**
	 * Constructor
	 *
	 * @since 1.0.0
	 * @return void
	 */
	public function __construct() {
		add_filter( 'tutor_pro_addons_lists_for_display', array( $this, 'addons_lists_to_show' ) );
		add_action( 'wp_ajax_tutor_get_all_addons', array( $this, 'get_all_addons' ) );
		add_action( 'wp_ajax_addon_enable_disable', array( $this, 'addon_enable_disable' ) );
	}

	/**
	 * Obtain addons config list.
	 *
	 * @since 3.0.0
	 *
	 * @return array
	 */
	public static function get_addons_config() {
		$list = get_option( self::OPTION_KEY, array() );
		return $list;
	}

	/**
	 * Status update of tutor addon.
	 *
	 * @since 3.0.0
	 *
	 * @param string $basename basename of addon.
	 * @param bool   $status status 0,1.
	 * @return void
	 */
	public static function update_addon_status( $basename, $status ) {
		$config = self::get_addons_config();
		if ( isset( $config[ $basename ] ) ) {
			$config[ $basename ]['is_enable'] = $status;
			update_option( self::OPTION_KEY, $config );
		}
	}

	/**
	 * Get all addons data.
	 *
	 * @since 1.0.0
	 * @return void
	 */
	public function get_all_addons() {

		// Check and verify the request.
		tutor_utils()->checking_nonce();

		if ( ! User::is_admin() ) {
			wp_send_json_error( tutor_utils()->error_message() );
		}

		// All good, let's proceed.
		$all_addons = $this->prepare_addons_data();

		wp_send_json_success(
			array(
				'addons' => $all_addons,
			)
		);
	}

	/**
	 * Prepare addons data.
	 *
	 * @since 1.0.0
	 * @return array
	 */
	public function prepare_addons_data() {
		$addons       = apply_filters( 'tutor_addons_lists_config', array() );
		$plugins_data = $addons;

		if ( is_array( $addons ) && count( $addons ) ) {
			foreach ( $addons as $base_name => $addon ) {
				$addon_config = tutor_utils()->get_addon_config( $base_name );
				$is_enabled   = (bool) tutor_utils()->avalue_dot( 'is_enable', $addon_config );

				$plugins_data[ $base_name ]['is_enabled'] = $is_enabled;

				$thumbnail_url = tutor()->url . 'assets/images/tutor-plugin.png';
				if ( file_exists( $addon['path'] . 'assets/images/thumbnail.png' ) ) {
					$thumbnail_url = $addon['url'] . 'assets/images/thumbnail.png';
				} elseif ( file_exists( $addon['path'] . 'assets/images/thumbnail.jpg' ) ) {
					$thumbnail_url = $addon['url'] . 'assets/images/thumbnail.jpg';
				} elseif ( file_exists( $addon['path'] . 'assets/images/thumbnail.svg' ) ) {
					$thumbnail_url = $addon['url'] . 'assets/images/thumbnail.svg';
				}

				$plugins_data[ $base_name ]['thumb_url'] = $thumbnail_url;

				/**
				 * Checking if there any dependant plugin exists
				 */
				$depends          = tutor_utils()->array_get( 'depend_plugins', $addon );
				$plugins_required = array();
				if ( tutor_utils()->count( $depends ) ) {
					foreach ( $depends as $plugin_base => $plugin_name ) {
						if ( ! is_plugin_active( $plugin_base ) ) {
							$plugins_required[ $plugin_base ] = $plugin_name;
						}
					}
				}

				$depended_plugins = array();
				foreach ( $plugins_required as $required_plugin ) {
					array_push( $depended_plugins, $required_plugin );
				}

				$plugins_data[ $base_name ]['plugins_required'] = $depended_plugins;

				// Check if it's notifications.
				if ( function_exists( 'tutor_notifications' ) && tutor_notifications()->basename === $base_name ) {

					$required = array();
					version_compare( PHP_VERSION, '7.2.5', '>=' ) ? 0 : $required[] = __( 'PHP 7.2.5 or greater is required', 'tutor' );
					! is_ssl() ? $required[]                                        = __( 'SSL certificate', 'tutor' ) : 0;

					foreach ( array( 'curl', 'gmp', 'mbstring', 'openssl' ) as $ext ) {
						! extension_loaded( $ext ) ? $required[] = 'PHP extension <strong>' . $ext . '</strong>' : 0;
					}

					$plugins_data[ $base_name ]['ext_required'] = $required;
				}
			}
		}

		/**
		 * Keep same sorting order.
		 *
		 * @since 2.2.4
		 */
		$free_addon_list = apply_filters( 'tutor_pro_addons_lists_for_display', array() );
		$prepared_addons = array();

		foreach ( $free_addon_list as $addon_name => $addon ) {
			$key = "tutor-pro/addons/{$addon_name}/{$addon_name}.php";
			if ( isset( $plugins_data[ $key ] ) ) {
				$prepared_addons[] = $plugins_data[ $key ];
			}
		}

		return $prepared_addons;
	}

	/**
	 * Method for enable / disable addons
	 *
	 * @since 1.0.0
	 * @return void
	 */
	public function addon_enable_disable() {

		tutor_utils()->checking_nonce();

		if ( ! current_user_can( 'manage_options' ) ) {
			wp_send_json_error( array( 'message' => __( 'Access Denied', 'tutor' ) ) );
		}

		$form_data     = json_decode( Input::post( 'addonFieldNames' ) );
		$before_config = self::get_addons_config();
		$addons_config = array();

		foreach ( $form_data as $addon_field_name => $is_enable ) {

			$before_status = ! isset( $before_config[ $addon_field_name ] ) ? 0 : $before_config[ $addon_field_name ]['is_enable'];
			$after_status  = $is_enable ? 1 : 0;

			if ( $before_status !== $after_status ) {
				do_action( 'tutor_addon_before_enable_disable' );
				if ( $is_enable ) {
					do_action( "tutor_addon_before_enable_{$addon_field_name}" );
					do_action( 'tutor_addon_before_enable', $addon_field_name );

					$addons_config[ $addon_field_name ]['is_enable'] = 1;
					update_option( self::OPTION_KEY, $addons_config );

					do_action( 'tutor_addon_after_enable', $addon_field_name );
					do_action( "tutor_addon_after_enable_{$addon_field_name}" );
				} else {
					do_action( "tutor_addon_before_disable_{$addon_field_name}" );
					do_action( 'tutor_addon_before_disable', $addon_field_name );

					$addons_config[ $addon_field_name ]['is_enable'] = 0;
					update_option( self::OPTION_KEY, $addons_config );

					do_action( 'tutor_addon_after_disable', $addon_field_name );
					do_action( "tutor_addon_after_disable_{$addon_field_name}" );
				}
				do_action( 'tutor_addon_after_enable_disable' );
			} else {
				$addons_config[ $addon_field_name ]['is_enable'] = $after_status;
				update_option( self::OPTION_KEY, $addons_config );
			}
		}

		wp_send_json_success();
	}

	/**
	 * Get tutor addons list
	 *
	 * @since 1.0.0
	 * @return array
	 */
	public function addons_lists_to_show() {
		$addons = array(
			'course-bundle'            => array(
				'name'        => __( 'Course Bundle', 'tutor' ),
				'description' => __( 'Group multiple courses to sell together.', 'tutor' ),
			),
			'subscription'             => array(
				'name'        => __( 'Subscription', 'tutor' ),
				'description' => __( 'Manage subscription', 'tutor' ),
			),
			'social-login'             => array(
				'name'        => __( 'Social Login', 'tutor' ),
				'description' => __( 'Let users register & login through social networks.', 'tutor' ),
			),
			'content-drip'             => array(
				'name'        => __( 'Content Drip', 'tutor' ),
				'description' => __( 'Unlock lessons by schedule or when students meet a specific condition.', 'tutor' ),
			),
			'tutor-multi-instructors'  => array(
				'name'        => __( 'Tutor Multi Instructors', 'tutor' ),
				'description' => __( 'Collaborate and add multiple instructors to a course.', 'tutor' ),
			),
			'tutor-assignments'        => array(
				'name'        => __( 'Tutor Assignments', 'tutor' ),
				'description' => __( 'Assess student learning with assignments.', 'tutor' ),
			),
			'tutor-course-preview'     => array(
				'name'        => __( 'Tutor Course Preview', 'tutor' ),
				'description' => __( 'Offer free previews of specific lessons before enrollment.', 'tutor' ),
			),
			'tutor-course-attachments' => array(
				'name'        => __( 'Tutor Course Attachments', 'tutor' ),
				'description' => __( 'Add unlimited attachments/ private files to any Tutor course', 'tutor' ),
			),
			'google-meet'              => array(
				'name'        => __( 'Tutor Google Meet Integration', 'tutor' ),
				'description' => __( 'Host live classes with Google Meet, directly from your lesson page.', 'tutor' ),
			),
			'tutor-report'             => array(
				'name'        => __( 'Tutor Report', 'tutor' ),
				'description' => __( 'Check your course performance through Tutor Report stats.', 'tutor' ),
			),
			'tutor-email'              => array(
				'name'        => __( 'Email', 'tutor' ),
				'description' => __( 'Send automated and customized emails for various Tutor events.', 'tutor' ),
			),
			'calendar'                 => array(
				'name'        => __( 'Calendar', 'tutor' ),
				'description' => __( 'Enable to let students view all your course events in one place.', 'tutor' ),
			),
			'tutor-notifications'      => array(
				'name'        => __( 'Notifications', 'tutor' ),
				'description' => __( 'Keep students and instructors notified of course events on their dashboard.', 'tutor' ),
			),
			'google-classroom'         => array(
				'name'        => __( 'Google Classroom Integration', 'tutor' ),
				'description' => __( 'Enable to integrate Tutor LMS with Google Classroom.', 'tutor' ),
			),
			'tutor-zoom'               => array(
				'name'        => __( 'Tutor Zoom Integration', 'tutor' ),
				'description' => __( 'Connect Tutor LMS with Zoom to host live online classes.', 'tutor' ),
			),
			'quiz-import-export'       => array(
				'name'        => __( 'Quiz Export/Import', 'tutor' ),
				'description' => __( 'Save time by exporting/importing quiz data with easy options.', 'tutor' ),
			),
			'enrollments'              => array(
				'name'        => __( 'Enrollment', 'tutor' ),
				'description' => __( 'Enable to manually enroll students in your courses.', 'tutor' ),
			),
			'tutor-certificate'        => array(
				'name'        => __( 'Tutor Certificate', 'tutor' ),
				'description' => __( 'Enable to award certificates upon course completion.', 'tutor' ),
			),
			'gradebook'                => array(
				'name'        => __( 'Gradebook', 'tutor' ),
				'description' => __( 'Track student progress with a centralized gradebook.', 'tutor' ),
			),
			'tutor-prerequisites'      => array(
				'name'        => __( 'Tutor Prerequisites', 'tutor' ),
				'description' => __( 'Set course prerequisites to guide learning paths effectively.', 'tutor' ),
			),
			'buddypress'               => array(
				'name'        => __( 'BuddyPress', 'tutor' ),
				'description' => __( 'Boost engagement with social features through BuddyPress for Tutor LMS.', 'tutor' ),
			),
			'wc-subscriptions'         => array(
				'name'        => __( 'WooCommerce Subscriptions', 'tutor' ),
				'description' => __( 'Capture Residual Revenue with Recurring Payments.', 'tutor' ),
			),
			'pmpro'                    => array(
				'name'        => __( 'Paid Memberships Pro', 'tutor' ),
				'description' => __( 'Boost revenue by selling course memberships.', 'tutor' ),
			),
			'restrict-content-pro'     => array(
				'name'        => __( 'Restrict Content Pro', 'tutor' ),
				'description' => __( 'Enable to manage content access through Restrict Content Pro. ', 'tutor' ),
			),
			'tutor-weglot'             => array(
				'name'        => __( 'Weglot', 'tutor' ),
				'description' => __( 'Translate & manage multilingual courses for global reach.', 'tutor' ),
			),
			'tutor-wpml'               => array(
				'name'        => __( 'WPML', 'tutor' ),
				'description' => __( 'Create multilingual courses, lessons, dashboard and more.', 'tutor' ),
			),
			'h5p'                      => array(
				'name'        => __( 'H5P', 'tutor' ),
				'description' => __( 'Integrate H5P to add interactivity and engagement to your courses.', 'tutor' ),
				'is_new'      => true,
			),
		);

		return $addons;
	}
}

Filemanager

Name Type Size Permission Actions
Addons.php File 11.6 KB 0644
Admin.php File 21.3 KB 0644
Ajax.php File 16.82 KB 0644
Announcements.php File 2.67 KB 0644
Assets.php File 23.25 KB 0644
Backend_Page_Trait.php File 4.39 KB 0644
BaseController.php File 1.47 KB 0644
Course.php File 85.39 KB 0644
Course_Embed.php File 2.55 KB 0644
Course_Filter.php File 8.67 KB 0644
Course_List.php File 13.7 KB 0644
Course_Settings_Tabs.php File 1.16 KB 0644
Course_Widget.php File 8.19 KB 0644
Custom_Validation.php File 513 B 0644
Dashboard.php File 1.23 KB 0644
Earnings.php File 9.53 KB 0644
FormHandler.php File 7.16 KB 0644
Frontend.php File 2.94 KB 0644
Gutenberg.php File 4.62 KB 0644
Input.php File 9.08 KB 0644
Instructor.php File 12.99 KB 0644
Instructors_List.php File 12.97 KB 0644
Lesson.php File 17.08 KB 0644
Options_V2.php File 63.19 KB 0644
Permalink.php File 2 KB 0644
Post_types.php File 18.3 KB 0644
Private_Course_Access.php File 2.52 KB 0644
Q_And_A.php File 10.66 KB 0644
Question_Answers_List.php File 2.54 KB 0644
Quiz.php File 62.02 KB 0644
QuizBuilder.php File 11.5 KB 0644
Quiz_Attempts_List.php File 7.32 KB 0644
RestAPI.php File 7.97 KB 0644
Reviews.php File 2.71 KB 0644
Rewrite_Rules.php File 5.18 KB 0644
Shortcode.php File 14.22 KB 0644
Singleton.php File 1.08 KB 0644
Student.php File 10.18 KB 0644
Students_List.php File 2.37 KB 0644
Taxonomies.php File 8.2 KB 0644
Template.php File 14.18 KB 0644
Theme_Compatibility.php File 683 B 0644
Tools.php File 3.33 KB 0644
Tools_V2.php File 18.18 KB 0644
Tutor.php File 36.06 KB 0644
TutorEDD.php File 4.63 KB 0644
Tutor_Base.php File 1.48 KB 0644
Tutor_Setup.php File 33.25 KB 0644
Upgrader.php File 7.49 KB 0644
User.php File 14.66 KB 0644
Utils.php File 263.33 KB 0644
Video_Stream.php File 3.94 KB 0644
WhatsNew.php File 4.07 KB 0644
Withdraw.php File 9.49 KB 0644
Withdraw_Requests_List.php File 6.15 KB 0644
WooCommerce.php File 23.15 KB 0644