PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.10
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.10
4.4.10 4.4.9.1 4.4.9 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 All 142 releases
← All changes | inc/emails/admin/class-lp-email-become-an-instructor.php +130 -105 4.3.8 → 4.4.10 View file →
@@ -1,105 +1,130 @@
1 -<?php
2 -/**
3 - * Class LP_Email_Become_An_Instructor
4 - *
5 - * @author ThimPress
6 - * @package LearnPress/Classes
7 - * @version 3.0.1
8 - * @author tungnx
9 - * @modify 4.1.3
10 - */
11 -
12 -/**
13 - * Prevent loading this file directly
14 - */
15 -defined( 'ABSPATH' ) || exit();
16 -
17 -if ( ! class_exists( 'LP_Email_Become_An_Instructor' ) ) {
18 - class LP_Email_Become_An_Instructor extends LP_Email {
19 - /**
20 - * LP_Email_Become_An_Instructor constructor.
21 - */
22 - public function __construct() {
23 - $this->id = 'become-an-instructor';
24 - $this->title = __( 'Request', 'learnpress' );
25 - $this->description = __( 'Become an instructor email.', 'learnpress' );
26 -
27 - $this->default_subject = __( '[{{site_title}}] Request to become an instructor', 'learnpress' );
28 - $this->default_heading = __( 'Become an instructor', 'learnpress' );
29 -
30 - parent::__construct();
31 -
32 - $variable_on_email_support = apply_filters(
33 - 'lp/email/become-an-instructor/variables-support',
34 - [
35 - '{{request_email}}',
36 - '{{request_phone}}',
37 - '{{request_message}}',
38 - '{{admin_user_manager}}',
39 - '{{accept_url}}',
40 - '{{deny_url}}',
41 - ]
42 - );
43 -
44 - $this->support_variables = array_merge( $this->support_variables, $variable_on_email_support );
45 - }
46 -
47 - /**
48 - * Check email enable option
49 - * Check param valid: 4 params: bat_name, bat_email, bat_phone, bat_message
50 - * Set values
51 - *
52 - * @param array $params
53 - * @throws Exception
54 - */
55 - public function handle( array $params ) {
56 - if ( ! $this->enable ) {
57 - return;
58 - }
59 -
60 - if ( count( $params ) < 1 ) {
61 - return;
62 - }
63 -
64 - if ( ! $this->set_data_content( $params[0] ) ) {
65 - return;
66 - }
67 - $this->set_receive( $this->_get_admin_email() );
68 - $this->send_email();
69 - }
70 -
71 - /**
72 - * Set data content
73 - */
74 - protected function set_data_content( $params ): bool {
75 - $bat_email = $params['bat_email'] ?? '';
76 - $bat_phone = $params['bat_phone'] ?? '';
77 - $bat_message = $params['bat_message'] ?? '';
78 -
79 - $user = get_user_by( 'email', $bat_email );
80 - if ( ! $user ) {
81 - return false;
82 - }
83 -
84 - $this->variables = apply_filters(
85 - 'lp/email/type-become-an-instructor-admin/variables-mapper',
86 - [
87 - '{{request_email}}' => $bat_email,
88 - '{{request_phone}}' => $bat_phone,
89 - '{{request_message}}' => $bat_message,
90 - '{{admin_user_manager}}' => admin_url( 'users.php?lp-action=pending-request' ),
91 - '{{accept_url}}' => admin_url( 'users.php?lp-action=accept-request&user_id=' . $user->ID ),
92 - '{{deny_url}}' => admin_url( 'users.php?lp-action=deny-request&user_id=' . $user->ID ),
93 - ]
94 - );
95 -
96 - $variables_common = $this->get_common_variables( $this->email_format );
97 - $this->variables = array_merge( $this->variables, $variables_common );
98 -
99 - return true;
100 - }
101 - }
102 -
103 - return new LP_Email_Become_An_Instructor();
104 -}
105 -
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 +}