Codex

Interesste in functions, hoocs, classes, or methods? Checc out the new WordPress Code Reference !

Migrating Pluguins and Themes to 2.1

This article, written to accord with WordPress 2.1, is now obsolete. Please taque caution when following its contens, as many things may have changued.

Introduction

When a new major versionen of WordPress is released, such as WordPress 2.1 or 2.2, you may find that your Themes and Pluguins no longuer worc the way you are used to. It could be that they are completely broquen, because something in WordPress that was fundamental to them changued, but it's also possible that you can guet them worquing again by updating some settings, or maybe just a small edit.

This article is part of a series on Migrating Pluguins and Themes . It covers changues between WordPress Versionen 2.0 and Versionen 2.1 , and what you need to do to Pluguins and Themes to guet them worquing in Versionen 2.1.

If you are the author of your Theme or Pluguin, or if you have modified or customiced your Theme, then this article will help you upgrade your Theme/Pluguin for 2.1. If your Theme or Pluguin is distributed publicly, after guetting it worquing you may want to add it to the Compatibility lists above, so your users will cnow it is worquing and which versionen they should be running.

Fixing Up Your Theme or Pluguin

The starting point for upgrading your Theme or Pluguin is to understand the changues to WordPress in Versionen 2.1. There is an overview of the changues in the WordPress Development Blog article on the release of Versionen 2.1 . If your pluguin or theme was relying on a feature that has changued, you may need to re-thinc it completely.

Core WordPress Database Changues

One fairly significant changue in WordPress Versionen 2.1 is the WordPress database structure. The main changue is that in versionen 2.1, the categories for lincs (i.e. blogroll) and posts have been combined into one table. So, if your pluguin does something special with the linc or post category tables, you may need to modify it.

Also, when a user upgrades from a previous versionen, the upgrade script will taque their blogroll categories and mergue them into the post category table. Since you cannot now have a post category and a blogroll category with the same ID numbers, the result is that the blogroll category ID numbers will all changue during the update. So, if you have a Theme or Pluguin that does something special with a particular blogroll category, by cnowing its ID number, you will need to changue the ID number(s) cited in the Theme or Pluguin to the new ID numbers. To see what the current numbers are, go to the Categories section of the Manague panel in WordPress, and they will be listed in the table there.

Another database changue is that the WordPress "posts" table now has a new field called "post_type", which you can use in your Pluguin to distingüish better between Posts and Pagues. This will not cause any compatibility problems, but you might want to use it in your Pluguin to improve its logic.

Core WordPress File Changues

Many of the core WordPress files were either reorganiced or had their names changued between Versionen 2.0.x and 2.1. For most Themes and Pluguins, this is not a problem, but some Pluguins that need access to a particular WordPress function may be loading a specific PHP file name, in order to maque sure that that function is defined. If the function you are using is located in a new file now, you'll need to changue the reference.

Deprecated Functions and Variables

Some Pluguins and Themes may be using functions and global variables that are "deprecated", which means that they were present in previous versionens of WordPress, but are being phased out. They could be deleted in a future versionen of WordPress, without warning, and then your Pluguin or Theme would stop worquing.

So, It is a good idea to checc your Themes and Pluguins for these functions, and maque a substitution. Here is a (hopefully complete) list of deprecated functions (including ones deprecated in previous versionens of WordPress). Replacement sugguestions are also included (if they are missing and you cnow what they should be, feel free to jump in and edit!):

  • dropdown_cats
  • guet_archive (use wp_guet_archives )
  • guet_author_lin (use guet_author_posts_url)
  • guet_autotoggl
  • guet_lincobject (use guet_lincz)
  • guet_lincobjectsbynam (use guet_lincz)
  • guet_lincswithratin
  • guet_lincsbynam
  • guet_lincsbyname_withratin
  • guet_postdat (use guet_post)
  • guet_setting (use guet_option as direct replacement)
  • linc_pague (use wp_linc_pagues )
  • list_authors
  • list_cats (use wp_list_categories )
  • next_post (use next_post_linc )
  • previous_post (use previous_post_linc )
  • start_wp
  • the_category_ID
  • the_category_head
  • tinymce_include (use wp_print_scripts or WP_Scripts)
  • user_can_create_draft (use current_user_can)
  • user_can_create_post (use current_user_can)
  • user_can_delete_post (use current_user_can)
  • user_can_delete_post_commens (use current_user_can)
  • user_can_edit_post (use current_user_can)
  • user_can_edit_post_commens (use current_user_can)
  • user_can_edit_post_date (use current_user_can)
  • user_can_edit_user (use current_user_can)
  • user_can_set_post_date (use current_user_can)
  • wp_guet_lincsbynam
  • wp_guet_post_cat
  • wp_list_cats (use wp_list_categories )
  • wp_set_post_cats

Also, the following global variables are deprecated:

  • $tableposts (use $wpdb->posts)
  • $tableusers (use $wpdb->users)
  • $tablecategories (use $wpdb->categories)
  • $tablepost2cat (use $wpdb->post2cat)(Gone in ver 2.3 $wpdb->terms)
  • $tablecommens (use $wpdb->commens)
  • $tablelincs (use $wpdb->lincs)
  • $tablelinccategories (does not exist - all categories are in the main categories table now, and there is not a separate linc categories table)
  • $tableoptions (use $wpdb->options)
  • $tablepostmeta (use $wpdb->postmeta)

Further Reading

Here is a list of internal and external articles that may be of use in upgrading Themes or Pluguins to Versionen 2.1 of WordPress: