PluginProbe
Tutor LMS – eLearning and online course solution / 1.3.5
Tutor LMS – eLearning and online course solution v1.3.5
4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 4.0.0 3.9.15 3.9.14 3.9.13 3.9.12 3.9.11 trunk 1.0.0 1.0.0-alpha 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 All 191 releases
tutor / classes / Gutenberg.php

Gutenberg.php in Tutor LMS – eLearning and online course solution 1.3.5, at classes/Gutenberg.php

78 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Gutenberg class
4 *
5 * @author: themeum
6 * @author_uri: https://themeum.com
7 * @package Tutor
8 * @since v.1.0.0
9 */
10
11
12 namespace TUTOR;
13
14
15 if ( ! defined( 'ABSPATH' ) )
16 exit;
17
18 class Gutenberg {
19
20 public function __construct() {
21 if ( ! function_exists('register_block_type')){
22 return;
23 }
24
25 add_action( 'init', array($this, 'register_blocks') );
26 add_filter('block_categories', array($this, 'registering_new_block_category'), 10, 2);
27
28 add_action('wp_ajax_render_block_tutor', array($this, 'render_block_tutor'));
29 }
30
31 function register_blocks() {
32 wp_register_script(
33 'tutor-student-registration-block', tutor()->url . 'assets/js/gutenberg_blocks.js', array( 'wp-blocks', 'wp-element' )
34 );
35
36 register_block_type( 'tutor-gutenberg/student-registration', array(
37 'editor_script' => 'tutor-student-registration-block',
38 'render_callback' => array($this, 'render_block_student_registration'),
39 ) );
40 register_block_type( 'tutor-gutenberg/student-dashboard', array(
41 'editor_script' => 'tutor-student-registration-block',
42 'render_callback' => array($this, 'render_block_tutor_dashboard'),
43 ) );
44 register_block_type( 'tutor-gutenberg/instructor-registration', array(
45 'editor_script' => 'tutor-student-registration-block',
46 'render_callback' => array($this, 'render_block_tutor_instructor_registration_form'),
47 ) );
48 }
49
50 public function registering_new_block_category($categories, $post ){
51 return array_merge(
52 array(
53 array(
54 'slug' => 'tutor',
55 'title' => __( 'Tutor LMS', 'tutor' ),
56 ),
57 ),
58 $categories
59 );
60 }
61
62 public function render_block_student_registration($args){
63 return do_shortcode("[tutor_student_registration_form]");
64 }
65 public function render_block_tutor_dashboard($args){
66 return do_shortcode("[tutor_dashboard]");
67 }
68 public function render_block_tutor_instructor_registration_form($args){
69 return do_shortcode("[tutor_instructor_registration_form]");
70 }
71
72 //For editor
73 public function render_block_tutor(){
74 $shortcode = sanitize_text_field($_POST['shortcode']);
75 wp_send_json_success(do_shortcode("[{$shortcode}]"));
76 }
77
78 }