PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.3.7
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.3.7
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-payments.php

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

165 lines 4.4 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_Payment
4 *
5 * @author ThimPress
6 * @package LearnPress/Admin/Classes
7 * @version 4.0.0
8 */
9
10 defined( 'ABSPATH' ) || exit;
11
12 /**
13 * Class LP_Settings_Payments
14 *
15 * Manage all payments are registered and settings to control order process.
16 *
17 */
18 class LP_Settings_Payments extends LP_Abstract_Settings_Page {
19 /**
20 * Constructor
21 */
22 public function __construct() {
23 $this->id = 'payments';
24 $this->text = esc_html__( 'Payments', 'learnpress' );
25
26 parent::__construct();
27
28 add_filter( 'learn-press/admin/submenu-section-title', array( $this, 'custom_section_title' ), 10, 2 );
29 }
30
31 public function custom_section_title( $title, $slug ) {
32 $sections = $this->get_sections();
33
34 if ( ! empty( $sections[ $slug ] ) && $sections[ $slug ] instanceof LP_Gateway_Abstract ) {
35 $title = $title . sprintf( '<span class="learn-press-tooltip" data-tooltip="%s"></span>', esc_attr( $sections[ $slug ]->get_method_description() ) );
36 }
37
38 return $title;
39 }
40
41 /**
42 * Get sections.
43 * Add a general section and each registered payment is a section.
44 *
45 * @return mixed
46 */
47 public function get_sections() {
48 static $sections;
49 if ( is_null( $sections ) ) {
50 $gateways = LP_Gateways::instance()->get_gateways();
51 $sections = array(
52 'general' => esc_html__( 'General', 'learnpress' ),
53 );
54
55 if ( $gateways ) {
56 foreach ( $gateways as $id => $gateway ) {
57 $sections[ $id ] = $gateway;
58 }
59 }
60 }
61
62 return $sections;
63 }
64
65 /**
66 * Settings fields of general section.
67 *
68 * @return mixed
69 */
70 public function get_settings_general() {
71 $checkout_url = learn_press_get_checkout_url();
72
73 $guest = apply_filters(
74 'learn-press/payment-settings/general',
75 array(
76 array(
77 'type' => 'title',
78 ),
79 array(
80 'title' => esc_html__( 'Guest checkout', 'learnpress' ),
81 'id' => 'guest_checkout',
82 'default' => 'no',
83 'type' => 'checkbox',
84 'desc' => esc_html__( 'Enable guest checkout.', 'learnpress' ),
85 ),
86 array(
87 'title' => esc_html__( 'Account login', 'learnpress' ),
88 'id' => 'enable_login_checkout',
89 'default' => 'yes',
90 'type' => 'checkbox',
91 'desc' => esc_html__( 'Enable the login form in the checkout.', 'learnpress' ),
92 ),
93 array(
94 'title' => esc_html__( 'Account creation', 'learnpress' ),
95 'id' => 'enable_registration_checkout',
96 'default' => 'yes',
97 'type' => 'checkbox',
98 'desc' => esc_html__( 'Enable the register form in the checkout.', 'learnpress' ),
99 ),
100 )
101 );
102
103 $enpoints = apply_filters(
104 'learn-press/payment-settings/checkout-endpoints',
105 array(
106 array(
107 'title' => esc_html__( 'Custom order slug', 'learnpress' ),
108 'id' => 'checkout_endpoints[lp_order_received]',
109 'default' => 'lp-order-received',
110 'placeholder' => 'lp-order-received',
111 'type' => 'text',
112 'desc' => sprintf( 'e.g. %s', "{$checkout_url}<code>" . LP_Settings::instance()->get( 'checkout_endpoints.lp_order_received', 'lp-order-received' ) . '</code>' ),
113 ),
114 )
115 );
116
117 $payment = array(
118 array(
119 'title' => esc_html__( 'Payments', 'learnpress' ),
120 'id' => 'payment_order',
121 'default' => '',
122 'type' => 'payment-order',
123 ),
124 array(
125 'type' => 'sectionend',
126 ),
127 );
128
129 return apply_filters( 'learn-press/payment-settings', array_merge( $guest, $enpoints, $payment ) );
130 }
131
132 public function admin_page_settings( $section = null, $tab = null ) {
133 $sections = array();
134 $items = LP_Admin_Menu::instance()->get_menu_items();
135
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();
140 }
141
142 $section_data = ! empty( $sections[ $section ] ) ? $sections[ $section ] : false;
143
144 if ( $section_data instanceof LP_Abstract_Settings ) {
145 $section_data->admin_option_settings();
146 } elseif ( is_callable( array( $this, 'admin_options_' . $section ) ) ) {
147 call_user_func_array( array( $this, 'admin_options_' . $section ), array( $section, $tab ) );
148 } else {
149 do_action( 'learn-press/admin/setting-payments/admin-options-' . $section, $tab );
150 }
151 }
152
153 /**
154 * Output admin option of general page.
155 *
156 * @param string $section
157 * @param string $tab
158 */
159 public function admin_options_general( $section, $tab ) {
160 parent::admin_page_settings( $section, $tab );
161 }
162 }
163
164 return new LP_Settings_Payments();
165