cat_ID] = $category_list->cat_name;
}
array_unshift($wp_cats, 'Choose a category');
// ==================================================================
// Page listing
// ==================================================================
$pages = get_pages('hide_empty=0&orderby=name');
$wp_pages = array();
foreach ($pages as $page_list ) {
$wp_pages[$page_list->ID] = $page_list->post_title;
}
array_unshift($wp_pages, 'Choose a page');
// ==================================================================
// Libraries
// ==================================================================
//// ==================================================================
// Theme options settings
//// ==================================================================
$themename = 'Theme';
$shortname = 'adelle_theme_';
$options = array (
array(
'name' => 'Theme',
'type' => 'header'
),
//// ==================================================================
// General
//// ==================================================================
array('type'=>'class','class'=>'
'),
array(
'name' => 'Custom favicon',
'id' => $shortname.'favicon',
'type' => 'upload',
"size" => '16x16',
'note' => '',
'std' => '',
),
array(
'name' => 'Footer credit',
'id' => $shortname.'footer_credit',
'type' => 'editor',
'note' => '',
),
array('type'=>'class','class'=>'
'),
//// ==================================================================
// Extra inputs
//// ==================================================================
array('type'=>'class','class'=>''),
//// ==================================================================
// 404 Error
//// ==================================================================
array('type'=>'class','class'=>''),
array(
'name' => '404 Page Content',
'id' => $shortname.'404_page',
'type' => 'editor',
'note' => '',
),
array('type'=>'class','class'=>'
'),
);
// ==================================================================
// Libraries
// ==================================================================
function mytheme_add_admin() {
global $themename, $shortname, $options;
if ( isset ( $_GET['page'] ) && ( $_GET['page'] == basename(__FILE__) ) ) {
if ( isset ($_REQUEST['action']) && ( 'save' == $_REQUEST['action'] ) ){
foreach ( $options as $value ) {
if ( array_key_exists('id', $value) ) {
if ( isset( $_REQUEST[ $value['id'] ] ) ) {
update_option( $value['id'], $_REQUEST[ $value['id'] ] );
} else {
delete_option( $value['id'] );
}
}
}
header("Location: themes.php?page=".basename(__FILE__)."&saved=true");
die;
} else if ( isset ($_REQUEST['action']) && ( 'reset' == $_REQUEST['action'] ) ) {
foreach ($options as $value) {
if ( array_key_exists('id', $value) ) {
delete_option( $value['id'] );
}
}
header("Location: admin.php?page=".basename(__FILE__)."&reset=true");
die;
}
}
add_theme_page('Theme Options', 'Theme Options', 'edit_themes', basename(__FILE__), 'mytheme_admin', 10);
}
function mytheme_admin() {
global $themename, $shortname, $options;
if( isset($_REQUEST['saved']) ) echo ''.$themename.' settings saved.
';
if( isset($_REQUEST['reset']) ) echo ''.$themename.' settings reset.
';
?>