PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.6
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.6
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 / emails / admin / class-lp-email-become-an-instructor.php

class-lp-email-become-an-instructor.php in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.4.6, at inc/emails/admin/class-lp-email-become-an-instructor.php

131 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Class LP_Email_Become_An_Instructor
4 *
5 * @author ThimPress
6 * @package LearnPress/Classes
7 * @version 3.0.2
8 * @modify 4.1.3
9 */
10
11 /**
12 * Prevent loading this file directly
13 */
14 defined( 'ABSPATH' ) || exit();
15
16 if ( ! class_exists( 'LP_Email_Become_An_Instructor' ) ) {
17 class LP_Email_Become_An_Instructor extends LP_Email {
18 /**
19 * LP_Email_Become_An_Instructor constructor.
20 */
21 public function __construct() {
22 $this->id = 'become-an-instructor';
23 $this->title = __( 'Request', 'learnpress' );
24 $this->description = __( 'Become an instructor email.', 'learnpress' );
25
26 $this->default_subject = __( '[{{site_title}}] Request to become an instructor', 'learnpress' );
27 $this->default_heading = __( 'Become an instructor', 'learnpress' );
28
29 parent::__construct();
30
31 $variable_on_email_support = apply_filters(
32 'lp/email/become-an-instructor/variables-support',
33 [
34 '{{request_email}}',
35 '{{request_phone}}',
36 '{{request_message}}',
37 '{{admin_user_manager}}',
38 '{{accept_url}}',
39 '{{deny_url}}',
40 ]
41 );
42
43 $this->support_variables = array_merge( $this->support_variables, $variable_on_email_support );
44 }
45
46 /**
47 * Check email enable option
48 * Check param valid: 4 params: bat_name, bat_email, bat_phone, bat_message
49 * Set values
50 *
51 * @param array $params
52 * @throws Exception
53 */
54 public function handle( array $params ) {
55 if ( ! $this->enable ) {
56 return;
57 }
58
59 if ( count( $params ) < 1 ) {
60 return;
61 }
62
63 if ( ! $this->set_data_content( $params[0] ) ) {
64 return;
65 }
66 $this->set_receive( $this->_get_admin_email() );
67 $this->send_email();
68 }
69
70 /**
71 * Set data content
72 */
73 protected function set_data_content( $params ): bool {
74 $bat_email = $params['bat_email'] ?? '';
75 $bat_phone = $params['bat_phone'] ?? '';
76 $bat_message = $params['bat_message'] ?? '';
77
78 $user = get_user_by( 'email', $bat_email );
79 if ( ! $user ) {
80 return false;
81 }
82
83 $content_format = $this->get_content_format();
84 $is_html = 'text/plain' !== $content_format;
85
86 $admin_user_manager = admin_url( 'users.php?lp-action=pending-request' );
87 $accept_url = admin_url( 'users.php?lp-action=accept-request&user_id=' . $user->ID );
88 $deny_url = admin_url( 'users.php?lp-action=deny-request&user_id=' . $user->ID );
89
90 if ( $is_html ) {
91 $admin_user_manager = sprintf(
92 '<a href="%s">%s</a>',
93 esc_url( $admin_user_manager ),
94 esc_url( $admin_user_manager )
95 );
96
97 $accept_url = sprintf(
98 '<a href="%s">%s</a>',
99 esc_url( $accept_url ),
100 esc_url( $accept_url )
101 );
102
103 $deny_url = sprintf(
104 '<a href="%s">%s</a>',
105 esc_url( $deny_url ),
106 esc_url( $deny_url )
107 );
108 }
109
110 $this->variables = apply_filters(
111 'lp/email/type-become-an-instructor-admin/variables-mapper',
112 [
113 '{{request_email}}' => $bat_email,
114 '{{request_phone}}' => $bat_phone,
115 '{{request_message}}' => $bat_message,
116 '{{admin_user_manager}}' => $admin_user_manager,
117 '{{accept_url}}' => $accept_url,
118 '{{deny_url}}' => $deny_url,
119 ]
120 );
121
122 $variables_common = $this->get_common_variables( $this->email_format );
123 $this->variables = array_merge( $this->variables, $variables_common );
124
125 return true;
126 }
127 }
128
129 return new LP_Email_Become_An_Instructor();
130 }
131