'; // the title needs a hat icon echo get_screen_icon('magic-fields'); print '

'.__('Magic Fields Settings', $mf_domain ).'

'; $options = self::fields_form(); self::form_options($options); print ''; } public function save_settings($data){ if($data['uninstall_magic_field'] == 'uninstall'){ mf_install::uninstall(); }else{ unset($data['uninstall_magic_field']); if($data['mf_settings']['extra']['clear_cache'] == 1){ mf_install::clear_cache(); } unset($data['mf_settings']['extra']); self::update($data['mf_settings']['general']); wp_redirect('options-general.php?page=mf_settings'); } } public static function form_options($options){ global $mf_domain; ?>


array( 'hide_visual_editor' => array( 'id' => 'hide_visual_editor', 'type' => 'checkbox', 'label' => __('Hide Visual Editor (multiline)',$mf_domain), 'name' => "mf_settings[general][hide_visual_editor]", 'value' => ( !empty( $options['hide_visual_editor'] ) )? $options['hide_visual_editor'] : 0, 'description' => __( 'Hide All Visual Editor (multiline)', $mf_domain ) ), 'dont_remove_tags' => array( 'id' => 'dont_remove_tags', 'type' => 'checkbox', 'label' => __('Do not remove tags TinyMCE. (multiline)',$mf_domain), 'name' => "mf_settings[general][dont_remove_tags]", 'value' => ( !empty( $options['dont_remove_tags'] ) ) ? $options['dont_remove_tags'] : 0, 'description' => __( 'Stop removing the

and
tags when saving and show them in the HTML editor', $mf_domain ) ), 'hide_post_panel' => array( 'id' => 'hide_post_panel', 'type' => 'checkbox', 'label' => __( 'Hide Wordpress Post panel' ), 'name' => "mf_settings[general][hide_post_panel]", 'value' => ( !empty( $options['hide_post_panel'] ) ) ? $options['hide_post_panel'] : 0, 'description' => __( 'Hide the post panel', $mf_domain ) ), 'hide_page_panel' => array( 'id' => 'hide_page_panel', 'type' => 'checkbox', 'label' => __( 'Hide Wordpress Page panel' ), 'name' => "mf_settings[general][hide_page_panel]", 'value' => ( !empty( $options['hide_page_panel'] ) ) ? $options['hide_page_panel'] : 0, 'description' => __( 'Hide the page panel', $mf_domain ) ) ), 'extra' => array( 'clear_cache' => array( 'id' => 'clear_cache', 'type' => 'checkbox', 'label' => __('Clear cache',$mf_domain), 'name' => "mf_settings[extra][clear_cache]", 'value' => 0, 'description' => __( 'delete all image thumbs', $mf_domain ) ) ) ); //update values $settings = self::get(); if(is_array($settings)){ foreach($settings as $k => $v){ if( isset($data['general'][$k]) ){ $data['general'][$k]['value'] = $v; } } } return $data; } public function update($options) { $options = serialize($options); update_option(MF_SETTINGS_KEY, $options); } public static function get($key = null) { if (get_option(MF_SETTINGS_KEY) == "") return ""; if (is_array(get_option(MF_SETTINGS_KEY))) $options = get_option(MF_SETTINGS_KEY); else $options = unserialize(get_option(MF_SETTINGS_KEY)); if (!empty($key)){ if( isset($options[$key]) ) return $options[$key]; return false; }else{ return $options; } } function set($key, $val) { $options = self::get(); $options[$key] = $val; self::update($options); } }