[ Avaa Bypassed ]




Upload:

Command:

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

namespace TUTOR;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Gutenberg class
 *
 * @since 1.0.0
 */
class Gutenberg {
	/**
	 * Constructor
	 *
	 * @since 1.0.0
	 * @return void|null
	 */
	public function __construct() {
		if ( ! function_exists( 'register_block_type' ) ) {
			return;
		}

		add_action( 'init', array( $this, 'register_blocks' ) );
		add_filter( 'block_categories_all', array( $this, 'registering_new_block_category' ), 10, 2 );
		add_action( 'wp_ajax_render_block_tutor', array( $this, 'render_block_tutor' ) );
		add_filter( 'rest_user_query', array( $this, 'author_list_dropdown' ), 10, 2 );
	}

	/**
	 * Bind author list on gutenberg editor mode
	 *
	 * @since 2.1.0
	 *
	 * @param array           $prepared_args arguments.
	 * @param WP_REST_Request $request WP REST request object.
	 *
	 * @return array
	 */
	public function author_list_dropdown( $prepared_args, $request ) {
		$url   = $request->get_header( 'referer' );
		$parts = parse_url( $url );
		if ( ! isset( $parts['query'] ) ) {
			return $prepared_args;
		}

		parse_str( $parts['query'], $query );
		$post_id = isset( $query['post'] ) ? (int) $query['post'] : 0;

		if ( ! $post_id ) {
			return $prepared_args;
		}

		$post = get_post( $post_id );

		if ( tutor()->course_post_type === $post->post_type && tutor_utils()->get_option( 'enable_gutenberg_course_edit' ) === true ) {
			// Modify the wp/v2/users endpoint request from gutenberg editor.
			unset( $prepared_args['who'] );
			$prepared_args['role__in'] = array( 'administrator', 'tutor_instructor' );
		}

		return $prepared_args;
	}

	/**
	 * Register blocks
	 *
	 * @since 1.0.0
	 * @return void
	 */
	public function register_blocks() {
		global $pagenow;
		if ( 'widgets.php' !== $pagenow ) {
			wp_register_script(
				'tutor-student-registration-block',
				tutor()->url . 'assets/lib/gutenberg_blocks.js',
				array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-components', 'wp-editor' ),
				TUTOR_VERSION
			);
		}

		register_block_type(
			'tutor-gutenberg/student-registration',
			array(
				'editor_script'   => 'tutor-student-registration-block',
				'render_callback' => array( $this, 'render_block_student_registration' ),
			)
		);

		register_block_type(
			'tutor-gutenberg/instructor-registration',
			array(
				'editor_script'   => 'tutor-student-registration-block',
				'render_callback' => array( $this, 'render_block_tutor_instructor_registration_form' ),
			)
		);

		// Check if WP version is equal to or greater than 5.9.
		global $wp_version;
		if ( version_compare( $wp_version, '5.9', '>=' ) && function_exists( 'wp_is_block_theme' ) && wp_is_block_theme() ) {
			wp_localize_script(
				'tutor-student-registration-block',
				'_tutor_gutenberg_block_data',
				array(
					'is_wp_version_5_9' => 'true',
				)
			);
		} else {
			wp_localize_script(
				'tutor-student-registration-block',
				'_tutor_gutenberg_block_data',
				array(
					'is_wp_version_5_9' => 'false',
				)
			);
		}
	}

	/**
	 * Register new category block
	 *
	 * @since 1.0.0
	 *
	 * @param array  $categories categories.
	 * @param object $post post object.
	 *
	 * @return array
	 */
	public function registering_new_block_category( $categories, $post ) {
		return array_merge(
			array(
				array(
					'slug'  => 'tutor',
					'title' => __( 'Tutor LMS', 'tutor' ),
				),
			),
			$categories
		);
	}

	/**
	 * Render student registration block
	 *
	 * @since 1.0.0
	 *
	 * @param array $args arguments.
	 * @return mixed
	 */
	public function render_block_student_registration( $args ) {
		return do_shortcode( '[tutor_student_registration_form]' );
	}

	/**
	 * Render dashboard block
	 *
	 * @since 1.0.0
	 *
	 * @param array $args arguments.
	 * @return mixed
	 */
	public function render_block_tutor_dashboard( $args ) {
		return do_shortcode( '[tutor_dashboard]' );
	}

	/**
	 * Render instructor registration block
	 *
	 * @since 1.0.0
	 *
	 * @param array $args arguments.
	 * @return mixed
	 */
	public function render_block_tutor_instructor_registration_form( $args ) {
		return do_shortcode( '[tutor_instructor_registration_form]' );
	}

	/**
	 * Render tutor block for editor
	 *
	 * @since 1.0.0
	 * @return void
	 */
	public function render_block_tutor() {
		tutor_utils()->checking_nonce();

		$shortcode = Input::post( 'shortcode' );

		$allowed_shortcode = array(
			'tutor_instructor_registration_form',
			'tutor_student_registration_form',
		);

		if ( ! in_array( $shortcode, $allowed_shortcode ) ) {
			wp_send_json_error();
		}

		wp_send_json_success( do_shortcode( "[{$shortcode}]" ) );
	}

}

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