PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.3.9.1
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.3.9.1
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.3.9.1, at inc/settings/abstract-settings-page.php

129 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
72 /**
73 * Get name for field
74 *
75 * @param $name
76 *
77 * @return mixed
78 */
79 public function get_field_name( $name ) {
80 $field_name = apply_filters( 'learn_press_settings_field_name_' . $name, "learn_press_{$name}" );
81
82 return $field_name;
83 }
84
85 /**
86 * Get ID for field
87 *
88 * @param $name
89 *
90 * @return mixed
91 */
92 public function get_field_id( $name ) {
93 return preg_replace( array( '!\[|(\]\[)!', '!\]!' ), array( '_', '' ), $this->get_field_name( $name ) );
94 }
95
96 public function get_sections() {
97 return array();
98 }
99
100 /**
101 * @param string $section
102 * @param string $tab
103 *
104 * @return bool|mixed
105 */
106 public function get_settings( $section = '', $tab = '' ) {
107 if ( ! $section ) {
108 $section = $this->get_sections();
109 $section = array_keys( $section );
110 }
111
112 settype( $section, 'array' );
113
114 $return = array();
115
116 foreach ( $section as $sec ) {
117 if ( is_callable( array( $this, 'get_settings_' . $sec ) ) ) {
118 $settings = call_user_func( array( $this, 'get_settings_' . $sec ) );
119
120 if ( $settings ) {
121 $return = array_merge( $return, $settings );
122 }
123 }
124 }
125
126 return $return;
127 }
128 }
129