站长百科 | 数字化技能提升教程 数字化时代生存宝典
首页
数字化百科
电子书
▼
建站程序
开发
服务器
办公软件
开发教程
▼
服务器教程
软件使用教程
运营教程
热门电子书
▼
CSS教程
WordPress教程
导航
程序频道
推广频道
网赚频道
人物频道
网站程序
网页制作
云计算
服务器
CMS
论坛
网店
虚拟主机
cPanel
网址导航
WIKI使用导航
WIKI首页
热点词条
最新资讯
网站程序
站长人物
页面分类
使用帮助
编辑测试
创建条目
网站地图
站长百科导航
站长百科
主机侦探
IDCtalk云说
跨境电商导航
WordPress啦
站长专题
网站推广
网站程序
网站赚钱
虚拟主机
cPanel
网址导航专题
云计算
微博营销
虚拟主机管理系统
开放平台
WIKI程序与应用
美国十大主机
编辑“
WordPress:Creating Admin Themes
”(章节)
人物百科
|
营销百科
|
网赚百科
|
站长工具
|
网站程序
|
域名主机
|
互联网公司
|
分类索引
跳转至:
导航
、
搜索
警告:
您没有登录。如果您做出任意编辑,您的IP地址将会公开可见。如果您
登录
或
创建
一个账户,您的编辑将归属于您的用户名,且将享受其他好处。
反垃圾检查。
不要
加入这个!
== 设计管理主题 == [[WordPress:Image:tiger-admin-theme.png|right|thumb|Tiger Admin Theme]]Whether you are designing your own Administration Panel Theme or creating one for public distribution as a WordPress Plugin, the process is basically the same. As a Plugin, the Admin Theme includes a function that will instruct WordPress to use a new stylesheet for displaying the Admin Panel. A distinct advantage to making a plugin is that if you ever want to revert back to the default style, all you have to do is deactivate the plugin. If you are just making few changes and do not want to go through the hassle of creating your plugin, you might be better off just editing the CSS file directly. [[WordPress:Image:tiger-admin-theme.png|right|thumb|Tiger Admin Theme]]不管你是设计自己的管理面板主题还是创建一个或者多个公开发行的主题作为WordPress插件,这两个过程基本是相同的。作为插件,管理主题包含有一个函数,这个函数会指示WordPress使用新的样式表,显示管理面板。创建插件一个明显的优势在于,如果你想要返回到默认样式,你只要取消运行插件,即可。如果你只是做出少量更改,而且不想要创建插件,你最好直接地编辑CSS文件。 ;Direct Editing :Make a backup copy of the <tt>wp-admin.css</tt> file from the <tt>wp-admin</tt> folder on your WordPress site. Then you can go in and make changes in the new <tt>wp-admin.css</tt> file with a backup, just in case. ;直接编辑 :制作WordPress站点<tt>wp-admin</tt>文件夹的<tt>wp-admin.css</tt>文件的备份。然后你可以进入备份,更改新的<tt>wp-admin.css</tt>文件,使用备份,以防出错。 ===The Admin Style Sheet=== ===管理样式表=== [[WordPress:Image:pink-admin-theme.png|right|thumb|Pink Administration Theme]]The original Admin Theme style sheet is very complex, covering all aspects of the Administration Panels thoroughly. Not all the parts and pieces may need to be changed to recreate your Admin Theme. [[WordPress:Image:pink-admin-theme.png|right|thumb|Pink 管理主题]]原始的管理主题样式表非常地复杂,完全地包含了管理面板的所有部分。重新创建你的管理主题并不一定要更改原始主题的每个部分。 Here is a partial list of the important style references used in the Administration Panels. Per CSS web standards, <tt>#</tt> denotes a style ID and <tt>.</tt> denotes a style class. 下面是管理面板中使用的重要的样式参照的部分列表。根据CSS网络标准,<tt>#</tt>表示样式ID而<tt>.</tt>表示样式类别。 ; <tt>#wphead</tt> :The main title of the admin panel. Used to display the name of the blog and a link to '''View Site'''. ; <tt>#wphead</tt> :管理面板主要的标题。用来显示博客名称和链接,链接到'''浏览站点'''。 ; <tt>#adminmenu ul</tt> :The main level navigation bar, for links: Dashboard, Write, Manage, etc. ; <tt>#adminmenu ul</tt> :关于链接的主要级别的导航条:Dashboard,编写,管理,等等。 ; <tt>#adminmenu2 ul</tt> :The sub level navigation bar, for links (example: under Manage: Posts, Pages, Categories). ; <tt>#adminmenu2 ul</tt> :关于链接的子级别的导航条(例如:管理下面:文章,网页,类别)。 ; <tt>.wrap</tt> :The basic wrapper for all content in the admin panel, set in a <tt><div></tt>. ; <tt>.wrap</tt> :管理面板中所有内容的基本的wrapper,设置在<tt><div></tt>中。 ; <tt>#zeitgeist</tt> :The sidebar on the Dashboard displaying Latest Activity and Blog Stats. ; <tt>#zeitgeist</tt> :Dashboard中的工具条,用来显示最新的活动和博客统计数据。 ; <tt>#footer</tt> :The footer at the bottom, with Wordpress logo, version number, and help links. ; <tt>#footer</tt> :底部的页底文字,有WordPress标示语,版本数字,和帮助链接。 ; <tt>.wrap h2</tt> :Individual Page headers for the various subpanels, like '''General Options'''. ; <tt>.wrap h2</tt> :不同的子面板,如'''总选项'''的单个网页标头。 The changes you make in the <tt>wp-admin.css</tt> can be minor or extensive. You can just change the background color, add a background image to different sections, change the font, or even just do a minor color or design change to the [[WordPress:Coloured_Quicktags|Quicktag buttons]]. It is up to you to use your imagination and create whatever effect you want. 你可以简单地或者大量地更改<tt>wp-admin.css</tt>。你可以只更改背景色,给不同的部分添加背景图像,更改字体,或者只是更改[[WordPress:Coloured_Quicktags|Quicktag 按钮]]的颜色或者设计。这取决于你的想象力,创建你想要的效果。 === Creating an Admin Theme Plugin === === 创建一个管理主题插件 === To create an Admin Theme Plugin, it will need to be easily installed with little effort by the user, and easily uninstalled or deactivated, returning the [[WordPress:Administration Panels]] to their original state. 要创建管理主题插件,用户需要能够轻易地安装,卸载,以及取消这个插件的运行,将[[WordPress:Administration Panels|管理面板]]返回到原始状态。 We begin by telling WordPress to link to a new style sheet. 首先,我们指示WordPress链接到一种新的样式表。 In a [[WordPress:Glossary#Text editor|text editor]], in a new document, put the following: 在[[WordPress:Glossary#Text editor|文本编辑器]]的一个新建文档中,放入: <pre> <?php /* Plugin Name: Blue Steel Theme Plugin URI: http://example.com/blue-steel-admin-theme Description: Blue Steel WordPress Admin Theme - Upload and Activate. Author: Mr. WordPress Version: 1.0 Author URI: http://example.com */ ?> </pre> <pre> <?php /* 插件名称: Blue Steel 主题 插件 URI: http://example.com/blue-steel-admin-theme 描述: Blue Steel WordPress 管理主题 – 上传和激活。 作者: Mr. WordPress 版本: 1.0 作者 URI: http://example.com */ ?> </pre> This is the "header" of the style sheet and provides information about the plugin to be viewed on the [[WordPress:Administration_Panels#Plugins_-_Add_Functionality_to_your_Blog|Plugin Panel]]. It provides the name, [[WordPress:Glossary#URI_and_URL|URI]] of the plugin, the description, author, and version. 这是样式表的"标头",提供了[[WordPress:Administration_Panels#Plugins_-_Add_Functionality_to_your_Blog|插件面板]]上的插件的信息。提供了插件名称,插件[[WordPress:Glossary#URI_and_URL|URI]],描述,作者和版本。 Create a folder on your computer, per this example, called <tt>blue-steel</tt>. Save this file inside of the folder and call it <tt>blue-steel.php</tt>. When you are ready, upload the entire folder to your plugin folder on your website at <tt>/wp-content/plugins/</tt>. This folder should be at <tt>/wp-content/plugins/blue-steel/</tt> and the plugin file should be at <tt>/wp-content/plugins/blue-steel/blue-steel.php</tt>. 在你的电脑上创建一个文件夹,如这个例子中,文件夹为<tt>blue-steel</tt>。将文件保存在文件夹中,文件名为<tt>blue-steel.php</tt>。你准备好之后,将你的整个文件夹上传到你的网站<tt>/wp-content/plugins/</tt中的 插件文件夹中。这个文件夹应该在<tt>/wp-content/plugins/blue-steel/</tt>,插件文件应该位于<tt>/wp-content/plugins/blue-steel/blue-steel.php</tt>。 To make this plugin call a new style sheet for the Administration Panels, we need to create a function that will add the style sheet to the <tt>head</tt> of the Admin Panel's <tt>header</tt>. This is no different than adding a link to a style sheet in all web pages. It will look something like this when the page is generated: 要使得这个插件为管理面板调用一种新的样式表,我们需要创建一个函数,这个函数会将新的样式表添加到管理面板的<tt>header</tt>的<tt>head</tt>上。网页创建好之后,这看起来像: <pre><link rel="stylesheet" type="text/css" href="http://example.com/wp-content/plugins/blue-steel/wp-admin.css"></pre> <pre><link rel="stylesheet" type="text/css" href="http://example.com/wp-content/plugins/blue-steel/wp-admin.css"></pre> With your plugin, you will want to detect where the user has installed WordPress, so that you know where the rest of your Theme is located. You can use the <tt>get_settings()</tt> function for that. This makes your plugin flexible and portable. Here is how we would create the stylesheet <tt>link</tt> shown above: 拥有了插件,你可能想要侦测用户在哪里安装了WordPress,这样你知道你其余的主题位于哪里。你可以使用<tt>get_settings()</tt>函数处理这一问题。这使得你的插件灵活方便。下面是关于我们怎样创建上面显示的样式表<tt>link</tt>: <pre><?php /* Plugin Name: Blue Steel Theme Plugin URI: http://example.com/blue-steel-admin-theme Description: Blue Steel WordPress Admin Theme - Upload and Activate. Author: Mr. WordPress Version: 1.0 Author URI: http://example.com */ function mr_blue_steel() { $url = get_settings('siteurl'); $url = $url . '/wp-content/plugins/blue-steel/wp-admin.css'; echo '<link rel="stylesheet" type="text/css" href="' . $url . '" />'; } ?></pre> <pre><?php /* 插件名称: Blue Steel 主题 插件 URI: http://example.com/blue-steel-admin-theme 描述: Blue Steel WordPress 管理主题 – 上传并且激活。 作者: Mr. WordPress 版本: 1.0 作者 URI: http://example.com */ function mr_blue_steel() { $url = get_settings('siteurl'); $url = $url . '/wp-content/plugins/blue-steel/wp-admin.css'; echo '<link rel="stylesheet" type="text/css" href="' . $url . '" />'; } ?></pre> Before we get to the actual styles, you need to add an action with the [[WordPress:Plugin_API#Adding_Actions|Plugin API]]. Actions allow for plugins to "hook" into functions and features of the program. For Admin Themes, you want to hook into the <tt>admin_head</tt> (called in the <tt><head></tt>) of the Administration Panel with <tt>add_action()</tt>: 在我们得到真正的样式之前,你需要添加[[WordPress:Plugin_API#Adding_Actions|插件 API]]的action。Action能够使得插件"hook" into函数和程序的功能。对于管理主题,你想要使用<tt>add_action()</tt>hook into管理面板的<tt>admin_head</tt>(在<tt><head></tt>中调用): <pre> function mr_blue_steel() { $url = get_settings('siteurl'); $url = $url . '/wp-content/plugins/blue-steel/wp-admin.css'; echo '<link rel="stylesheet" type="text/css" href="' . $url . '" />'; } add_action('admin_head', 'mr_blue_steel'); ?></pre> <pre> function mr_blue_steel() { $url = get_settings('siteurl'); $url = $url . '/wp-content/plugins/blue-steel/wp-admin.css'; echo '<link rel="stylesheet" type="text/css" href="' . $url . '" />'; } add_action('admin_head', 'mr_blue_steel'); ?></pre> In addition to the <tt>admin_head</tt> Plugin API hook, you can also optionally add a function to add content to the <tt>admin_footer</tt>. For example, you might want to put a notice about the theme in the footer. Here is how to add it to your plugin: 除了<tt>admin_head</tt> 插件 API hook,你还可以随意地添加函数,向<tt>admin_footer</tt>添加内容。例如,你可能想在页脚添加关于主题的通知。下面是关于怎样将函数添加到你的插件: <pre> function blue_steel_footer() { echo 'This theme was made by <a href="http://example.com">Mr. WordPress</a>.'; } add_action('admin_footer', 'blue_steel_footer'); </pre> <pre> function blue_steel_footer() { echo 'This theme was made by <a href="http://example.com">Mr. WordPress</a>.'; } add_action('admin_footer', 'blue_steel_footer'); </pre> Save the plugin and upload it to your site. Select it from the Plugins Panel and see if anything about <tt>blue-steel</tt> appears. If it does, you are on the right track! 保存插件并且将插件上传到你的站点上。从插件面板上选出插件,看看关于<tt>blue-steel</tt>内容有没有出现。如果出现了,你就做对了!
摘要:
请注意,您对站长百科的所有贡献都可能被其他贡献者编辑,修改或删除。如果您不希望您的文字被任意修改和再散布,请不要提交。
您同时也要向我们保证您所提交的内容是您自己所作,或得自一个不受版权保护或相似自由的来源(参阅
Wordpress-mediawiki:版权
的细节)。
未经许可,请勿提交受版权保护的作品!
取消
编辑帮助
(在新窗口中打开)