WordPress: Migrating Plugins and Themes to 2.3:修订间差异

来自站长百科
跳转至: 导航、​ 搜索
(新页面: ==Introduction== When a new major version of WordPress is released, such as WordPress 2.1 or 2.2, you may find that your Themes and Plugins no longer work the way you are used to. It cou...)
 
无编辑摘要
第1行: 第1行:
==Introduction==
==Introduction==
==介绍==


When a new major version of WordPress is released, such as WordPress 2.1 or 2.2, you may find that your Themes and Plugins no longer work the way you are used to. It could be that they are completely broken, because something in WordPress that was fundamental to them changed, but it's also possible that you can get them working again by updating some settings, or maybe just a small edit.  
When a new major version of WordPress is released, such as WordPress 2.1 or 2.2, you may find that your Themes and Plugins no longer work the way you are used to. It could be that they are completely broken, because something in WordPress that was fundamental to them changed, but it's also possible that you can get them working again by updating some settings, or maybe just a small edit.  
发行一个新的主要版本的WordPress,如WordPress2.1或者2.2,你可能发现你的主题和插件不再向以前那样运行。可能因为插件和主题完全毁坏了,因为WordPress中对它们而言至关重要的部分更改了,但是通过上传一些设置,或者只是简单地编辑一下,你可能有能够使得这些插件和主题正常运行。


This article is part of a series on [[WordPress:Migrating Plugins and Themes]]. It covers changes between WordPress [[WordPress:Version 2.2]] and [[WordPress:Version 2.3]], and what you need to do to Plugins and Themes to get them working in Version 2.3.  You may also want to visit  [[WordPress:Migrating Plugins and Themes to 2.5]] if you want to support later versions.
This article is part of a series on [[WordPress:Migrating Plugins and Themes]]. It covers changes between WordPress [[WordPress:Version 2.2]] and [[WordPress:Version 2.3]], and what you need to do to Plugins and Themes to get them working in Version 2.3.  You may also want to visit  [[WordPress:Migrating Plugins and Themes to 2.5]] if you want to support later versions.
这篇文章是[[WordPress:Migrating Plugins and Themes|升级插件和主题]]系列的一部分。包括[[WordPress:Version 2.2|2.2版本]] 和 [[WordPress:Version 2.3|2.3版本]]之间的变化,你需要做的就是,使得插件和主题能够在2.3版本中运行。如果你想要支持以后的版本,你也可能也想要阅读[[WordPress:Migrating Plugins and Themes to 2.5|将插件和主题升级到2.5版本]]。


If the Theme or Plugin you are using was developed by someone else, there are several places to look for information:
If the Theme or Plugin you are using was developed by someone else, there are several places to look for information:
如果你使用的主题或者插件是其他人开发的,你可以从下面的这些地点查找信息:
* Your Plugin or Theme's home page
* Your Plugin or Theme's home page
*你的插件或者主题的主页
* WordPress 2.3 [[WordPress:Plugins/Plugin_Compatibility/2.3|Plugin Compatibility List]]
* WordPress 2.3 [[WordPress:Plugins/Plugin_Compatibility/2.3|Plugin Compatibility List]]
* WordPress 2.3 [[WordPress:Plugins/Plugin_Compatibility/2.3|插件兼容性列表]]
* WordPress 2.3 [[WordPress:Themes/Theme_Compatibility/2.3|Theme Compatibility List]]
* WordPress 2.3 [[WordPress:Themes/Theme_Compatibility/2.3|Theme Compatibility List]]
* WordPress 2.3 [[WordPress:Themes/Theme_Compatibility/2.3|主题兼容性列表]]


If you are the author of your Theme or Plugin, or if you have modified or customized your Theme, then this article will help you upgrade your Theme/Plugin for 2.3. If your Theme or Plugin is distributed publicly, after getting it working you may want to add it to the Compatibility lists above, so your users will know it is working and which version they should be running.
If you are the author of your Theme or Plugin, or if you have modified or customized your Theme, then this article will help you upgrade your Theme/Plugin for 2.3. If your Theme or Plugin is distributed publicly, after getting it working you may want to add it to the Compatibility lists above, so your users will know it is working and which version they should be running.
如果你是主题或者插件的作者,或者如果你更改或者自定义了主题,那么这篇文章会帮助你将主题/插件升级到2.3。如果你的主题或者插件是公开发行的版本,使得插件和主题运行之后,你希望将插件或者主题添加到上述的兼容性列表,这样你的用户会了解这些插件或者主题能够运行以及应该在哪个版本上运行。


==Fixing Up Your Theme or Plugin==
==Fixing Up Your Theme or Plugin==
==升级你的主题或者插件==


===Categories and Tags===
===Categories and Tags===
===类别和标签===
The main change of importance to Plugins and Themes in [[WordPress:Version 2.3]] was the introduction of tagging as a core WordPress functionality.  
The main change of importance to Plugins and Themes in [[WordPress:Version 2.3]] was the introduction of tagging as a core WordPress functionality.  
[[WordPress:Version 2.3|2.3版本]]中对于插件和主题而言,至关重要的变化在于引进了标签作为WordPress核心功能。


If you want to add tags to your theme (e.g. to display the tags used on a post, or put a tag cloud into your sidebar), you will be interested in new [[WordPress:Template_Tags/the_tags|the_tags]] and [[WordPress:Template_Tags/wp_tag_cloud|wp_tag_cloud]] template tag functions.
If you want to add tags to your theme (e.g. to display the tags used on a post, or put a tag cloud into your sidebar), you will be interested in new [[WordPress:Template_Tags/the_tags|the_tags]] and [[WordPress:Template_Tags/wp_tag_cloud|wp_tag_cloud]] template tag functions.
如果你希望给你的主题添加标签(显示文章上使用的标签,或者将标签云放入你的边栏),你可能对新的[[WordPress:Template_Tags/the_tags|the_tags]] 和[[WordPress:Template_Tags/wp_tag_cloud|wp_tag_cloud]]标签函数感兴趣。


There were also quite a few new tag-related functions for use in plugins introduced in WordPress 2.3.  
There were also quite a few new tag-related functions for use in plugins introduced in WordPress 2.3.  
在WordPress2.3版本引用的插件中也可以使用一些新的标签相关的函数。


Also, as a side effect of introducing tags to WordPress, the underlying database table structure, in regards to storage of categories, was changed considerably. So, any plugins that ran queries using the category-related tables in the WordPress database will likely be broken; the queries will have to be completely rewritten. Plugins and Themes that used WordPress functions to access categories should be OK.
Also, as a side effect of introducing tags to WordPress, the underlying database table structure, in regards to storage of categories, was changed considerably. So, any plugins that ran queries using the category-related tables in the WordPress database will likely be broken; the queries will have to be completely rewritten. Plugins and Themes that used WordPress functions to access categories should be OK.
向WordPress引进标签也会有负面效应,有关类别储存的潜在的数据库结构,会相应地更改。因此,因此任何使用WordPress数据库中类别相关的表格来运行查询的插件可能会毁坏;查询需要完全地重写。使用WordPress函数来访问类别的插件和主题仍然正常。


===Canonical URLs===
===Canonical URLs===
===规范的 URLs===
Another change in 2.3 that affects some plugins is the introduction of "canonical" URLs. The canonical URL system basically rewrites all URLs used in WordPress into "canonical" form, so that there is only one URL that points to a given display, and other URLs that could also point to that display are redirected to the "canonical" URL. Most plugins will not be affected by this change, but a plugin that adds suffixes to URLs could find that some of the URLs it generates are broken. Notably, a URL with a page number in it, such as example.com/page/2/ (to access the second page of older posts) ''must'' have the page section at the end of the URL. Prior versions of WordPress would have allowed example.com/page/2/suffix/ to work, but in WordPress 2.3, the URL must be generated as example.com/suffix/page/2 in order to function correctly.  
Another change in 2.3 that affects some plugins is the introduction of "canonical" URLs. The canonical URL system basically rewrites all URLs used in WordPress into "canonical" form, so that there is only one URL that points to a given display, and other URLs that could also point to that display are redirected to the "canonical" URL. Most plugins will not be affected by this change, but a plugin that adds suffixes to URLs could find that some of the URLs it generates are broken. Notably, a URL with a page number in it, such as example.com/page/2/ (to access the second page of older posts) ''must'' have the page section at the end of the URL. Prior versions of WordPress would have allowed example.com/page/2/suffix/ to work, but in WordPress 2.3, the URL must be generated as example.com/suffix/page/2 in order to function correctly.  
2.3版本影响插件的使用的另一个变化在于引进了"规范的" URLs。规范的URL系统基本上将WordPress使用的所有的URLs重写为"规范的" 形式,因此只有一个URL执行指定的显示内容,其它指向显示内容的URLs重新导向"规范的" URL。大多数插件不会受这种变化的影响,但是将后缀添加到URLs的插件就会发现产生的一些URLs毁坏了。 一般,如果URL中带有页码,如example.com/page/2/ (访问旧文章的第二个页面) ''必须'' 在URL的结尾带有页面部分。WordPress先前版本可能允许example.com/page/2/suffix/ 运行,但是在WordPress2.3版本中,URL必须创建为example.com/suffix/page/2 以正常地运行。


Note that if you use a non-standard url/permalink structure that is necessary for the functioning of your site, the "canonical url" functionality can be turned off by adding the following to a plugin file or the functions.php file in your template folder:  
Note that if you use a non-standard url/permalink structure that is necessary for the functioning of your site, the "canonical url" functionality can be turned off by adding the following to a plugin file or the functions.php file in your template folder:  
注意如果你使用不标准的url/permalink结构,对于运行你的站点是必须的,通过将下面的内容添加到插件文件或者添加到你的模板文件夹的functions.php文件,你可以关闭"标准的url"功能:
  remove_filter('template_redirect', 'redirect_canonical');
  remove_filter('template_redirect', 'redirect_canonical');
remove_filter('template_redirect', 'redirect_canonical');
WordPress 2.5 will make a further filter available for choosing which canonical redirects are denied rather than forcing them to be all on or all off.
WordPress 2.5 will make a further filter available for choosing which canonical redirects are denied rather than forcing them to be all on or all off.
WordPress会创建更深入的filter,用来选择否认哪个canonical redirects而不是迫使所有的canonical redirects打开或者关闭。

2008年9月18日 (四) 16:49的版本

Introduction

介绍

When a new major version of WordPress is released, such as WordPress 2.1 or 2.2, you may find that your Themes and Plugins no longer work the way you are used to. It could be that they are completely broken, because something in WordPress that was fundamental to them changed, but it's also possible that you can get them working again by updating some settings, or maybe just a small edit.

发行一个新的主要版本的WordPress,如WordPress2.1或者2.2,你可能发现你的主题和插件不再向以前那样运行。可能因为插件和主题完全毁坏了,因为WordPress中对它们而言至关重要的部分更改了,但是通过上传一些设置,或者只是简单地编辑一下,你可能有能够使得这些插件和主题正常运行。

This article is part of a series on WordPress:Migrating Plugins and Themes. It covers changes between WordPress WordPress:Version 2.2 and WordPress:Version 2.3, and what you need to do to Plugins and Themes to get them working in Version 2.3. You may also want to visit WordPress:Migrating Plugins and Themes to 2.5 if you want to support later versions.

这篇文章是升级插件和主题系列的一部分。包括2.2版本2.3版本之间的变化,你需要做的就是,使得插件和主题能够在2.3版本中运行。如果你想要支持以后的版本,你也可能也想要阅读将插件和主题升级到2.5版本

If the Theme or Plugin you are using was developed by someone else, there are several places to look for information:

如果你使用的主题或者插件是其他人开发的,你可以从下面的这些地点查找信息:



If you are the author of your Theme or Plugin, or if you have modified or customized your Theme, then this article will help you upgrade your Theme/Plugin for 2.3. If your Theme or Plugin is distributed publicly, after getting it working you may want to add it to the Compatibility lists above, so your users will know it is working and which version they should be running.

如果你是主题或者插件的作者,或者如果你更改或者自定义了主题,那么这篇文章会帮助你将主题/插件升级到2.3。如果你的主题或者插件是公开发行的版本,使得插件和主题运行之后,你希望将插件或者主题添加到上述的兼容性列表,这样你的用户会了解这些插件或者主题能够运行以及应该在哪个版本上运行。

Fixing Up Your Theme or Plugin

升级你的主题或者插件

Categories and Tags

类别和标签

The main change of importance to Plugins and Themes in WordPress:Version 2.3 was the introduction of tagging as a core WordPress functionality.

2.3版本中对于插件和主题而言,至关重要的变化在于引进了标签作为WordPress核心功能。

If you want to add tags to your theme (e.g. to display the tags used on a post, or put a tag cloud into your sidebar), you will be interested in new the_tags and wp_tag_cloud template tag functions.

如果你希望给你的主题添加标签(显示文章上使用的标签,或者将标签云放入你的边栏),你可能对新的the_tagswp_tag_cloud标签函数感兴趣。

There were also quite a few new tag-related functions for use in plugins introduced in WordPress 2.3.

在WordPress2.3版本引用的插件中也可以使用一些新的标签相关的函数。

Also, as a side effect of introducing tags to WordPress, the underlying database table structure, in regards to storage of categories, was changed considerably. So, any plugins that ran queries using the category-related tables in the WordPress database will likely be broken; the queries will have to be completely rewritten. Plugins and Themes that used WordPress functions to access categories should be OK.

向WordPress引进标签也会有负面效应,有关类别储存的潜在的数据库结构,会相应地更改。因此,因此任何使用WordPress数据库中类别相关的表格来运行查询的插件可能会毁坏;查询需要完全地重写。使用WordPress函数来访问类别的插件和主题仍然正常。

Canonical URLs

规范的 URLs

Another change in 2.3 that affects some plugins is the introduction of "canonical" URLs. The canonical URL system basically rewrites all URLs used in WordPress into "canonical" form, so that there is only one URL that points to a given display, and other URLs that could also point to that display are redirected to the "canonical" URL. Most plugins will not be affected by this change, but a plugin that adds suffixes to URLs could find that some of the URLs it generates are broken. Notably, a URL with a page number in it, such as example.com/page/2/ (to access the second page of older posts) must have the page section at the end of the URL. Prior versions of WordPress would have allowed example.com/page/2/suffix/ to work, but in WordPress 2.3, the URL must be generated as example.com/suffix/page/2 in order to function correctly.

2.3版本影响插件的使用的另一个变化在于引进了"规范的" URLs。规范的URL系统基本上将WordPress使用的所有的URLs重写为"规范的" 形式,因此只有一个URL执行指定的显示内容,其它指向显示内容的URLs重新导向"规范的" URL。大多数插件不会受这种变化的影响,但是将后缀添加到URLs的插件就会发现产生的一些URLs毁坏了。 一般,如果URL中带有页码,如example.com/page/2/ (访问旧文章的第二个页面) 必须 在URL的结尾带有页面部分。WordPress先前版本可能允许example.com/page/2/suffix/ 运行,但是在WordPress2.3版本中,URL必须创建为example.com/suffix/page/2 以正常地运行。

Note that if you use a non-standard url/permalink structure that is necessary for the functioning of your site, the "canonical url" functionality can be turned off by adding the following to a plugin file or the functions.php file in your template folder:

注意如果你使用不标准的url/permalink结构,对于运行你的站点是必须的,通过将下面的内容添加到插件文件或者添加到你的模板文件夹的functions.php文件,你可以关闭"标准的url"功能:

remove_filter('template_redirect', 'redirect_canonical');

remove_filter('template_redirect', 'redirect_canonical');

WordPress 2.5 will make a further filter available for choosing which canonical redirects are denied rather than forcing them to be all on or all off.

WordPress会创建更深入的filter,用来选择否认哪个canonical redirects而不是迫使所有的canonical redirects打开或者关闭。