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

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