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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 / Gutenberg.php
tutor / classes Last commit date
Addons.php 11 months ago Admin.php 11 months ago Ajax.php 1 year ago Announcements.php 1 year ago Assets.php 11 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 10 months ago Course_Embed.php 3 years ago Course_Filter.php 1 year ago Course_List.php 10 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 1 year ago FormHandler.php 2 years ago Frontend.php 1 year ago Gutenberg.php 1 year ago Icon.php 10 months ago Input.php 1 year ago Instructor.php 1 year ago Instructors_List.php 11 months ago Lesson.php 10 months ago Options_V2.php 11 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 10 months ago QuizBuilder.php 11 months ago Quiz_Attempts_List.php 11 months ago RestAPI.php 2 years ago Reviews.php 11 months ago Rewrite_Rules.php 2 years ago Shortcode.php 1 year ago Singleton.php 1 year ago Student.php 1 year ago Students_List.php 1 year ago Taxonomies.php 1 year ago Template.php 11 months ago Theme_Compatibility.php 3 years ago Tools.php 1 year ago Tools_V2.php 1 year ago Tutor.php 10 months ago TutorEDD.php 1 year ago Tutor_Base.php 2 years ago Tutor_Setup.php 1 year ago Upgrader.php 10 months ago User.php 1 year ago Utils.php 10 months ago Video_Stream.php 3 years ago WhatsNew.php 2 years ago Withdraw.php 1 year ago Withdraw_Requests_List.php 11 months ago WooCommerce.php 1 year ago
Gutenberg.php
211 lines
1 <?php
2 /**
3 * Manage Gutenberg
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 /**
18 * Gutenberg class
19 *
20 * @since 1.0.0
21 */
22 class Gutenberg {
23 /**
24 * Constructor
25 *
26 * @since 1.0.0
27 * @return void|null
28 */
29 public function __construct() {
30 if ( ! function_exists( 'register_block_type' ) ) {
31 return;
32 }
33
34 add_action( 'init', array( $this, 'register_blocks' ) );
35 add_filter( 'block_categories_all', array( $this, 'registering_new_block_category' ), 10, 2 );
36 add_action( 'wp_ajax_render_block_tutor', array( $this, 'render_block_tutor' ) );
37 add_filter( 'rest_user_query', array( $this, 'author_list_dropdown' ), 10, 2 );
38 }
39
40 /**
41 * Bind author list on gutenberg editor mode
42 *
43 * @since 2.1.0
44 *
45 * @param array $prepared_args arguments.
46 * @param WP_REST_Request $request WP REST request object.
47 *
48 * @return array
49 */
50 public function author_list_dropdown( $prepared_args, $request ) {
51 $url = $request->get_header( 'referer' );
52 $parts = parse_url( $url );
53 if ( ! isset( $parts['query'] ) ) {
54 return $prepared_args;
55 }
56
57 parse_str( $parts['query'], $query );
58 $post_id = isset( $query['post'] ) ? (int) $query['post'] : 0;
59
60 if ( ! $post_id ) {
61 return $prepared_args;
62 }
63
64 $post = get_post( $post_id );
65
66 if ( tutor()->course_post_type === $post->post_type && tutor_utils()->get_option( 'enable_gutenberg_course_edit' ) === true ) {
67 // Modify the wp/v2/users endpoint request from gutenberg editor.
68 unset( $prepared_args['who'] );
69 $prepared_args['role__in'] = array( 'administrator', 'tutor_instructor' );
70 }
71
72 return $prepared_args;
73 }
74
75 /**
76 * Register blocks
77 *
78 * @since 1.0.0
79 * @return void
80 */
81 public function register_blocks() {
82 global $pagenow;
83 if ( 'widgets.php' !== $pagenow ) {
84 wp_register_script(
85 'tutor-student-registration-block',
86 tutor()->url . 'assets/lib/gutenberg_blocks.js',
87 array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-components', 'wp-editor' ),
88 TUTOR_VERSION
89 );
90 }
91
92 register_block_type(
93 'tutor-gutenberg/student-registration',
94 array(
95 'editor_script' => 'tutor-student-registration-block',
96 'render_callback' => array( $this, 'render_block_student_registration' ),
97 )
98 );
99
100 register_block_type(
101 'tutor-gutenberg/instructor-registration',
102 array(
103 'editor_script' => 'tutor-student-registration-block',
104 'render_callback' => array( $this, 'render_block_tutor_instructor_registration_form' ),
105 )
106 );
107
108 // Check if WP version is equal to or greater than 5.9.
109 global $wp_version;
110 if ( version_compare( $wp_version, '5.9', '>=' ) && function_exists( 'wp_is_block_theme' ) && wp_is_block_theme() ) {
111 wp_localize_script(
112 'tutor-student-registration-block',
113 '_tutor_gutenberg_block_data',
114 array(
115 'is_wp_version_5_9' => 'true',
116 )
117 );
118 } else {
119 wp_localize_script(
120 'tutor-student-registration-block',
121 '_tutor_gutenberg_block_data',
122 array(
123 'is_wp_version_5_9' => 'false',
124 )
125 );
126 }
127 }
128
129 /**
130 * Register new category block
131 *
132 * @since 1.0.0
133 *
134 * @param array $categories categories.
135 * @param object $post post object.
136 *
137 * @return array
138 */
139 public function registering_new_block_category( $categories, $post ) {
140 return array_merge(
141 array(
142 array(
143 'slug' => 'tutor',
144 'title' => __( 'Tutor LMS', 'tutor' ),
145 ),
146 ),
147 $categories
148 );
149 }
150
151 /**
152 * Render student registration block
153 *
154 * @since 1.0.0
155 *
156 * @param array $args arguments.
157 * @return mixed
158 */
159 public function render_block_student_registration( $args ) {
160 return do_shortcode( '[tutor_student_registration_form]' );
161 }
162
163 /**
164 * Render dashboard block
165 *
166 * @since 1.0.0
167 *
168 * @param array $args arguments.
169 * @return mixed
170 */
171 public function render_block_tutor_dashboard( $args ) {
172 return do_shortcode( '[tutor_dashboard]' );
173 }
174
175 /**
176 * Render instructor registration block
177 *
178 * @since 1.0.0
179 *
180 * @param array $args arguments.
181 * @return mixed
182 */
183 public function render_block_tutor_instructor_registration_form( $args ) {
184 return do_shortcode( '[tutor_instructor_registration_form]' );
185 }
186
187 /**
188 * Render tutor block for editor
189 *
190 * @since 1.0.0
191 * @return void
192 */
193 public function render_block_tutor() {
194 tutor_utils()->checking_nonce();
195
196 $shortcode = Input::post( 'shortcode' );
197
198 $allowed_shortcode = array(
199 'tutor_instructor_registration_form',
200 'tutor_student_registration_form',
201 );
202
203 if ( ! in_array( $shortcode, $allowed_shortcode ) ) {
204 wp_send_json_error();
205 }
206
207 wp_send_json_success( do_shortcode( "[{$shortcode}]" ) );
208 }
209
210 }
211