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 / background-process / class-lp-background-single-email.php

class-lp-background-single-email.php in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.4.8, at inc/background-process/class-lp-background-single-email.php

65 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Send emails in background
4 */
5 defined( 'ABSPATH' ) || exit;
6
7 if ( ! class_exists( 'LP_Background_Single_Email' ) ) {
8 /**
9 * Class LP_Background_Single_Email
10 *
11 * @since 4.1.1
12 * @author tungnx
13 */
14 class LP_Background_Single_Email extends LP_Async_Request {
15 protected $action = 'background_single_email';
16 protected static $instance;
17
18 /**
19 * Method async handle
20 */
21 protected function handle() {
22 $params = LP_Helper::sanitize_params_submitted( $_POST['params'] ?? false );
23 $class_name = LP_Helper::sanitize_params_submitted( $_POST['class_name'] ?? false );
24
25 if ( ! $class_name || ! $params ) {
26 error_log( 'Params send email on background is invalid' );
27
28 return;
29 }
30
31 if ( ! class_exists( $class_name ) ) {
32 error_log( 'Class not exists: ' . $class_name );
33
34 return;
35 }
36
37 if ( ! method_exists( $class_name, 'handle' ) ) {
38 error_log( "Method 'handle' not exists on class $class_name" );
39
40 return;
41 }
42
43 /**
44 * @var LP_Email_Type_Enrolled_Course $email
45 */
46 $email = new $class_name();
47 $email->handle( $params );
48 }
49
50 /**
51 * @return LP_Background_Single_Email
52 */
53 public static function instance(): self {
54 if ( is_null( self::$instance ) ) {
55 self::$instance = new self();
56 }
57
58 return self::$instance;
59 }
60 }
61
62 // Must run instance to register ajax.
63 LP_Background_Single_Email::instance();
64 }
65