PluginProbe
RT Mega Menu – Mega Menu Builder for Elementor & Gutenberg / trunk
RT Mega Menu – Mega Menu Builder for Elementor & Gutenberg vtrunk
1.5.3 1.5.2 1.5.1 1.5.0 1.4.8 1.4.9 1.4.7 1.4.6 1.4.5 trunk 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 All 47 releases
rt-mega-menu / admin / includes / admin-settings.php

admin-settings.php in RT Mega Menu – Mega Menu Builder for Elementor & Gutenberg trunk, at admin/includes/admin-settings.php

290 lines 14.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
3 if ( ! class_exists('RTMEGA_MENU_admin_settings')) {
4 class RTMEGA_MENU_admin_settings {
5
6 private $rtmega_menu_options;
7
8 function __construct(){
9
10 add_action( 'admin_menu', [$this, 'rtmega_menu_register'] );
11 add_action( 'admin_init', [$this, 'rtmega_menu_settings'] );
12
13 }
14
15 public function rtmega_menu_register (){
16 add_menu_page(
17 __('RT Mega Menu', 'rt-mega-menu'),
18 __('RT Mega Menu', 'rt-mega-menu'),
19 'manage_options',
20 'rt-mega-menu',
21 array($this, 'rtmega_menu_plugin_page'),
22 'dashicons-editor-kitchensink',
23 100
24 );
25 }
26
27
28
29 public function rtmega_menu_settings() {
30
31 register_setting(
32 'rtmega_menu_options_group', // option_group
33 'rtmega_menu_options', // option_name
34 array(
35 'sanitize_callback' => array($this, 'rtmega_menu_options_sanitize')
36 )
37 );
38
39 add_settings_section(
40 'rtmega_menu_setting_section', // id
41 '', // title
42 array( $this, 'rtmega_menu_settings_section' ), // callback
43 'rtmega-menu-settings' // page
44 );
45
46 add_settings_field(
47
48 'rt_mega_menu_width', // id
49
50 'Width', // title
51
52 array( $this, 'rtmega_render_menu_opts' ), // callback
53
54 'rtmega-menu-settings', // page
55
56 'rtmega_menu_setting_section' // section
57
58 );
59
60 }
61
62 function rtmega_menu_options_sanitize( $input ) {
63 $output = array();
64
65 if ( ! empty( $input ) && is_array( $input ) ) {
66 foreach ( $input as $key => $value ) {
67
68 $safe_key = sanitize_key( $key );
69
70 if ( is_array( $value ) ) {
71 // nested array ecursive sanitize
72 $output[ $safe_key ] = array_map( 'sanitize_text_field', $value );
73 } else {
74 $output[ $safe_key ] = sanitize_text_field( $value );
75 }
76 }
77 }
78
79 return $output;
80 }
81
82
83 public function rtmega_get_settings_fields() {
84
85 $rtmega_settings_fields = array();
86
87 $style_fields = array(
88 array(
89 'id' => 'menu_sections_start',
90 'name' => 'menu_sections_start',
91 'type' => 'section_start',
92 'label' => 'Main Menu:',
93 ),
94 array(
95 'id' => 'menu_color',
96 'name' => 'menu_color',
97 'type' => 'wpcolor',
98 'label' => 'Menu Color',
99 ),
100 array(
101 'id' => 'menu_hover_color',
102 'name' => 'menu_hover_color',
103 'type' => 'wpcolor',
104 'label' => 'Menu Hover Color',
105 ),
106 array(
107 'id' => 'menu_active_color',
108 'name' => 'menu_active_color',
109 'type' => 'wpcolor',
110 'label' => 'Menu Active Color',
111 ),
112 array(
113 'id' => 'submenu_sections_start',
114 'name' => 'submenu_sections_start',
115 'type' => 'section_start',
116 'label' => 'Sub Menu:',
117 ),
118 array(
119 'id' => 'submenu_color',
120 'name' => 'submenu_color',
121 'type' => 'wpcolor',
122 'label' => 'Menu Color',
123 ),
124 array(
125 'id' => 'submenu_hover_color',
126 'name' => 'submenu_hover_color',
127 'type' => 'wpcolor',
128 'label' => 'Menu Hover Color',
129 ),
130 array(
131 'id' => 'submenu_bg_color',
132 'name' => 'submenu_bg_color',
133 'type' => 'wpcolor',
134 'label' => 'Menu Background Color',
135 ),
136 array(
137 'id' => 'submenu_width',
138 'name' => 'submenu_width',
139 'type' => 'text',
140 'label' => 'Menu Width',
141 ),
142
143 );
144
145 $rtmega_settings_fields['style_fields'] = $style_fields;
146 return $rtmega_settings_fields;
147
148 }
149
150 public function rtmega_menu_plugin_page (){
151
152 $this->rtmega_menu_options = get_option( 'rtmega_menu_options' ); ?>
153 <h1><?php echo esc_html__( 'RTMEGA Menu Settings', 'rt-mega-menu' ); ?></h1>
154 <?php settings_errors(); ?>
155 <div class="">
156 <form method="POST" action="options.php">
157 <div class="tabs rtmega-menu-settings-tabs">
158 <ul id="tabs-nav">
159 <li><a href="#tab1"><?php echo esc_html__( 'Mega Menu Styles', 'rt-mega-menu' ); ?></a></li>
160 <li><a href="#tab2"><?php echo esc_html__( 'Pro Features', 'rt-mega-menu' ); ?></a></li>
161 <?php do_action( 'rtmega_after_settings_tab_nav_item' ); ?>
162 </ul> <!-- END tabs-nav -->
163 <div class="tab-contents-wrapper">
164 <div id="tab1" class="tab-content" style="display: none;">
165 <?php
166 settings_fields( 'rtmega_menu_options_group' );
167 do_settings_sections( 'rtmega-menu-settings' );
168 submit_button();
169 ?>
170 </div>
171 <div id="tab2" class="tab-content" style="display: none;">
172 <h1><?php echo esc_html__( 'RT Menu Free Vs RT Menu Pro Features', 'rt-mega-menu' ); ?></h1>
173 <div class="rtmega-features-list-wrapper">
174 <div class="rtmega-features-list rtmega-features-list-free">
175 <h3><?php echo esc_html__( 'RT Menu Free', 'rt-mega-menu' ); ?></h3>
176 <ul>
177 <li><span class="dashicons dashicons-yes"></span><?php echo esc_html__( 'Menu Template Option.', 'rt-mega-menu' ); ?></li>
178 <li><span class="dashicons dashicons-yes"></span><?php echo esc_html__( 'Individual Menu Width Control Option.', 'rt-mega-menu' ); ?></li>
179 <li><span class="dashicons dashicons-yes"></span><?php echo esc_html__( 'Sub Menu Position.', 'rt-mega-menu' ); ?></li>
180 <li><span class="dashicons dashicons-no"></span><?php echo esc_html__( 'Menu Icon Picker.', 'rt-mega-menu' ); ?></li>
181 <li><span class="dashicons dashicons-no"></span><?php echo esc_html__( 'Menu Icon Color.', 'rt-mega-menu' ); ?></li>
182 <li><span class="dashicons dashicons-no"></span><?php echo esc_html__( 'Menu Badge.', 'rt-mega-menu' ); ?></li>
183 <li><span class="dashicons dashicons-no"></span><?php echo esc_html__( 'Menu Badge Color.', 'rt-mega-menu' ); ?></li>
184 <li><span class="dashicons dashicons-no"></span><?php echo esc_html__( 'Menu Badge Background Color.', 'rt-mega-menu' ); ?></li>
185 <li><span class="dashicons dashicons-no"></span><?php echo esc_html__( 'User-based menu item visibility controls.', 'rt-mega-menu' ); ?></li>
186 <li><span class="dashicons dashicons-no"></span><?php echo esc_html__( 'Location-based menu item visibility controls.', 'rt-mega-menu' ); ?></li>
187 <li><span class="dashicons dashicons-no"></span><?php echo esc_html__( 'Device-based menu item visibility controls.', 'rt-mega-menu' ); ?></li>
188 <li><span class="dashicons dashicons-no"></span><?php echo esc_html__( 'WooCommerce customer visibility rules (Logged-in status, Purchase history, and Cart contents)', 'rt-mega-menu' ); ?></li>
189 </ul>
190 </div>
191 <div class="rtmega-features-list rtmega-features-list-free">
192 <h3><?php echo esc_html__( 'RT Menu Pro', 'rt-mega-menu' ); ?></h3>
193 <ul>
194 <li><span class="dashicons dashicons-yes"></span><?php echo esc_html__( 'Menu Template Option.', 'rt-mega-menu' ); ?></li>
195 <li><span class="dashicons dashicons-yes"></span><?php echo esc_html__( 'Individual Menu Width Control Option.', 'rt-mega-menu' ); ?></li>
196 <li><span class="dashicons dashicons-yes"></span><?php echo esc_html__( 'Sub Menu Position.', 'rt-mega-menu' ); ?></li>
197 <li><span class="dashicons dashicons-yes"></span><?php echo esc_html__( 'Menu Icon Picker.', 'rt-mega-menu' ); ?></li>
198 <li><span class="dashicons dashicons-yes"></span><?php echo esc_html__( 'Menu Icon Color.', 'rt-mega-menu' ); ?></li>
199 <li><span class="dashicons dashicons-yes"></span><?php echo esc_html__( 'Menu Badge.', 'rt-mega-menu' ); ?></li>
200 <li><span class="dashicons dashicons-yes"></span><?php echo esc_html__( 'Menu Badge Color.', 'rt-mega-menu' ); ?></li>
201 <li><span class="dashicons dashicons-yes"></span><?php echo esc_html__( 'Menu Badge Background Color.', 'rt-mega-menu' ); ?></li>
202 <li><span class="dashicons dashicons-yes"></span><?php echo esc_html__( 'User-based menu item visibility controls.', 'rt-mega-menu' ); ?></li>
203 <li><span class="dashicons dashicons-yes"></span><?php echo esc_html__( 'Location-based menu item visibility controls.', 'rt-mega-menu' ); ?></li>
204 <li><span class="dashicons dashicons-yes"></span><?php echo esc_html__( 'Device-based menu item visibility controls.', 'rt-mega-menu' ); ?></li>
205 <li><span class="dashicons dashicons-yes"></span><?php echo esc_html__( 'WooCommerce customer visibility rules (Logged-in status, Purchase history, and Cart contents)', 'rt-mega-menu' ); ?></li>
206 </ul>
207 </div>
208
209 </div>
210 <a href="https://rtmega.themewant.com" target="_blank" class="button button-primary"><?php echo esc_html__( 'Buy Now', 'rt-mega-menu' ); ?></a>
211 </div>
212 <?php do_action( 'rtmega_after_settings_tab_content' ); ?>
213 </div>
214 </div> <!-- END tabs -->
215
216 </form>
217 </div>
218 <script>
219 (function($){
220
221 $(document).ready(function () {
222
223 // Show the first tab and hide the rest
224 $('#tabs-nav li:first-child').addClass('active');
225 $('.tab-content').hide();
226 $('.tab-content:first').show();
227
228 // Click function
229 $('#tabs-nav li').click(function(){
230 $('#tabs-nav li').removeClass('active');
231 $(this).addClass('active');
232 $('.tab-content').hide();
233
234 var activeTab = $(this).find('a').attr('href');
235 $(activeTab).fadeIn();
236 return false;
237 });
238
239 $('input[type="wpcolor"]').wpColorPicker();
240
241
242
243 });
244
245 })(jQuery);
246 </script>
247
248 <?php
249 }
250
251
252 public function rtmega_menu_settings_section (){
253
254 }
255
256 public function rtmega_render_menu_opts() {
257
258 $rtmega_settings_fields = $this->rtmega_get_settings_fields();
259
260
261
262 foreach ($rtmega_settings_fields['style_fields'] as $field) {
263 if($field['type'] == 'section_start'){
264 ?>
265 <h3 class="settings-section"><?php echo esc_html($field['label']) ?></h3>
266 <?php
267 }else{
268
269 $val = '';
270 if( isset( $this->rtmega_menu_options[$field['name']]) ){
271 $val = $this->rtmega_menu_options[$field['name']];
272 }else if(isset($field['default'])){
273 $val = $field['default'];
274 }
275
276
277 printf(
278 '<div class="settings-item"><label>'. esc_html($field['label']) .'</label>
279 <input type="'. esc_html($field['type']).'" name="rtmega_menu_options['. esc_html($field['name']) .']" id="rtmega_render_menu_opts" value="%s"></div>',esc_html($val)
280 );
281 }
282
283 }
284
285 }
286
287 }
288
289 new RTMEGA_MENU_admin_settings();
290 }