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

166 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
50 if ( ! $sections ) {
51 $gateways = LP_Gateways::instance()->get_gateways();
52 $sections = array(
53 'general' => esc_html__( 'General', 'learnpress' ),
54 );
55
56 if ( $gateways ) {
57 foreach ( $gateways as $id => $gateway ) {
58 $sections[ $id ] = $gateway;
59 }
60 }
61 }
62
63 return $sections;
64 }
65
66 /**
67 * Settings fields of general section.
68 *
69 * @return mixed
70 */
71 public function get_settings_general() {
72 $checkout_url = learn_press_get_checkout_url();
73
74 $guest = apply_filters(
75 'learn-press/payment-settings/general',
76 array(
77 array(
78 'type' => 'title',
79 ),
80 array(
81 'title' => esc_html__( 'Guest checkout', 'learnpress' ),
82 'id' => 'guest_checkout',
83 'default' => 'no',
84 'type' => 'checkbox',
85 'desc' => esc_html__( 'Enable guest checkout', 'learnpress' ),
86 ),
87 array(
88 'title' => esc_html__( 'Account login', 'learnpress' ),
89 'id' => 'enable_login_checkout',
90 'default' => 'yes',
91 'type' => 'checkbox',
92 'desc' => esc_html__( 'Enable login form in checkout', 'learnpress' ),
93 ),
94 array(
95 'title' => esc_html__( 'Account creation', 'learnpress' ),
96 'id' => 'enable_registration_checkout',
97 'default' => 'yes',
98 'type' => 'checkbox',
99 'desc' => esc_html__( 'Enable register form in checkout', 'learnpress' ),
100 ),
101 )
102 );
103
104 $enpoints = apply_filters(
105 'learn-press/payment-settings/checkout-endpoints',
106 array(
107 array(
108 'title' => esc_html__( 'Custom order slug', 'learnpress' ),
109 'id' => 'checkout_endpoints[lp_order_received]',
110 'default' => 'lp-order-received',
111 'placeholder' => 'lp-order-received',
112 'type' => 'text',
113 'desc' => sprintf( 'e.g. %s', "{$checkout_url}<code>" . LP_Settings::instance()->get( 'checkout_endpoints.lp_order_received', 'lp-order-received' ) . '</code>' ),
114 ),
115 )
116 );
117
118 $payment = array(
119 array(
120 'title' => esc_html__( 'Payments', 'learnpress' ),
121 'id' => 'payment_order',
122 'default' => '',
123 'type' => 'payment-order',
124 ),
125 array(
126 'type' => 'sectionend',
127 ),
128 );
129
130 return apply_filters( 'learn-press/payment-settings', array_merge( $guest, $enpoints, $payment ) );
131 }
132
133 public function admin_page_settings( $section = null, $tab = null ) {
134 $sections = array();
135 $items = LP_Admin_Menu::instance()->get_menu_items();
136
137 if ( ! empty( $items['settings'] ) ) {
138 $tab = $items['settings']->get_active_tab();
139 $section = $items['settings']->get_active_section();
140 $sections = $items['settings']->get_sections();
141 }
142
143 $section_data = ! empty( $sections[ $section ] ) ? $sections[ $section ] : false;
144
145 if ( $section_data instanceof LP_Abstract_Settings ) {
146 $section_data->admin_option_settings();
147 } elseif ( is_callable( array( $this, 'admin_options_' . $section ) ) ) {
148 call_user_func_array( array( $this, 'admin_options_' . $section ), array( $section, $tab ) );
149 } else {
150 do_action( 'learn-press/admin/setting-payments/admin-options-' . $section, $tab );
151 }
152 }
153
154 /**
155 * Output admin option of general page.
156 *
157 * @param string $section
158 * @param string $tab
159 */
160 public function admin_options_general( $section, $tab ) {
161 parent::admin_page_settings( $section, $tab );
162 }
163 }
164
165 return new LP_Settings_Payments();
166