WordPress2.1发布的数据结构变化

在官方网站上发布了“Is your plugin Naughty or Nice?”,主要介绍了可能影响到WP现有插件对未来的WP2.1的支持问题。

WordPress 2.1 is almost here and you know what that means for developers. It’s time

to pull out those old plugins you’ve had stashed, blow off the dust and start applying some spit and polish and make sure it will last longer than Grandma’s Ham and Bean soup that has been sitting in the refrigerator for weeks.

Many of the big changes in WordPress 2.1 are MySQL related so grab a pen and paper (or open Notepad) and start taking notes.

  • The $table* variables have all been eliminated. They have not been deprecated as doing so would mean that the variables are still present but developers are no longer encouraged to use them. In this case, they have been removed from the core. When you’re developing plugins that contain SQL statements, ensure you globalize $wpdb, and call tables using $wpdb->posts, $wpdb->post2cat, etc. Likewise, the former $table_prefix variable that developers could globalize before to find the MySQL table prefix defined in wp-config.php has also been deprecated in favor of $wpdb->prefix.
  • Developers using the former linkcategories table should be aware that link categories are now part of categories. They are simply given another category ID and are not maintained separate from post categories.
  • The posts table now has a column of post_type that should help developers distinguish between posts and pages.
  • Future posts now gain the post_status of ‘future’ which eliminates the use of NOW() in all queries in the core. Plugin developers should follow suit.

WordPress 2.1 is nearing the time when the codebase will be released for testing, but it’s not too early to get those plugins and themes tweaked for the release. There is a Codex page where plugin compatibility is being tracked as well.

Editor’s note: If you stick to the WP APIs as much as possible you won’t run into plugin upgrade issues like this.

发表评论

电子邮件地址不会被公开。 必填项已用*标注

*