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

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

128 lines 2.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_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 $settings = $this->get_settings( $section, $tab );
44 $settings = $this->sanitize_settings( $settings );
45
46 do_action( 'learn-press/settings-render' );
47
48 if ( $settings ) {
49 LP_Meta_Box_Helper::output_fields( $settings );
50 } else {
51 echo esc_html__( 'No settings available.', 'learnpress' );
52 }
53 }
54
55 /**
56 * Save option in LP4.
57 *
58 * @param string $section
59 * @param string $tab
60 * @version 4.0.0
61 */
62 public function save_settings( $section = null, $tab = '' ) {
63 $settings = apply_filters( 'learn-press/admin/get-settings/admin-options-' . $section, $this->get_settings( $section, $tab ) );
64 $settings = $this->sanitize_settings( $settings );
65
66 if ( $settings ) {
67 LP_Meta_Box_Helper::save_fields( $settings );
68 }
69 }
70
71 /**
72 * Get name for field
73 *
74 * @param $name
75 *
76 * @return mixed
77 */
78 public function get_field_name( $name ) {
79 $field_name = apply_filters( 'learn_press_settings_field_name_' . $name, "learn_press_{$name}" );
80
81 return $field_name;
82 }
83
84 /**
85 * Get ID for field
86 *
87 * @param $name
88 *
89 * @return mixed
90 */
91 public function get_field_id( $name ) {
92 return preg_replace( array( '!\[|(\]\[)!', '!\]!' ), array( '_', '' ), $this->get_field_name( $name ) );
93 }
94
95 public function get_sections() {
96 return array();
97 }
98
99 /**
100 * @param string $section
101 * @param string $tab
102 *
103 * @return bool|mixed
104 */
105 public function get_settings( $section = '', $tab = '' ) {
106 if ( ! $section ) {
107 $section = $this->get_sections();
108 $section = array_keys( $section );
109 }
110
111 settype( $section, 'array' );
112
113 $return = array();
114
115 foreach ( $section as $sec ) {
116 if ( is_callable( array( $this, 'get_settings_' . $sec ) ) ) {
117 $settings = call_user_func( array( $this, 'get_settings_' . $sec ) );
118
119 if ( $settings ) {
120 $return = array_merge( $return, $settings );
121 }
122 }
123 }
124
125 return $return;
126 }
127 }
128