Addons.php
6 years ago
Admin.php
6 years ago
Ajax.php
6 years ago
Assets.php
6 years ago
Course.php
6 years ago
Course_Settings_Tabs.php
6 years ago
Course_Widget.php
6 years ago
Dashboard.php
6 years ago
Email.php
6 years ago
FormHandler.php
6 years ago
Gutenberg.php
6 years ago
Instructor.php
6 years ago
Instructors_List.php
6 years ago
Lesson.php
6 years ago
Options.php
6 years ago
Post_types.php
6 years ago
Q_and_A.php
6 years ago
Question_Answers_List.php
6 years ago
Quiz.php
6 years ago
Quiz_Attempts_List.php
6 years ago
RestAPI.php
6 years ago
Rewrite_Rules.php
6 years ago
Shortcode.php
6 years ago
Student.php
6 years ago
Students_List.php
6 years ago
Taxonomies.php
6 years ago
Template.php
6 years ago
Theme_Compatibility.php
6 years ago
Tools.php
6 years ago
Tutor.php
6 years ago
TutorEDD.php
6 years ago
Tutor_Base.php
6 years ago
Tutor_List_Table.php
6 years ago
Upgrader.php
6 years ago
User.php
6 years ago
Utils.php
6 years ago
Video_Stream.php
6 years ago
Withdraw.php
6 years ago
Withdraw_Requests_List.php
6 years ago
WooCommerce.php
6 years ago
Gutenberg.php
78 lines
| 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 | add_action('wp_ajax_render_block_tutor', array($this, 'render_block_tutor')); |
| 28 | } |
| 29 | |
| 30 | function register_blocks() { |
| 31 | wp_register_script( |
| 32 | 'tutor-student-registration-block', tutor()->url . 'assets/js/gutenberg_blocks.js', array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-components', 'wp-editor' ) |
| 33 | ); |
| 34 | |
| 35 | register_block_type( 'tutor-gutenberg/student-registration', array( |
| 36 | 'editor_script' => 'tutor-student-registration-block', |
| 37 | 'render_callback' => array($this, 'render_block_student_registration'), |
| 38 | ) ); |
| 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 | } |