array($this, 'rtmega_menu_options_sanitize') ) ); add_settings_section( 'rtmega_menu_setting_section', // id '', // title array( $this, 'rtmega_menu_settings_section' ), // callback 'rtmega-menu-settings' // page ); add_settings_field( 'rt_mega_menu_width', // id 'Width', // title array( $this, 'rtmega_render_menu_opts' ), // callback 'rtmega-menu-settings', // page 'rtmega_menu_setting_section' // section ); } function rtmega_menu_options_sanitize( $input ) { $output = array(); if ( ! empty( $input ) && is_array( $input ) ) { foreach ( $input as $key => $value ) { $safe_key = sanitize_key( $key ); if ( is_array( $value ) ) { // nested array ecursive sanitize $output[ $safe_key ] = array_map( 'sanitize_text_field', $value ); } else { $output[ $safe_key ] = sanitize_text_field( $value ); } } } return $output; } public function rtmega_get_settings_fields() { $rtmega_settings_fields = array(); $style_fields = array( array( 'id' => 'menu_sections_start', 'name' => 'menu_sections_start', 'type' => 'section_start', 'label' => 'Main Menu:', ), array( 'id' => 'menu_color', 'name' => 'menu_color', 'type' => 'wpcolor', 'label' => 'Menu Color', ), array( 'id' => 'menu_hover_color', 'name' => 'menu_hover_color', 'type' => 'wpcolor', 'label' => 'Menu Hover Color', ), array( 'id' => 'menu_active_color', 'name' => 'menu_active_color', 'type' => 'wpcolor', 'label' => 'Menu Active Color', ), array( 'id' => 'submenu_sections_start', 'name' => 'submenu_sections_start', 'type' => 'section_start', 'label' => 'Sub Menu:', ), array( 'id' => 'submenu_color', 'name' => 'submenu_color', 'type' => 'wpcolor', 'label' => 'Menu Color', ), array( 'id' => 'submenu_hover_color', 'name' => 'submenu_hover_color', 'type' => 'wpcolor', 'label' => 'Menu Hover Color', ), array( 'id' => 'submenu_bg_color', 'name' => 'submenu_bg_color', 'type' => 'wpcolor', 'label' => 'Menu Background Color', ), array( 'id' => 'submenu_width', 'name' => 'submenu_width', 'type' => 'text', 'label' => 'Menu Width', ), ); $rtmega_settings_fields['style_fields'] = $style_fields; return $rtmega_settings_fields; } public function rtmega_menu_plugin_page (){ $this->rtmega_menu_options = get_option( 'rtmega_menu_options' ); ?>