PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.1.7.2
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.1.7.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 / email-groups / class-lp-settings-emails-group.php

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

102 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Class LP_Settings_Emails_Group
5 *
6 * @since 3.0.0
7 */
8 class LP_Settings_Emails_Group extends LP_Settings {
9
10 /**
11 * Items
12 *
13 * @var array
14 */
15 public $items = array();
16
17 /**
18 * @var string
19 */
20 public $group_id = '';
21
22 /**
23 * LP_Settings_Emails_Group constructor.
24 */
25 public function __construct() {
26 parent::__construct();
27
28 $emails = LP_Emails::instance()->emails;
29
30 $ids = array_fill_keys( $this->items, '' );
31
32 foreach ( $this->items as $id ) {
33 foreach ( $emails as $email ) {
34 if ( ! is_object( $email ) ) {
35 continue;
36 }
37
38 if ( ! array_key_exists( $email->id, $ids ) ) {
39 continue;
40 }
41 $email->group = $this;
42 $ids[ $email->id ] = $email;
43 }
44 }
45
46 $this->items = $ids;
47
48 add_action( 'learn-press/admin/setting-payments/admin-options-' . $this->group_id, array( $this, 'output_settings' ) );
49 add_filter( 'learn-press/admin/get-settings/admin-options-' . $this->group_id, array( $this, 'filter_get_settings' ) );
50 }
51
52 public function output_settings() {
53 $current = $this->get_current_section();
54
55 echo '<ul class="subsubsub">';
56
57 foreach ( $this->items as $email ) {
58 if ( ! is_object( $email ) ) {
59 continue;
60 }
61 if ( $current == $email->id ) {
62 echo '<li class="active"><span>' . wp_kses_post( $email->title ) . '</span></li>';
63 } else {
64 echo '<li><a href="' . esc_url_raw( add_query_arg( 'sub-section', $email->id ) ) . '">' . wp_kses_post( $email->title ) . '</a></li>';
65 }
66 }
67
68 echo '</ul>';
69
70 if ( ! empty( $this->items[ $current ] ) ) {
71 $this->items[ $current ]->admin_option_settings(); // Email content show in here <nhamdv> LP_Abstract_Settings.
72 }
73 }
74
75 /**
76 * Filter save setting.
77 *
78 * @return array list setting Email.
79 * @version 4.0.0
80 * @author Nhamdv
81 */
82 public function filter_get_settings() {
83 $current = $this->get_current_section();
84
85 if ( ! empty( $this->items[ $current ] ) ) {
86 return $this->items[ $current ]->get_settings();
87 }
88 }
89
90 public function get_current_section() {
91 $ids = array_keys( $this->items );
92
93 return ! empty( $_REQUEST['sub-section'] ) ? sanitize_text_field( $_REQUEST['sub-section'] ) : reset( $ids );
94 }
95
96 public function __toString() {
97 $name = str_replace( array( 'LP_Settings_', '_' ), array( '', ' ' ), get_class( $this ) );
98
99 return (string) $name;
100 }
101 }
102