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

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

220 lines 5.8 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;
59 if ( is_null( $sections ) ) {
60 $emails = LP_Emails::instance()->emails;
61
62 $sections = array(
63 'general' => esc_html__( 'General', 'learnpress' ),
64 );
65
66 if ( $emails ) {
67 $groups = array(
68 include 'email-groups/class-lp-settings-new-order-emails.php',
69 include 'email-groups/class-lp-settings-processing-order-emails.php',
70 include 'email-groups/class-lp-settings-completed-order-emails.php',
71 include 'email-groups/class-lp-settings-cancelled-order-emails.php',
72 include 'email-groups/class-lp-settings-refunded-order-emails.php',
73 include 'email-groups/class-lp-settings-refund-request-order-emails.php',
74 include 'email-groups/class-lp-settings-enrolled-course-emails.php',
75 include 'email-groups/class-lp-settings-finished-course-emails.php',
76 include 'email-groups/class-lp-settings-become-teacher-emails.php',
77 include 'email-groups/class-lp-settings-reset-password-emails.php',
78 );
79
80 $groups = apply_filters( 'learn-press/email-section-classes', $groups );
81
82 foreach ( $groups as $group ) {
83 $sections[ $group->group_id ] = $group;
84 }
85
86 foreach ( $emails as $email ) {
87 if ( ! is_object( $email ) ) {
88 continue;
89 }
90
91 foreach ( $groups as $group ) {
92 if ( is_object( $group ) && ! empty( $group->items[ $email->id ] ) ) {
93 continue 2;
94 }
95 }
96
97 if ( isset( $sections[ $email->id ] ) ) {
98 $sections[ $email->id ] = $email;
99 }
100 }
101 }
102 }
103
104 return apply_filters( 'learn-press/settings/section/' . $this->id, $sections );
105 }
106
107 /**
108 * Settings fields of general section.
109 *
110 * @return mixed
111 */
112 public function get_settings_general() {
113 return apply_filters(
114 'learn-press/emails-settings/general',
115 array(
116 array(
117 'title' => esc_html__( 'Email sender options', 'learnpress' ),
118 'type' => 'title',
119 'desc' => esc_html__( 'For all outgoing LearnPress notification emails.', 'learnpress' ),
120 ),
121 array(
122 'title' => esc_html__( '"From" name', 'learnpress' ),
123 'id' => 'emails_general[from_name]',
124 'default' => get_option( 'blogname' ),
125 'type' => 'text',
126 'css' => 'width:400px',
127 ),
128 array(
129 'type' => 'sectionend',
130 ),
131 array(
132 'title' => esc_html__( 'Email template', 'learnpress' ),
133 'type' => 'title',
134 'desc' => esc_html__( 'This section lets you customize the LearnPress emails', 'learnpress' ),
135 ),
136 /*array(
137 'title' => esc_html__( 'Content type', 'learnpress' ),
138 'id' => 'emails_general[default_email_content]',
139 'default' => 'html',
140 'type' => 'select',
141 'options' => array(
142 'plain' => esc_html__( 'Plain Text', 'learnpress' ),
143 'html' => esc_html__( 'HTML', 'learnpress' ),
144 ),
145 ),*/
146 array(
147 'title' => esc_html__( 'Header image', 'learnpress' ),
148 'id' => 'emails_general[header_image]',
149 'default' => '',
150 'type' => 'image',
151 ),
152 array(
153 'title' => esc_html__( 'Footer text', 'learnpress' ),
154 'id' => 'emails_general[footer_text]',
155 'default' => esc_html__( 'LearnPress', 'learnpress' ),
156 'type' => 'textarea',
157 ),
158 array(
159 'title' => esc_html__( 'Emails', 'learnpress' ),
160 'id' => 'emails_general[list_emails]',
161 'default' => '',
162 'type' => 'list-emails',
163 ),
164 array(
165 'type' => 'sectionend',
166 ),
167 )
168 );
169 }
170
171 /**
172 * Display admin page for payments settings tab.
173 *
174 * @param string $section
175 * @param string $tab
176 * @version 4.0.0
177 */
178 public function admin_page_settings( $section = null, $tab = null ) {
179 $sections = array();
180 $items = LP_Admin_Menu::instance()->get_menu_items();
181
182 if ( ! empty( $items['settings'] ) ) {
183 $tab = $items['settings']->get_active_tab();
184 $section = $items['settings']->get_active_section();
185 $sections = $items['settings']->get_sections();
186 }
187 $section_data = ! empty( $sections[ $section ] ) ? $sections[ $section ] : false;
188
189 if ( $section_data instanceof LP_Email ) {
190 $section_data->admin_option_settings();
191 } else {
192 if ( is_callable( array( $this, 'admin_options_' . $section ) ) ) {
193 call_user_func_array( array( $this, 'admin_options_' . $section ), array( $section, $tab ) );
194 } else {
195 do_action( 'learn-press/admin/setting-payments/admin-options-' . $section, $tab );
196 }
197 }
198 }
199
200 /**
201 * Output admin option of general page.
202 *
203 * @param string $section
204 * @param string $tab
205 */
206 public function admin_options_general( $section, $tab ) {
207 parent::admin_page_settings( $section, $tab );
208 }
209
210 public static function instance() {
211 if ( ! self::$_instance ) {
212 self::$_instance = new self();
213 }
214
215 return self::$_instance;
216 }
217 }
218
219 return LP_Settings_Emails::instance();
220