站长百科 | 数字化技能提升教程 数字化时代生存宝典
首页
数字化百科
电子书
▼
建站程序
开发
服务器
办公软件
开发教程
▼
服务器教程
软件使用教程
运营教程
热门电子书
▼
CSS教程
WordPress教程
导航
程序频道
推广频道
网赚频道
人物频道
网站程序
网页制作
云计算
服务器
CMS
论坛
网店
虚拟主机
cPanel
网址导航
WIKI使用导航
WIKI首页
热点词条
最新资讯
网站程序
站长人物
页面分类
使用帮助
编辑测试
创建条目
网站地图
站长百科导航
站长百科
主机侦探
IDCtalk云说
跨境电商导航
WordPress啦
站长专题
网站推广
网站程序
网站赚钱
虚拟主机
cPanel
网址导航专题
云计算
微博营销
虚拟主机管理系统
开放平台
WIKI程序与应用
美国十大主机
编辑“
WordPress:Plugins/WordPress Widgets Api
”(章节)
人物百科
|
营销百科
|
网赚百科
|
站长工具
|
网站程序
|
域名主机
|
互联网公司
|
分类索引
跳转至:
导航
、
搜索
警告:
您没有登录。如果您做出任意编辑,您的IP地址将会公开可见。如果您
登录
或
创建
一个账户,您的编辑将归属于您的用户名,且将享受其他好处。
反垃圾检查。
不要
加入这个!
== 开发新的Widgets == The Google Search widget is commented within inches of its life, so consider that your tutorial. Additionally, there are a few guidelines to follow: Google 搜索widget注释尽在咫尺,因此考虑将这个作为你的指南。此外,需要遵循一些指导方针: * Don’t execute any code while the plugin is loaded. Use the plugins_loaded hook or you risk fatal errors due to undefined functions, or missing the boat completely because your plugin loaded before the one it depends on. *载入插件的时候,不要运行任何代码。使用plugins_loaded hook或者因为未定义的函数,或者因为你的插件再没有依赖函数的情况下,载入,你坐失良机,冒着致命错误的危险。 * Use register_sidebar_widget($name, $callback) to add your widget to the admin interface. *使用register_sidebar_widget($name, $callback)将你的widget添加到管理界面。 * Follow this template: *遵循下面的模板: <pre> function widget_myuniquewidget($args) { extract($args); ?> <?php echo $before_widget; ?> <?php echo $before_title . 'My Unique Widget' . $after_title; ?> Hello, World! <?php echo $after_widget; ?> <?php } register_sidebar_widget('My Unique Widget', 'widget_myuniquewidget'); </pre> <pre> function widget_myuniquewidget($args) { extract($args); ?> <?php echo $before_widget; ?> <?php echo $before_title . 'My Unique Widget' . $after_title; ?> Hello, World! <?php echo $after_widget; ?> <?php } register_sidebar_widget('My Unique Widget', 'widget_myuniquewidget'); </pre> * Don’t leave out $before_widget, $after_widget, $before_title, or $after_title by accident. They are required for compatibility with various themes. *不要碰巧遗漏了$before_widget, $after_widget, $before_title, 或者$after_title。需要这些函数与不同的主题兼容。 * Name your widget and its functions carefully. Those strings will be used as HTML attributes and you don’t want to cause identical id’s in a single HTML document. *仔细地命名你的widget和函数。这些字符串将会用作HTML属性而且你不希望在单一的HTML文档中产生同样的id’s。 * Localization is done internally to preserve the HTML id attribute. If you want your widget name localized with a textdomain, pass array($name, $textdomain) instead of $name. *本地化是在内部完成的,保留HTML id 属性。如果你希望能使用文本域名本地化你的widget名称,请传递array($name, $textdomain)而不是$name。 * To accommodate multi-widgets (e.g. Text and RSS) you can also pass a replacement value with the name: array($name_as_sprintf_pattern, $textdomain, $replacement). See the source. *要容纳多个widgets(例如文本和RSS),你可以使用下面的名称传递replacement参数值:array($name_as_sprintf_pattern, $textdomain, $replacement)。请看看原始资料。 * You may use the variables mentioned above in different ways, or neglect them in some circumstances. Some widgets may not need a title, for example. Some widgets will use the $before_widget and $after_widget several times, or as arguments to tell another template tag how to format its output. *你可能以不同的方式使用上述提到的变数,或者在有些情况下,忽视这些变数。一些widgets可能不需要标题。有的widgets几次都用到$before_widget 和 $after_widget,或者作为参数通知其它模板标签怎样为输出内容设计格式。 * Optionally, use the following syntax to add a configuration page to the admin. Your callback will be used within the main form, so you must not include any <form> tags or a form submit button. *使用下面的语法将配置页面添加到管理。在主要的表格中会用到你的callback,因此你不应该包含任何<form>标签或者表格递交按钮。 <pre> register_widget_control($name, $callback [, $width [, $height ]] ); </pre> <pre> register_widget_control($name, $callback [, $width [, $height ]] ); </pre> * Namespace your form elements so they don’t conflict with other widgets. *给你的表格内容定义名字空间,这样与其它的widgets不会发送冲突。 * Each widget must have a unique name. You can replace an already-registered widget by registering another one with the same name, supplying your own callback. *每个widget必须有个单独的名称,你可以通常同样名称的widget,替换已注册的widget,支持你自己的callback。 * Any extra arguments to register_sidebar_widget() or register_widget_control() will be passed to your callback. See the Text and RSS widgets for examples. * register_sidebar_widget()或者register_widget_control()的任何额外参数会传递到你的callback。请看看文本和RSS widget,作为例子参考。 * Any widget or control can be “unregistered” by passing an empty string to the registration function. *向注册函数传递空字符串,可以“取消注册”任何widget或者control。 * There are probably some undocumented functions. You are encouraged to read the source code and see how we’ve created the standard widgets using these functions. *可能有一些违归档的函数。鼓励你阅读源代码,了解我们怎样使用这些函数,创建了标准的widgets。 * Please test your widgets with several themes other than Classic and Default (they both use the ul/li/h2 markup). *除了经典和默认主题(都使用ul/li/h2标记),请使用多个主题测试你的widgets。 * Please audit the security of your widgets before distributing them. *发行widgets之前,请审核widgets的安全性。 * If you would like your widget to be considered for use on WordPress.com, send a link (no attachments please) to widgets@wordpress.com and we’ll have a look. *如果你希望你的widget在WordPress.com上使用,请发送链接(不要加附件)到widgets@wordpress.com,我们会查看你的widget。
摘要:
请注意,您对站长百科的所有贡献都可能被其他贡献者编辑,修改或删除。如果您不希望您的文字被任意修改和再散布,请不要提交。
您同时也要向我们保证您所提交的内容是您自己所作,或得自一个不受版权保护或相似自由的来源(参阅
Wordpress-mediawiki:版权
的细节)。
未经许可,请勿提交受版权保护的作品!
取消
编辑帮助
(在新窗口中打开)