PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.8
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.8
4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 4.2.0 All 139 releases
learnpress / inc / Shortcodes / class-lp-shortcode-become-a-teacher.php

class-lp-shortcode-become-a-teacher.php in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.4.8, at inc/Shortcodes/class-lp-shortcode-become-a-teacher.php

109 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Become A Teacher Shortcode.
4 *
5 * @author ThimPress
6 * @category Shortcodes
7 * @package Learnpress/Shortcodes
8 * @version 4.0.0
9 * @extends LP_Abstract_Shortcode
10 */
11
12 defined( 'ABSPATH' ) || exit();
13
14 if ( ! class_exists( 'LP_Shortcode_Become_A_Teacher' ) ) {
15 class LP_Shortcode_Become_A_Teacher extends LP_Abstract_Shortcode {
16
17 /**
18 * @var array
19 */
20 protected static $messages = array();
21
22 /**
23 * LP_Checkout_Shortcode constructor.
24 *
25 * @param mixed $atts
26 */
27 public function __construct( $atts = '' ) {
28 parent::__construct( $atts );
29 }
30
31 /**
32 * Add new message into queue.
33 *
34 * @param $message
35 * @param string $code
36 */
37 public static function add_message( $message, $code = '' ) {
38 self::$messages[ $code ] = $message;
39 }
40
41 /**
42 * Get added message by code from queue.
43 *
44 * @param string $code
45 *
46 * @return bool|mixed
47 */
48 public static function get_message( $code = '' ) {
49 return isset( self::$messages[ $code ] ) ? self::$messages[ $code ] : false;
50 }
51
52 /**
53 * Get all messages added into queue.
54 *
55 * @return array
56 */
57 public static function get_messages() {
58 return self::$messages;
59 }
60
61 /**
62 * Output form.
63 *
64 * @return string
65 */
66 public function output() {
67 wp_enqueue_style( 'learnpress' );
68 ob_start();
69
70 $message = '';
71 $atts = $this->get_atts();
72 $user = learn_press_get_current_user( false );
73
74 if ( ! $user || $user instanceof LP_User_Guest ) {
75 $message = sprintf( esc_html__( 'Please %s to send your request!', 'learnpress' ), sprintf( '<strong><a href="%s">%s</a></strong>', learn_press_get_login_url(), _x( 'login', 'become-teacher-form', 'learnpress' ) ) );
76 } else {
77 if ( learn_press_become_teacher_sent() ) {
78 $message = esc_html__( 'You have already sent the request. Please wait for the approval.', 'learnpress' );
79 } elseif ( learn_press_user_maybe_is_a_teacher() ) {
80 $message = esc_html__( 'You are a teacher!', 'learnpress' );
81 }
82 }
83
84 if ( apply_filters( 'learn_press_become_a_teacher_display_form', true, $message ) ) {
85 $atts = shortcode_atts(
86 array(
87 'title' => esc_html__( 'Become a Teacher', 'learnpress' ),
88 'description' => esc_html__( 'Fill in your information and send it to us to become a teacher.', 'learnpress' ),
89 'submit_button_text' => esc_html__( 'Submit', 'learnpress' ),
90 'submit_button_process_text' => esc_html__( 'Processing', 'learnpress' ),
91 ),
92 $atts
93 );
94
95 wp_enqueue_style( 'learnpress' );
96 wp_enqueue_script( 'lp-become-a-teacher' );
97
98 if ( empty( $message ) || ( class_exists( '\Elementor\Plugin' ) && \Elementor\Plugin::$instance->editor->is_edit_mode() ) ) {
99 learn_press_get_template( 'global/become-teacher-form.php', $atts );
100 } else {
101 learn_press_display_message( $message );
102 }
103 }
104
105 return ob_get_clean();
106 }
107 }
108 }
109