PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.1.6.9.2
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.1.6.9.2
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.1.6.9.2, at inc/background-process/class-lp-background-single-email.php

66 lines 1.3 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 WP_Async_Request {
15 protected $prefix = 'lp';
16 protected $action = 'background_single_email';
17 protected static $instance;
18
19 /**
20 * Method async handle
21 */
22 protected function handle() {
23 $params = $_POST['params'] ?? false;
24 $class_name = $_POST['class_name'] ?? false;
25
26 if ( ! $class_name || ! $params ) {
27 error_log( 'Params send email on background is invalid' );
28
29 return;
30 }
31
32 if ( ! class_exists( $class_name ) ) {
33 error_log( 'Class not exists: ' . $class_name );
34
35 return;
36 }
37
38 if ( ! method_exists( $class_name, 'handle' ) ) {
39 error_log( "Method 'handle' not exists on class $class_name" );
40
41 return;
42 }
43
44 /**
45 * @var LP_Email_Type_Enrolled_Course $email
46 */
47 $email = new $class_name;
48 $email->handle( $params );
49 }
50
51 /**
52 * @return LP_Background_Single_Email
53 */
54 public static function instance(): self {
55 if ( is_null( self::$instance ) ) {
56 self::$instance = new self();
57 }
58
59 return self::$instance;
60 }
61 }
62
63 // Must run instance to register ajax.
64 LP_Background_Single_Email::instance();
65 }
66