cat_ID] = $category_item->cat_name; } array_unshift($all_cats, "Select a category"); /*--------------------------------------------------- register settings ----------------------------------------------------*/ function theme_settings_init(){ register_setting( 'theme_settings', 'theme_settings' ); wp_enqueue_style("panel_style", get_template_directory_uri()."/panel/panel.css", false, "1.0", "all"); wp_enqueue_script("panel_script", get_template_directory_uri()."/panel/panel_script.js", false, "1.0"); } /*--------------------------------------------------- add settings page to menu ----------------------------------------------------*/ function add_settings_page() { add_theme_page( __( 'BoxBlog' .' Theme Panel' ), __( 'BoxBlog' .' Theme Panel' ), 'manage_options', 'settings', 'theme_settings_page'); } /*--------------------------------------------------- add actions ----------------------------------------------------*/ add_action( 'admin_init', 'theme_settings_init' ); add_action( 'admin_menu', 'add_settings_page' ); /* --------------------------------------------------------- Declare options ----------------------------------------------------------- */ $theme_options = array ( array( "name" => $themename." Options", "type" => "title"), /* --------------------------------------------------------- General section ----------------------------------------------------------- */ array( "name" => __("General", "candd"), "type" => "section"), array( "type" => "open"), array( "name" => __("Logo Url", "candd"), "desc" => __("Enter the link to your logo image", "candd"), "id" => $shortname."_logo", "type" => "text", "std" => get_bloginfo('template_url') ."/images/logo.png"), array( "name" => __("Custom Favicon", "candd"), "desc" => __("A favicon is a 16x16 pixel icon that represents your site; paste the URL to a .ico image that you want to use as the image", "candd"), "id" => $shortname."_favicon", "type" => "text", "std" => get_bloginfo('template_url') ."/images/favicon.ico"), array( "type" => "close"), /* --------------------------------------------------------- Footer section ----------------------------------------------------------- */ array( "name" => __("Footer", "candd"), "type" => "section"), array( "type" => "open"), array( "name" => "Footer Credit", "desc" => __("You can customize footer credit on footer area her.", "candd"), "id" => $shortname."_footer_text", "type" => "textarea", "std" => ""), array( "type" => "close") ); /*--------------------------------------------------- Theme Panel Output ----------------------------------------------------*/ function theme_settings_page() { global $themename,$theme_options; $i=0; $message=''; if ( 'save' == $_REQUEST['action'] ) { foreach ($theme_options as $value) { update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } foreach ($theme_options as $value) { if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } else { delete_option( $value['id'] ); } } $message='saved'; } else if( 'reset' == $_REQUEST['action'] ) { foreach ($theme_options as $value) { delete_option( $value['id'] ); } $message='reset'; } ?>
'; if ( $message=='reset' ) echo ''.$themename.' settings reset.