PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.9
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.9
4.4.9 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 All 140 releases
← All changes | inc/admin/settings/class-lp-settings-payments.php +46 -8 4.3.7 → 4.4.9 View file →
@@ -6,8 +6,11 @@
6 6 * @package LearnPress/Admin/Classes
7 7 * @version 4.0.0
8 8 */
9 9
10 +use LearnPress\Helpers\Config;
11 +use LearnPress\TemplateHooks\Admin\AdminSettingsPage;
12 +
10 13 defined( 'ABSPATH' ) || exit;
11 14
12 15 /**
13 16 * Class LP_Settings_Payments
@@ -12,9 +15,8 @@
12 15 /**
13 16 * Class LP_Settings_Payments
14 17 *
15 18 * Manage all payments are registered and settings to control order process.
16 - *
17 19 */
18 20 class LP_Settings_Payments extends LP_Abstract_Settings_Page {
19 21 /**
20 22 * Constructor
@@ -49,8 +51,9 @@
49 51 if ( is_null( $sections ) ) {
50 52 $gateways = LP_Gateways::instance()->get_gateways();
51 53 $sections = array(
52 54 'general' => esc_html__( 'General', 'learnpress' ),
55 + 'refund' => esc_html__( 'Refund', 'learnpress' ),
53 56 );
54 57
55 58 if ( $gateways ) {
56 59 foreach ( $gateways as $id => $gateway ) {
@@ -128,18 +131,43 @@
128 131
129 132 return apply_filters( 'learn-press/payment-settings', array_merge( $guest, $enpoints, $payment ) );
130 133 }
131 134
132 - public function admin_page_settings( $section = null, $tab = null ) {
133 - $sections = array();
134 - $items = LP_Admin_Menu::instance()->get_menu_items();
135 + /**
136 + * Settings fields of refund section.
137 + *
138 + * @return array
139 + */
140 + public function get_settings_refund() {
141 + return Config::instance()->get( 'refund', 'settings/payments' );
142 + }
135 143
136 - if ( ! empty( $items['settings'] ) ) {
137 - $tab = $items['settings']->get_active_tab();
138 - $section = $items['settings']->get_active_section();
139 - $sections = $items['settings']->get_sections();
144 + /**
145 + * Keep refund option names compatible with the former general settings fields.
146 + *
147 + * @param string $name Field name.
148 + *
149 + * @return mixed
150 + */
151 + public function get_admin_field_name( $name ) {
152 + $tab = AdminSettingsPage::instance()->get_active_tab();
153 + $section = AdminSettingsPage::instance()->get_active_section();
154 +
155 + if ( 'payments' === $tab && 'refund' === $section ) {
156 + if ( empty( $name ) ) {
157 + $name = md5( microtime( true ) );
158 + }
159 +
160 + return apply_filters( 'learn_press_settings_field_name_' . $name, "learn_press_{$name}" );
140 161 }
141 162
163 + return parent::get_admin_field_name( $name );
164 + }
165 +
166 + public function admin_page_settings( $section = null, $tab = null ) {
167 + $tab = AdminSettingsPage::instance()->get_active_tab();
168 + $section = AdminSettingsPage::instance()->get_active_section();
169 + $sections = AdminSettingsPage::instance()->get_sections();
142 170 $section_data = ! empty( $sections[ $section ] ) ? $sections[ $section ] : false;
143 171
144 172 if ( $section_data instanceof LP_Abstract_Settings ) {
145 173 $section_data->admin_option_settings();
@@ -156,8 +184,18 @@
156 184 * @param string $section
157 185 * @param string $tab
158 186 */
159 187 public function admin_options_general( $section, $tab ) {
188 + parent::admin_page_settings( $section, $tab );
189 + }
190 +
191 + /**
192 + * Output admin option of refund page.
193 + *
194 + * @param string $section
195 + * @param string $tab
196 + */
197 + public function admin_options_refund( $section, $tab ) {
160 198 parent::admin_page_settings( $section, $tab );
161 199 }
162 200 }
163 201