PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.8
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.8
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 / settings / abstract-settings-page.php

abstract-settings-page.php in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.4.8, at inc/settings/abstract-settings-page.php

134 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Class LP_Abstract_Settings_Page
4 *
5 * @author ThimPress
6 * @package LearnPress/Classes
7 * @version 1.0
8 */
9
10 defined( 'ABSPATH' ) || exit;
11
12 class LP_Abstract_Settings_Page extends LP_Abstract_Settings {
13
14 /**
15 * Tab's ID
16 *
17 * @var string
18 */
19 public $id = '';
20
21 /**
22 * Tab's text
23 *
24 * @var string
25 */
26 public $text = '';
27
28 /**
29 * Constructor
30 */
31 public function __construct() {
32 parent::__construct();
33 }
34
35 /**
36 * Display admin page in LP4.
37 *
38 * @param string $section
39 * @param string $tab
40 * @version 4.0.0
41 */
42 public function admin_page_settings( $section = null, $tab = '' ) {
43 //wp_enqueue_style( 'select2' );
44 $settings = $this->get_settings( $section, $tab );
45 $settings = $this->sanitize_settings( $settings );
46
47 do_action( 'learn-press/settings-render' );
48
49 if ( $settings ) {
50 LP_Meta_Box_Helper::output_fields( $settings );
51 } else {
52 echo esc_html__( 'No settings available.', 'learnpress' );
53 }
54 }
55
56 /**
57 * Save option in LP4.
58 *
59 * @param string $section
60 * @param string $tab
61 * @version 4.0.0
62 */
63 public function save_settings( $section = null, $tab = '' ) {
64 $settings = apply_filters( 'learn-press/admin/get-settings/admin-options-' . $section, $this->get_settings( $section, $tab ) );
65 $settings = $this->sanitize_settings( $settings );
66
67 if ( $settings ) {
68 LP_Meta_Box_Helper::save_fields( $settings, $_POST );
69 }
70
71 if ( 'paypal' === $section ) {
72 // Delete token for case switch live and sandbox
73 delete_option( 'learn_press_' . LP_Gateway_Paypal::PAYPAL_TOKEN );
74 }
75 }
76
77 /**
78 * Get name for field
79 *
80 * @param $name
81 *
82 * @return mixed
83 */
84 public function get_field_name( $name ) {
85 $field_name = apply_filters( 'learn_press_settings_field_name_' . $name, "learn_press_{$name}" );
86
87 return $field_name;
88 }
89
90 /**
91 * Get ID for field
92 *
93 * @param $name
94 *
95 * @return mixed
96 */
97 public function get_field_id( $name ) {
98 return preg_replace( array( '!\[|(\]\[)!', '!\]!' ), array( '_', '' ), $this->get_field_name( $name ) );
99 }
100
101 public function get_sections() {
102 return array();
103 }
104
105 /**
106 * @param string $section
107 * @param string $tab
108 *
109 * @return bool|mixed
110 */
111 public function get_settings( $section = '', $tab = '' ) {
112 if ( ! $section ) {
113 $section = $this->get_sections();
114 $section = array_keys( $section );
115 }
116
117 settype( $section, 'array' );
118
119 $return = array();
120
121 foreach ( $section as $sec ) {
122 if ( is_callable( array( $this, 'get_settings_' . $sec ) ) ) {
123 $settings = call_user_func( array( $this, 'get_settings_' . $sec ) );
124
125 if ( $settings ) {
126 $return = array_merge( $return, $settings );
127 }
128 }
129 }
130
131 return $return;
132 }
133 }
134