<?php
/**
 * @package Set Defaults
 * @author Frank B&uuml;ltge
 * @version 0.1
 */
 
/*
Plugin Name: Set Defaults
Plugin URI: http://bueltge.de/
Description: Set my defaults options with one click.
Author: Frank B&uuml;ltge
Version: 0.1
License: GPL
Author URI: http://bueltge.de/
Last Change: 09.02.2009 13:24:42
*/


if ( !function_exists ('add_action') ) {
    
header('Status: 403 Forbidden');
    
header('HTTP/1.1 403 Forbidden');
    exit();
}


if ( !
class_exists('SetDefaults') ) {
    class 
SetDefaults {
        
        
// constructor
        
function SetDefaults() {
            
            
add_action'init', array(&$this'on_init'), );
        }
        
        
        
/**
         * init functions
         *
         * @package Set Defaults
         */
        
function on_init() {
            
            if ( 
is_admin() ) {
                
                
// init default options on activate
                
if ( function_exists('register_activation_hook') )
                    
register_activation_hook(__FILE__, array($this'set_my_defaults') );
                    
                
// deinstall options on deactive
                
if ( function_exists('register_uninstall_hook') )
                    
register_uninstall_hook(__FILE__, array($this'set_wp_defaults') );
                
// deinstall options in deactivate
                
if ( function_exists('register_deactivation_hook') )
                    
register_deactivation_hook(__FILE__, array($this'set_wp_defaults') );
            }
            
        }
        
        
        
/**
         * set my defaults
         *
         * @package Set Defaults
         */
        
function set_my_defaults() {
            
// save WP defaults
            
update_option'wp_comments_per_page'get_option('comments_per_page') );
            
update_option'wp_date_format'get_option('date_format') );
            
            
// set my defaults
            
update_option'comments_per_page''20' );
            
update_option'date_format''j. M y' );
        }
        
        
        
/**
         * set WordPress defaults
         *
         * @package Set Defaults
         * @filesource wp-admin/upgrade.php
         * @see        wp_install_defaults
         */
        
function set_wp_defaults() {
            
// update back 2 WP defaults
            
update_option'comments_per_page'get_option('wp_comments_per_page') );
            
update_option'date_format'get_option('wp_date_format') );
            
            
// set my defaults
            
delete_option'wp_comments_per_page' );
            
delete_option'wp_date_format' );
        }
        
    } 
// end class SetDefaults

    
$SetDefaults = new SetDefaults();
}
?>