| 1 |
<?php |
| 2 |
/** |
| 3 |
* Template for displaying email notifications step. |
| 4 |
* |
| 5 |
* @author ThimPress |
| 6 |
* @package LearnPress/Admin/Views |
| 7 |
* @version 4.0.0 |
| 8 |
*/ |
| 9 |
|
| 10 |
use LearnPress\TemplateHooks\Admin\AdminTemplate; |
| 11 |
|
| 12 |
defined( 'ABSPATH' ) || exit; |
| 13 |
|
| 14 |
$email_notifications = array( |
| 15 |
array( |
| 16 |
'name' => __( 'New Order Email', 'learnpress' ), |
| 17 |
'description' => __( 'Sent to admin & instructor when a new order is placed.', 'learnpress' ), |
| 18 |
'key' => 'new_order', |
| 19 |
'email_ids' => array( 'new-order-admin', 'new-order-instructor' ), |
| 20 |
), |
| 21 |
array( |
| 22 |
'name' => __( 'Order Completed Email', 'learnpress' ), |
| 23 |
'description' => __( 'Sent to student when payment is confirmed.', 'learnpress' ), |
| 24 |
'key' => 'order_completed', |
| 25 |
'email_ids' => array( 'completed-order-user' ), |
| 26 |
), |
| 27 |
array( |
| 28 |
'name' => __( 'Course Enrolled Email', 'learnpress' ), |
| 29 |
'description' => __( 'Sent to student when enrolled into a course.', 'learnpress' ), |
| 30 |
'key' => 'course_enrolled', |
| 31 |
'email_ids' => array( 'enrolled-course-user' ), |
| 32 |
), |
| 33 |
array( |
| 34 |
'name' => __( 'Course Completed Email', 'learnpress' ), |
| 35 |
'description' => __( 'Sent to student upon finishing a course.', 'learnpress' ), |
| 36 |
'key' => 'course_completed', |
| 37 |
'email_ids' => array( 'finished-course-user' ), |
| 38 |
), |
| 39 |
array( |
| 40 |
'name' => __( 'Become Instructor Request', 'learnpress' ), |
| 41 |
'description' => __( 'Sent to admin when a user applies to become a teacher.', 'learnpress' ), |
| 42 |
'key' => 'become_instructor_request', |
| 43 |
'email_ids' => array( 'become-an-instructor' ), |
| 44 |
), |
| 45 |
array( |
| 46 |
'name' => __( 'Become Instructor Accepted', 'learnpress' ), |
| 47 |
'description' => __( 'Sent to applicant when approved.', 'learnpress' ), |
| 48 |
'key' => 'become_instructor_accepted', |
| 49 |
'email_ids' => array( 'instructor-accepted' ), |
| 50 |
), |
| 51 |
); |
| 52 |
|
| 53 |
$enabled_notifications = 0; |
| 54 |
foreach ( $email_notifications as &$email_notification ) { |
| 55 |
$email_notification['enabled'] = true; |
| 56 |
foreach ( $email_notification['email_ids'] as $email_id ) { |
| 57 |
$email = LP_Emails::get_email( $email_id ); |
| 58 |
if ( ! $email || ! $email->enable() ) { |
| 59 |
$email_notification['enabled'] = false; |
| 60 |
break; |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
if ( $email_notification['enabled'] ) { |
| 65 |
++$enabled_notifications; |
| 66 |
} |
| 67 |
} |
| 68 |
unset( $email_notification ); |
| 69 |
|
| 70 |
$has_enabled_notifications = $enabled_notifications === count( $email_notifications ); |
| 71 |
?> |
| 72 |
|
| 73 |
<div class="lp-setup-emails"> |
| 74 |
<div class="lp-setup-section-header"> |
| 75 |
<h2><?php esc_html_e( 'Step 4: Email Notifications', 'learnpress' ); ?></h2> |
| 76 |
|
| 77 |
<p> |
| 78 |
<?php esc_html_e( |
| 79 |
'Configure automated email notifications sent to students and instructors.', |
| 80 |
'learnpress' |
| 81 |
); ?> |
| 82 |
</p> |
| 83 |
</div> |
| 84 |
|
| 85 |
<div class="lp-setup-emails__master lp-setup-card"> |
| 86 |
<div class="lp-setup-emails__master-content"> |
| 87 |
<span class="lp-setup-emails__mail-icon lp-icon-envelope-o" aria-hidden="true"></span> |
| 88 |
|
| 89 |
<strong> |
| 90 |
<?php esc_html_e( 'Enable All Email Notifications', 'learnpress' ); ?> |
| 91 |
</strong> |
| 92 |
</div> |
| 93 |
|
| 94 |
<span class="screen-reader-text"><?php esc_html_e( 'Enable all email notifications', 'learnpress' ); ?></span> |
| 95 |
<?php echo AdminTemplate::html_toggle_enable( array( 'name' => 'email_notifications_master', 'value' => $has_enabled_notifications, 'classes' => 'lp-setup-email-master' ) ); ?> |
| 96 |
</div> |
| 97 |
|
| 98 |
<div class="lp-setup-emails__table-wrap lp-setup-card"> |
| 99 |
<table class="lp-setup-emails__table"> |
| 100 |
<thead> |
| 101 |
<tr> |
| 102 |
<th> |
| 103 |
<?php esc_html_e( 'Email Notification Type', 'learnpress' ); ?> |
| 104 |
</th> |
| 105 |
|
| 106 |
<th> |
| 107 |
<?php esc_html_e( 'Description', 'learnpress' ); ?> |
| 108 |
</th> |
| 109 |
|
| 110 |
<th> |
| 111 |
<?php esc_html_e( 'Status', 'learnpress' ); ?> |
| 112 |
</th> |
| 113 |
</tr> |
| 114 |
</thead> |
| 115 |
|
| 116 |
<tbody> |
| 117 |
<?php foreach ( $email_notifications as $email ) : ?> |
| 118 |
<tr> |
| 119 |
<td class="lp-setup-emails__name"> |
| 120 |
<?php echo esc_html( $email['name'] ); ?> |
| 121 |
</td> |
| 122 |
|
| 123 |
<td class="lp-setup-emails__description"> |
| 124 |
<?php echo esc_html( $email['description'] ); ?> |
| 125 |
</td> |
| 126 |
|
| 127 |
<td class="lp-setup-emails__status"> |
| 128 |
<span class="screen-reader-text"><?php echo esc_html( sprintf( __( 'Enable %s', 'learnpress' ), $email['name'] ) ); ?></span> |
| 129 |
<?php echo AdminTemplate::html_toggle_enable( array( 'name' => sprintf( 'settings[emails][notifications][%s]', $email['key'] ), 'value' => $email['enabled'], 'classes' => 'lp-setup-email-notification' ) ); ?> |
| 130 |
</td> |
| 131 |
</tr> |
| 132 |
<?php endforeach; ?> |
| 133 |
</tbody> |
| 134 |
</table> |
| 135 |
</div> |
| 136 |
</div> |
| 137 |
|