options as $value) { if ( array_key_exists('id', $value) ) { if ( isset( $_REQUEST[ $value['id'] ] ) ) { if ( in_array( $value['id'], array( $this->shortname.'_background_color', $this->shortname.'_border_color', $this->shortname.'_hover_color', $this->shortname.'_link_color', ) ) ) { $opt_value = preg_match( '/^#?([a-f0-9]{3}){1,2}$/i', trim( $_REQUEST[ $value['id'] ] ) ) ? trim( $_REQUEST[ $value['id'] ] ) : ''; update_option( $value['id'], $opt_value ); } else { update_option( $value['id'], stripslashes( $_REQUEST[ $value['id'] ] ) ); } } } } wp_redirect("themes.php?page=".basename(__FILE__)."&saved=true"); exit; } else if ( ! empty( $_REQUEST['reset-theme-options-nonce'] ) && wp_verify_nonce( $_REQUEST['reset-theme-options-nonce'], 'reset-theme-options' ) && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'reset' ) { foreach ($this->options as $value) { if ( array_key_exists('id', $value) ) { delete_option( $value['id'] ); } } wp_redirect("themes.php?page=".basename(__FILE__)."&reset=true"); exit; } } add_theme_page(__( 'Theme Options' ), __( 'Theme Options' ), 'edit_theme_options', basename(__FILE__), array(&$this, 'adminPage')); } /* Output of the Admin Page */ function adminPage () { // global $themename, $shortname, $options; if ( isset( $_REQUEST['saved'] ) && $_REQUEST['saved'] ) echo '
' . $this->themename . __(' options saved.', 'vigilance') . '
' . $this->themename . __(' options reset.', 'vigilance') . '