WordPress:WordPress Housekeeping

来自站长百科
Xxf3325讨论 | 贡献2008年4月10日 (四) 10:00的版本 (新页面: =Cleaning Your WordPress House= Just as with your house, WordPress requires a little housekeeping once in a while to keep it working right. Here is a list of things you should do on a [[W...)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航、​ 搜索

Cleaning Your WordPress House

Just as with your house, WordPress requires a little housekeeping once in a while to keep it working right. Here is a list of things you should do on a regularly scheduled basis to keep your WordPress site running smoothly.

Upgrade WordPress

If a new release of WordPress is out, we recommend that you upgrade. These new releases often include new and improved features and fixes. You don't have to install a new release the very day it comes out. You can wait. It is recommended to check in with WordPress for updates and upgrades at least every three months, six months at the most. Check WordPress or WordPress Downloads for latest version available.

Plugins

WordPress:Plugins are an exciting feature of WordPress. They add functions and features to your WordPress site such as adding customized post listings to featuring a local weather forecast on your site.

With the hundreds of plugins available, it's fun to test drive them, trying out different ones to see what they will do, if you need them, and if they really add to your site or clutter things up. Once in a while, you should do a little housekeeping on your plugins.

Upgrade Plugins

Every three to six months, check for the latest plugin version. This is easy to do from the Administration > Plugin Panel. On the left is a column that links to the plugin author's site or the site of the plugin's source and documentation, sometimes the WordPress Plugins Repository. Note the version number in the list and click on the link to visit the site and see if you have the latest version. If not, consider downloading and installing the newest version.

Delete Old or Unwanted Plugins

Many times a plugin doesn't fit your site or you don't need it, but you leave it there just in case. These tend to pile up in your Administration > Plugins Panel, making your plugin list long and cumbersome to scroll through. If left there long enough, they might become obsolete with the new WordPress versions. Check your Plugins panel about every three to six months and clean out the stuff you know you won't use.

Plugin Admin Screen|thumbBegin your Plugins housekeeping by visiting the plugin author's site to see if there are instructions on how to uninstall the plugin via the Plugins panel on the left side of the screen. Some plugins require adding tags and code to your Template files while others require modification of the WordPress administration files. Be sure and read through the plugin's uninstall instructions to remove each of these modifications so your site will not have errors when the plugin is turned off.

If no specific instructions for uninstalling exist, then read through the installation instructions to check for modifications, if applicable, and reverse their changes, if implemented. If it has been a long time since you used this plugin, you still might have left its modifications in your template files and forgotten them. Carefully remove them.

To remove a plugin, make sure the plugin is deactivated from the Administration > Plugins Panel. Go to your website's wp-content/plugins folder (usually with an FTP program) and look for the file name of the plugin you want to remove. Select the file name and delete it.

If have your WordPress site on your hard drive, open the wp-content/plugins folder on your site and find the file name of the plugin you want to delete, select it and delete it. This way, if you have to restore or copy your Plugin folder to your website, you won't restore the unwanted plugin on your site.

New Plugins

WordPress plugins are being added constantly. Maybe there is a new plugin that will do what one of your older plugins do, but better? Maybe there is a plugin out there that will add functionality that will benefit your WordPress site?

Every three to six months search the Internet or visit the WordPress plugin sites to see if there are any new plugins available that will improve your site. If they replace the functions of a plugin you already have installed, be sure and follow the plugin author's instructions for removal or the tips in the [[WordPress:#Delete Old or Unwanted Plugins| Delete Old or Unwanted Plugins]] section in this article.


Theme Housekeeping

Just like plugins, many users love test driving all the different WordPress Themes available. Some users might have twenty or more Themes in their Administration > Presentation theme list. If you aren't using them, why not do a little housekeeping on your themes?

Admin Presenation Panel|thumbTo remove a theme from your WordPress site, check the Administration > Presentation Panel to make sure you aren't using that particular theme.

Then open your website (using an FTP program) and look in the wp-content/themes/ folder for the specific theme you wish to remove. Highlight its folder within the wp-content/themes/ folder and delete it.

If you keep your WordPress website on your hard drive, go to the wp-content/themes/ folder and delete the unwanted theme folder so you won't re-upload that theme in the future.

If you have been developing and designing your own theme to tweak it to exactly what you want, and it's been working well for a while, it might be time to do a little housekeeping on your theme templates and style sheet.

Theme Template Files

While you were designing your template files, you probably added a few things you commented out because they didn't work right or you weren't sure you really needed them, but left them there just in case you wanted them later. If you still don't want them, go through your template files and delete those commented out codes and tags.

[[WordPress:#Site Optimizaton|Optimizing your templates and style sheet]] is part of the normal activity of website designers and developers. While you have your template files open, take a moment to clean out some unwanted spaces. Having spaces before a code is fine, but there may be hidden ones after your code lines that just make the file size larger. There also might be three blank lines before some of the code when a single blank line might be all you need to separate some code from the pack. Delete those blank lines, but take care not to remove any spacing that should be left. Familiarity with PHP and HTML helps with this process.


Cleaning the Style Sheet

Just as with your template files, it may be time to do a little housekeeping on your styles.css file in your Theme folder. There is [[WordPress:#Site Optimizaton|more information on optimizing your style sheet]] below, but start first by cleaning out the unwanted stuff in your style sheet.

Look for comments you've made to remind you of the things you did and changed. Do you still need them to remind you of modifications you made, or can they be deleted?

Look for triple space lines between style sections and delete those down to one blank line to clean up your file size.

Is your style sheet a jumble of style references? Is it grouped alphabetically and are you tired of hunting through lines of code to find everything in your core structure (header, content, sidebar, footer) when it might be more convenient to group these together? Or maybe you have it grouped by section and similarity and you want it sorted alphabetically. Either way, it might be time to do a little housekeeping and arrange your style sheet the way that works best for your needs.


Get a New Theme

Tired of your old theme's look? Maybe it's time to do a little presentation housekeeping and change the look of your WordPress site. With the addition of Themes in WordPress v1.5, changing your site's look is easy.

Check out the various resources for WordPress Themes. If you find one you like, download it and install it according to the theme author's instructions and then activate it from the Administration > Presentation Panel.

Don't worry, your old theme will still be there. Test drive the new one for a while. You can always go back to the old one. If you are really determined to turn your theme housekeeping efforts into some serious work, check out the article on WordPress:Theme Development to create your own unique theme.

Unwanted Images

Many users upload a lot of graphics to their site that they end up never using. If you find yourself with a lot of unused graphics and images, consider going through them and cleaning house by deleting them. Double check that they are also removed from your hard drive WordPress folder, so you don't add them back in the future.

If you aren't sure you will never need them again, but you aren't using them now and want to remove them from your site if server site space is limited, move them to a folder in your hard drive WordPress folder called backupimages or something similar and store them there, just in case.


Site Optimization

If you are using a WordPress Theme you haven't modified, you shouldn't have to worry about optimizing your website. Still, it might help. Site optimization means creating a "lean and mean" website that loads fast, is easy on the bandwidth, validates, and meets web standards.

WordPress stresses that code and style files should validate and be laid out with a lot of tabs so they are easy to read. The World Wide Web Consortium and the Web Standards Organization stresses that all web page code be compliant with their standards. If you are going to get into this, you should familiarize yourself with the most basic of these standards.

One of those standards is to present a clean and optimized style sheet and XHTML code. We've covered some of the housekeeping cleaning chores associated with WordPress files and functions, but if you really want to streamline your site's code, take it a step further and look into your site optimization options.

Basically, total site optimization means validating your site's HTML and CSS, testing the site's design across browsers, ensuring web standards are met, including standards for accessibility - but let's start with some simple cleaning.

Every space, character, and bit in your code and style sheets add up to bytes. That sentence came to about 64 bytes. Each byte of information adds up, and the larger they are, the longer they take to load. Do yourself and your users a favor by keeping your file sizes to a minimum. So where do all these bandwidth wasters hide?

If you have set your code to look pretty with lots of indents, have you checked to see if there are any TAB codes at the end of the line before the line break? In some themes, there tend to be a lot of those. You don't need a TAB before a line break, only after, but somehow, these sneak into the code.

Using spaces to line up code adds to the size. A TAB is considered one character in most editors, but the five spaces that copy the TAB indent takes up five characters. Using double spaces instead of single spaces in your code and styles adds up, too.

Using a good search and replace capable text editor, you can quickly clean these up, making your styles and code optimized for fast loading.

There are a lot of ways of optimizing your code and styles, and here are some resources for more information on creating lean and mean code:

Optimization Resources Code

Speeding Up Your Site

Maintenance Schedule

In the article, Lessons: WordPress Site Maintenance, we cover website maintenance, but take a moment now to go through this list of WordPress housekeeping chores and add them to your calendar so you can clean up your site on a regular basis, keeping your WordPress site a lean and clean site to visit.