解决WordPress后台慢,将控制台显示到首页
Written on May 29, 2008 By 蓝兔 【字体:小 大 】在本地测试这款名为Apple Theme的WordPress主题时,发现该主题将控制台调用在首页显示,也就是说,只要是以管理员身份登陆,就可以在博客首页快捷的进入WordPress的Dashboard控制项进行操作,这真的是一个非常聪明的想法,因为它可以解决WordPress后台运行慢的问题,大大的提高WordPress管理的效率。如图:

然后我就琢磨着这个方法肯定也能在别的主题上实现?
首先将控制台需要用的图标拷贝到当前主题下,到Apple Theme发布页面下载Apple Theme,解压之后将adminbar文件夹复制到自己的themes/images/下
在当前主题CSS后面添加:
- /*Begin Admin Bar*/
- .sbrbar {
- float: left;
- width: 50%;
- }
- .sbrbar ul.admin-bar li {
- margin: 0 0 3px;
- }
- .sbrbar ul.admin-bar li a img {
- border: 0 solid;
- padding: 0 3px 0 0;
- vertical-align: middle;
- }
最后在Sidebar需要显示控制台的地方添加如下代码:
- <?php /* If this is the frontpage */ if ( is_home() ) { ?>
- <?php
- // <!--begin Admin bar-->
- global $user_identity,$user_level;
- get_currentuserinfo();
- if ($user_identity) { ?>
- <li>
- <h3>Admin Dashboard</h3>
- <ul>
- <div class="sbrbar">
- <ul class="admin-bar">
- <li><a href="<?php echo get_option('siteurl'); ?>/wp-admin/" title="<?php _e('View the blog\'s summary','apple4us'); ?>"><img src="<?php bloginfo('template_url'); ?>/images/adminbar/icon_dashboard.png" alt="<?php _e('Dashboard','apple4us'); ?>" title="<?php _e('View the blog\'s summary','apple4us'); ?>" /><strong><?php _e('Admin','apple4us'); ?></strong></a></li>
- <?php if ($user_level >= 1) { ?>
- <?php // Get comments awaiting moderation
- $numcomments = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'");
- ?>
- <li><a href="<?php echo get_option('siteurl'); ?>/wp-admin/post-new.php" title="<?php _e('Create a new post','apple4us'); ?>"><img src="<?php bloginfo('template_url'); ?>/images/adminbar/icon_post_new.png" alt="<?php _e('New Entry','apple4us'); ?>" title="<?php _e('Create a new post','apple4us'); ?>" /><?php _e('Post','apple4us'); ?></a></li>
- <li><a href="<?php echo get_option('siteurl'); ?>/wp-admin/page-new.php" title="<?php _e('Create a new page','apple4us'); ?>"><img src="<?php bloginfo('template_url'); ?>/images/adminbar/icon_page_new.png" alt="<?php _e('New Page','apple4us'); ?>" title="<?php _e('Create a new page','apple4us'); ?>" /><?php _e('Page','apple4us'); ?></a></li>
- <li><a href="<?php echo get_option('siteurl'); ?>/wp-admin/edit.php" title="<?php _e('Administer the entries','apple4us'); ?>"><img src="<?php bloginfo('template_url'); ?>/images/adminbar/icon_post_manage.png" alt="<?php _e('Manage Entries','apple4us'); ?>" title="<?php _e('Administer the entries','apple4us'); ?>" /><?php _e('Manage','apple4us'); ?></a></li>
- <li><a href="<?php echo get_option('siteurl'); ?>/wp-admin/link-manager.php" title="<?php _e('Administer the links','apple4us'); ?>"><img src="<?php bloginfo('template_url'); ?>/images/adminbar/icon_link_manage.png" alt="<?php _e('Links','apple4us'); ?>" title="<?php _e('Administer the links','apple4us'); ?>" /><?php _e('Links','apple4us'); ?></a></li>
- <li><a href="<?php echo get_option('siteurl'); ?>/wp-admin/upload.php" title="<?php _e('Administer the uploads','apple4us'); ?>"><img src="<?php bloginfo('template_url'); ?>/images/adminbar/icon_uploads_manage.png" alt="<?php _e('Uploads','apple4us'); ?>" title="<?php _e('Administer the uploads','apple4us'); ?>" /><?php _e('Uploads','apple4us'); ?></a></li>
- <?php } ?>
- </ul>
- </div>
- <?php if ($user_level >= 1) { ?>
- <div class="sbrbar">
- <ul class="admin-bar">
- <li><a href="<?php echo get_option('siteurl'); ?>/wp-admin/moderation.php" title="<?php _e('Administer the comments','apple4us'); ?>"><img src="<?php bloginfo('template_url'); ?>/images/adminbar/icon_comments.png" alt="<?php _e('Comments','apple4us'); ?>" title="<?php _e('Administer the comments','apple4us'); ?>" /><?php _e('Comment','apple4us'); ?> <?php if ( $numcomments ) : ?> (<strong><?php echo number_format($numcomments); ?></strong>)<?php endif; ?></a></li>
- <li><a href="<?php echo get_option('siteurl'); ?>/wp-admin/themes.php" title="<?php _e('Change the blog\'s look and feel','apple4us'); ?>"><img src="<?php bloginfo('template_url'); ?>/images/adminbar/icon_presentation.png" alt="<?php _e('Design','apple4us'); ?>" title="<?php _e('Change the blog\'s look and feel','apple4us'); ?>" /><?php _e('Design','apple4us'); ?></a></li>
- <li><a href="<?php echo get_option('siteurl'); ?>/wp-admin/plugins.php" title="<?php _e('Administer the plugins','apple4us'); ?>"><img src="<?php bloginfo('template_url'); ?>/images/adminbar/icon_plugins.png" alt="<?php _e('Plugins','apple4us'); ?>" title="<?php _e('Administer the plugins','apple4us'); ?>" /><?php _e('Plugins','apple4us'); ?></a></li>
- <li><a href="<?php echo get_option('siteurl'); ?>/wp-admin/options-general.php" title="<?php _e('Change the blog\'s options','apple4us'); ?>"><img src="<?php bloginfo('template_url'); ?>/images/adminbar/icon_options.png" alt="<?php _e('Options','apple4us'); ?>" title="<?php _e('Change the blog\'s options','apple4us'); ?>" /><?php _e('Options','apple4us'); ?></a></li>
- <li><a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php" title="<?php _e('Administer the users','apple4us'); ?>"><img src="<?php bloginfo('template_url'); ?>/images/adminbar/icon_users.png" alt="<?php _e('Users','apple4us'); ?>" title="<?php _e('Administer the users','apple4us'); ?>" /><?php _e('Users','apple4us'); ?></a></li>
- <li><a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="<?php _e('Log out of this account','apple4us'); ?>"><img src="<?php bloginfo('template_url'); ?>/images/adminbar/icon_logout.png" alt="<?php _e('Logout','apple4us'); ?>" title="<?php _e('Logout of Wordpress','apple4us'); ?>" /><?php _e('Logout »','apple4us'); ?></a></li>
- </ul>
- </div>
- </ul>
- </li>
- <?php } ?>
- <?php } ?>
- <?php } ?>
效果如图:

最后要特别感谢Apple Theme的作者dupola
Sino Blog
。。。。。。。。被你发现啦。哈哈。
我比较喜欢蓝色,不然你肯定用你的Apple主题了,呵呵~~
确实是很不错的功能撒~~