PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.1.6.9.3
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.1.6.9.3
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 / admin / settings / class-lp-settings-emails.php

class-lp-settings-emails.php in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.1.6.9.3, at inc/admin/settings/class-lp-settings-emails.php

219 lines 5.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Class LP_Settings_Emails
4 *
5 * @author ThimPress
6 * @package LearnPress/Classes
7 * @version 4.0.0
8 */
9
10 defined( 'ABSPATH' ) || exit;
11
12 require_once 'email-groups/class-lp-settings-emails-group.php';
13
14 class LP_Settings_Emails extends LP_Abstract_Settings_Page {
15 /**
16 * @var null
17 */
18 protected static $_instance = null;
19
20 /**
21 * Constructor
22 */
23 public function __construct() {
24 $this->id = 'emails';
25 $this->text = esc_html__( 'Emails', 'learnpress' );
26
27 parent::__construct();
28
29 add_filter( 'learn-press/admin/submenu-section-title', array( $this, 'custom_section_title' ), 10, 2 );
30 }
31
32 /**
33 * Add tooltip to section title
34 *
35 * @param string $title
36 * @param string $slug
37 *
38 * @return string
39 */
40 public function custom_section_title( $title, $slug ) {
41 $sections = $this->get_sections();
42
43 if ( ! empty( $sections[ $slug ] ) && $sections[ $slug ] instanceof LP_Email ) {
44 if ( $sections[ $slug ]->description ) {
45 $title = $title . sprintf( '<span class="learn-press-tooltip" data-tooltip="%s"></span>', esc_attr( $sections[ $slug ]->description ) );
46 }
47 }
48
49 return $title;
50 }
51
52 /**
53 * Sections
54 *
55 * @return mixed
56 */
57 public function get_sections() {
58 static $sections = false;
59
60 if ( ! $sections ) {
61 $emails = LP_Emails::instance()->emails;
62
63 $sections = array(
64 'general' => esc_html__( 'General', 'learnpress' ),
65 );
66
67 if ( $emails ) {
68 $groups = array(
69 include 'email-groups/class-lp-settings-new-order-emails.php',
70 include 'email-groups/class-lp-settings-processing-order-emails.php',
71 include 'email-groups/class-lp-settings-completed-order-emails.php',
72 include 'email-groups/class-lp-settings-cancelled-order-emails.php',
73 include 'email-groups/class-lp-settings-enrolled-course-emails.php',
74 include 'email-groups/class-lp-settings-finished-course-emails.php',
75 include 'email-groups/class-lp-settings-become-teacher-emails.php',
76 include 'email-groups/class-lp-settings-reset-password-emails.php',
77 );
78
79 $groups = apply_filters( 'learn-press/email-section-classes', $groups );
80
81 foreach ( $groups as $group ) {
82 $sections[ $group->group_id ] = $group;
83 }
84
85 foreach ( $emails as $email ) {
86 if ( ! is_object( $email ) ) {
87 continue;
88 }
89
90 foreach ( $groups as $group ) {
91 if ( is_object( $group ) && ! empty( $group->items[ $email->id ] ) ) {
92 continue 2;
93 }
94 }
95
96 if ( isset( $sections[ $email->id ] ) ) {
97 $sections[ $email->id ] = $email;
98 }
99 }
100 }
101 }
102
103 return apply_filters( 'learn-press/settings/section/' . $this->id, $sections );
104 }
105
106 /**
107 * Settings fields of general section.
108 *
109 * @return mixed
110 */
111 public function get_settings_general() {
112 return apply_filters(
113 'learn-press/emails-settings/general',
114 array(
115 array(
116 'title' => esc_html__( 'Email sender options', 'learnpress' ),
117 'type' => 'title',
118 'desc' => esc_html__( 'For all outgoing LearnPress notification emails.', 'learnpress' ),
119 ),
120 array(
121 'title' => esc_html__( '"From" name', 'learnpress' ),
122 'id' => 'emails_general[from_name]',
123 'default' => get_option( 'blogname' ),
124 'type' => 'text',
125 'css' => 'width:400px',
126 ),
127 array(
128 'type' => 'sectionend',
129 ),
130 array(
131 'title' => esc_html__( 'Email template', 'learnpress' ),
132 'type' => 'title',
133 'desc' => esc_html__( 'This section lets you customize the LearnPress emails', 'learnpress' ),
134 ),
135 array(
136 'title' => esc_html__( 'Content type', 'learnpress' ),
137 'id' => 'emails_general[default_email_content]',
138 'default' => 'html',
139 'type' => 'select',
140 'options' => array(
141 'plain' => esc_html__( 'Plain Text', 'learnpress' ),
142 'html' => esc_html__( 'HTML', 'learnpress' ),
143 ),
144 ),
145 array(
146 'title' => esc_html__( 'Header image', 'learnpress' ),
147 'id' => 'emails_general[header_image]',
148 'default' => '',
149 'type' => 'image',
150 ),
151 array(
152 'title' => esc_html__( 'Footer text', 'learnpress' ),
153 'id' => 'emails_general[footer_text]',
154 'default' => esc_html__( 'LearnPress', 'learnpress' ),
155 'type' => 'textarea',
156 ),
157 array(
158 'title' => esc_html__( 'Emails', 'learnpress' ),
159 'id' => 'emails_general[list_emails]',
160 'default' => '',
161 'type' => 'list-emails',
162 ),
163 array(
164 'type' => 'sectionend',
165 ),
166 )
167 );
168 }
169
170 /**
171 * Display admin page for payments settings tab.
172 *
173 * @param string $section
174 * @param string $tab
175 * @version 4.0.0
176 */
177 public function admin_page_settings( $section = null, $tab = null ) {
178 $sections = array();
179 $items = LP_Admin_Menu::instance()->get_menu_items();
180
181 if ( ! empty( $items['settings'] ) ) {
182 $tab = $items['settings']->get_active_tab();
183 $section = $items['settings']->get_active_section();
184 $sections = $items['settings']->get_sections();
185 }
186 $section_data = ! empty( $sections[ $section ] ) ? $sections[ $section ] : false;
187
188 if ( $section_data instanceof LP_Email ) {
189 $section_data->admin_option_settings();
190 } else {
191 if ( is_callable( array( $this, 'admin_options_' . $section ) ) ) {
192 call_user_func_array( array( $this, 'admin_options_' . $section ), array( $section, $tab ) );
193 } else {
194 do_action( 'learn-press/admin/setting-payments/admin-options-' . $section, $tab );
195 }
196 }
197 }
198
199 /**
200 * Output admin option of general page.
201 *
202 * @param string $section
203 * @param string $tab
204 */
205 public function admin_options_general( $section, $tab ) {
206 parent::admin_page_settings( $section, $tab );
207 }
208
209 public static function instance() {
210 if ( ! self::$_instance ) {
211 self::$_instance = new self();
212 }
213
214 return self::$_instance;
215 }
216 }
217
218 return LP_Settings_Emails::instance();
219