1) { $cur_size = count($flatty_theme_options); $def_size = count($def_theme_options); if ($def_size!=$cur_size) { // Check for new options foreach ($def_theme_options as $def_key => $def_value) : if (!isset($flatty_theme_options[$def_key])) { $flatty_theme_options[$def_key] = $def_value; } endforeach; // Check for deleted options foreach ($flatty_theme_options as $cur_key => $cur_value) : if (!isset($def_theme_options[$cur_key])) { unset ($flatty_theme_options[$cur_key]); } endforeach; delete_option('flatty_theme_options'); add_option('flatty_theme_options', $flatty_theme_options); } } else { // Update options with defaults $flatty_theme_options = $def_theme_options; // Add default options to db add_option('flatty_theme_options', $def_theme_options); } } function add_flatty_options_page() { add_theme_page(__('Theme Options', 'flatty'), __('Theme Options', 'flatty'), 'edit_theme_options', 'theme-options-page', array('flatty_theme_options_page', 'page')); } function page() { // Get options global $flatty_theme_options; // SAVE OPTIONS if (isset($_POST['submit'])) : // Check referer check_admin_referer('flatty_theme_options_page'); // Obtain all $_POST values and make sure unchecked options are // saved with a 0 value. foreach ($flatty_theme_options as $k => $v) { if (isset($_POST[$k])) { $flatty_theme_options[$k] = wp_kses($_POST[$k], array()); } else { $flatty_theme_options[$k] = 0; } } // Update $ret=update_option('flatty_theme_options', $flatty_theme_options); if ($ret) $updated=1; ?>


>

>
>

>

>