PluginProbe
Selection Lite / 1.12
Selection Lite v1.12
trunk 1.0 1.1 1.10 1.11 1.12 1.14 1.15 1.16 1.17 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9
selection-lite / src / Merkulove / Unity / Tab.php

Tab.php in Selection Lite 1.12, at src/Merkulove/Unity/Tab.php

154 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Selection Lite
4 * Carefully selected Elementor addons bundle, for building the most awesome websites
5 *
6 * @encoding UTF-8
7 * @version 1.12
8 * @copyright (C) 2018-2024 Merkulove ( https://merkulov.design/ ). All rights reserved.
9 * @license GPLv3
10 * @contributors merkulove, vladcherviakov, phoenixmkua, podolianochka, viktorialev01
11 * @support help@merkulov.design
12 **/
13
14 namespace Merkulove\SelectionLite\Unity;
15
16 /** Exit if accessed directly. */
17 if ( ! defined( 'ABSPATH' ) ) {
18 header( 'Status: 403 Forbidden' );
19 header( 'HTTP/1.1 403 Forbidden' );
20 exit;
21 }
22
23 /**
24 * Base methods for Tabs Classes.
25 *
26 * @since 1.0
27 *
28 **/
29 abstract class Tab {
30
31 /**
32 * Check if tab exist and enabled.
33 *
34 * @param string $tab_slug - Slug of tub to check.
35 *
36 * @since 1.0
37 * @access protected
38 *
39 * @return bool - True if Tab is enabled, false otherwise.
40 **/
41 protected function is_enabled( $tab_slug = null ) {
42
43 /** Foolproof. */
44 if ( null === $tab_slug ) { return false; }
45
46 /** Get all tabs and settings. */
47 $tabs = Plugin::get_tabs();
48
49 /** Check if status tab exist. */
50 if ( ! isset( $tabs[ $tab_slug ] ) ) { return false; }
51
52 /** Check if 'enabled' field of status tab exist. */
53 if ( ! isset( $tabs[ $tab_slug ][ 'enabled' ] ) ) { return false; }
54
55 /** Check if status tab is enabled. */
56 return true === $tabs[ $tab_slug ][ 'enabled' ];
57
58 }
59
60 /**
61 * Render tab title.
62 *
63 * @param string $tab_slug - Slug of tub to check.
64 *
65 * @since 1.0
66 * @access protected
67 *
68 * @return void
69 **/
70 protected function render_title( $tab_slug = null ) {
71
72 /** Foolproof. */
73 if ( null === $tab_slug ) { return; }
74
75 /** Get all tabs and settings. */
76 $tabs = Plugin::get_tabs();
77
78 /** Get selected to process tab. */
79 $tab = $tabs[ $tab_slug ];
80
81 /** If title enabled. */
82 if ( true === $tab[ 'show_title' ] ) {
83
84 /** Render Title. */
85 echo '<h3>' . esc_html( $tab[ 'title' ] ) . '</h3>';
86
87 }
88
89 }
90
91 /**
92 * Output nonce, action, and option_page fields for a settings page.
93 * Prints out all settings sections added to a particular settings page
94 *
95 * @param string $tab_slug - Slug of tub to check.
96 *
97 * @since 1.0
98 * @access protected
99 *
100 * @return void
101 **/
102 protected function do_settings_base( $tab_slug = null ) {
103
104 /** Foolproof. */
105 if ( null === $tab_slug ) { return; }
106
107 settings_fields( 'SelectionLite' . $tab_slug . 'OptionsGroup' );
108 do_settings_sections( 'SelectionLite' . $tab_slug. 'OptionsGroup' );
109
110 }
111
112 /**
113 * Registers a setting and its data.
114 * Add a new section to a settings page.
115 *
116 * @param string $tab_slug - Slug of tub to check.
117 *
118 * @since 1.0
119 * @access protected
120 *
121 * @return void
122 **/
123 protected function add_settings_base( $tab_slug = null ) {
124
125 /** Foolproof. */
126 if ( null === $tab_slug ) { return; }
127
128 /** Status Tab. */
129 register_setting( 'SelectionLite' . $tab_slug . 'OptionsGroup', 'mdp_selection_lite_' . $tab_slug . '_settings' );
130 add_settings_section( 'mdp_selection_lite_' . $tab_slug . '_page_status_section', '', null, 'SelectionLite' . $tab_slug . 'OptionsGroup' );
131
132 }
133
134 /**
135 * Check if tab is enabled by tab slug.
136 *
137 * @param string $tab_slug - Tab slug.
138 *
139 * @since 1.0
140 * @access private
141 *
142 * @return bool
143 **/
144 public static function is_tab_enabled( $tab_slug ) {
145
146 /** Get all tabs and settings. */
147 $tabs = Plugin::get_tabs();
148
149 return isset( $tabs[ $tab_slug ][ 'enabled' ] ) && $tabs[ $tab_slug ][ 'enabled' ];
150
151 }
152
153 }
154