'0', 'title'=>'Select'); foreach ($categories as $cat) { if($cat->category_count == '0') { $posts_title = 'No posts!'; } elseif($cat->category_count == '1') { $posts_title = '1 post'; } else { $posts_title = $cat->category_count . ' posts'; } $categories_array[] = array('value'=> $cat->cat_ID, 'title'=> $cat->cat_name . ' ( ' . $posts_title . ' )'); } return $categories_array; } $options = array ( array( "type" => "open"), array( "name" => "Logo", "desc" => "Set logo image", "id" => $shortname."_logo", "std" => get_bloginfo('template_url') . "/images/logo.png", "type" =>"image_upload" ), array( "name" => "Rss", "desc" => "Show Rss", "id" => $shortname."_rss", "std" => "true", "type" => "checkbox"), array( "name" => "Facebook", "desc" => "Set Facebook link", "id" => $shortname."_facebook", "std" => "http://facebook.com/", "type" => "text"), array( "name" => "Twitter", "desc" => "Set Twitter link", "id" => $shortname."_twitter", "std" => "http://twitter.com/", "type" => "text"), array( "name" => "LinkedIn", "desc" => "Set LinkedIn link", "id" => $shortname."_linkedin", "std" => "http://linkedin.com/", "type" => "text"), array( "name" => "Youtube", "desc" => "Set Youtube link", "id" => $shortname."_youtube", "std" => "http://www.youtube.com/", "type" => "text"), array( "name" => "Copyright Image", "desc" => "Set copyright image", "id" => $shortname."_copyimg", "std" => get_bloginfo('template_url') . "/images/footer_logo.png", "type" =>"image_upload_2" ), array( "name" => "Copyright Text", "desc" => "Set copyright text", "id" => $shortname."_copytext", "std" => "", "type" => "text"), array( "name" => "Posted on", "desc" => "As example it will shows 'Posted on 12 january 2013'", "id" => $shortname."_postedon", "std" => "Posted on", "type" => "text"), array( "name" => "By", "desc" => "As example it will shows 'by admin'", "id" => $shortname."_by", "std" => "by", "type" => "text"), array( "type" => "close") ); function mytheme_add_admin() { global $themename, $shortname, $options; if ( $_GET['page'] == basename(__FILE__) ) { if ( 'save' == $_REQUEST['action'] ) { foreach ($options as $value) { update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } foreach ($options as $value) { if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } else { delete_option( $value['id'] ); } } echo ''; die; } } add_theme_page($themename." Theme Settings","Theme Settings", 'edit_themes', basename(__FILE__), 'mytheme_admin'); } function mytheme_admin_init() { global $themename, $shortname, $options; $get_theme_options = get_option($shortname . '_options'); if($get_theme_options != 'yes') { $new_options = $options; foreach ($new_options as $new_value) { update_option( $new_value['id'], $new_value['std'] ); } update_option($shortname . '_options', 'yes'); } } if(!function_exists('get_sidebars')) { function get_sidebars() { wp_initialize_the_theme_load(); get_sidebar(); } } function mytheme_admin() { global $themename, $shortname, $options; if ( $_REQUEST['saved'] ) echo '
Settings '.$themename.' saved.