WordPress Bits

Hacking WordPress. Keeping the bits together.

Archive for the ‘WordPress’ Category

Tip #2 : Scheduling tasks with WordPress

Posted by Leonid Mamchenkov on August 15, 2007

Since WordPress 2.1 there is a way to schedule tasks from within WordPress (as opposite to using external schedulers). It is quite useful for doing systematic backups, cleaning user databases, importing data from other resources into your database, and things like that.

Glenn Slaven wrote a nice article – “Timing is everything: scheduling in WordPress” – explaining how to use this feature. If you read it through, tried, and failed to make it work, there is a Cron Demo plugin, which should get you started.

Posted in Plugins, WordPress, WordPress Tips | 7 Comments »

Adding options to WordPress plugins

Posted by Leonid Mamchenkov on August 15, 2007

Most WordPress plugins out there are simple things, fixing or changing one thing at a time.  But there are also examples of more complex things, like e-commerce and banner management, advanced anti-SPAM control, more flexible content and user management, etc.  One of the common things between those “advanced” plugins is that they almost always provide a user with a way to configure them – a screen with options.

In this post, we’ll see how to create plugins which integrate into WordPress options administration.

Read the rest of this entry »

Posted in Documentation, Menu, Options, Plugins, WordPress | 55 Comments »

Navigating WordPress source code

Posted by Leonid Mamchenkov on August 14, 2007

If you really want to know how WordPress works, if you want to know what you can do with it and what you can’t, if you want to understand how to solve your problems with WordPress, there is one thing that you absolutely have to do. No matter how many plugins you play with. No matter how many themes you install. No matter how many tips and tricks you read about. You have to look inside WordPress. Spend some time with its source code.

But not to worry! I probably made it sound much more scary than it is. In this post, we’ll look at a few ways of how to get familiar with WordPress source code and what resources are out there to help us in the process.

Read the rest of this entry »

Posted in Documentation, WordPress | 23 Comments »

WordPress Options follow-up

Posted by Leonid Mamchenkov on August 12, 2007

After the “Quick access to WordPress options” post got published, I’ve got plenty of questions, most of which could be rephrased as one of the two:

  1. What does each displayed option mean?
  2. How can I delete unused options?

While a comprehensive description of each option is yet to be done, I thought I’d do another post with a few links that might clear up some confusion.

Read the rest of this entry »

Posted in Database, Options, Plugins, WordPress | 5 Comments »

Cleaning up after the WordPress widget party

Posted by Leonid Mamchenkov on August 11, 2007

In one of the recent posts – “Advanced Widgets. Widgets with controls.” – we saw how to create WordPress widgets, which could have configuration options.  In one of the comments to that post, Matthew Smith, asked a very good question:

do the widgets leave settings in the database upon removal? Should these be cleaned up using a hook like unregister_widget() (if it exists, I haven’t looked yet)? Or does WordPress do this automatically?

Nicely spotted, Matthew!  Thank you.

Indeed, what happens there?

Read the rest of this entry »

Posted in Plugins, Widgets, WordPress | 14 Comments »

Automating WordPress customizations – the install.php way

Posted by Leonid Mamchenkov on August 10, 2007

In “Automating WordPress customizations – the plugin way” we looked at how to change a whole bunch of thing in one go by having our own plugin.  The plugin approach can save a lot of time, but it does not actually give any control over the installation process.

Often we want to interfere with the way things are.  For example, upon successful WordPress installation you find a web site with one post (“Hello World!”), one page (“About”), and a test comment to the first post.  Also, there is a category “Uncategorized”, and “admin” user, and a few other things in the database, which are not so obvious (for example, user roles, such as Administrator, Editor, and Subscriber).

There are also a few things, which are happening during the installation process itself.  For example, a random password for the administrator is generation, and email is sent to the administrator’s address with credentials and new site details.  As handy as it is for a friend’s new blog, there are many situations when we don’t want this done, or want it done differently.

WordPress has a way to control installation flow via a custom install.php file, which saves you from all the problems of core files editing.  In this post, we’ll see how to use this feature and what can actually be done with it.

Read the rest of this entry »

Posted in Database, Options, WordPress | 31 Comments »

Automating WordPress customizations – the plugin way

Posted by Leonid Mamchenkov on August 9, 2007

If you installed WordPress more than two times, you know the drill. Download the latest version, unzip or untar, copy config-sample.php into config.php, edit config.php, upload files to your web host, visit new WordPress URL, click “Next Step” a couple of times, while submitting blog name and administrator’s email. After all is done, login with username “admin” and provided random password, go to Options menu, and set things the way you want them to be. Then upload and activate chosen plugins, and then switch theme to something you’ve spent some time searching for or designing.

Overall, the process is very simple and straight forward. And there are rumors that it will be even simpler in upcoming versions of WordPress. It’s all nice and good. But there is something that only you can make better.

If you installed WordPress more than two times, and by now we know you did, chances are you have a certain way of configuring things. You probably use the same administrator’s email. Or want to use a pre-defined password, not a randomly generated one, because you seriously can’t remember random passwords for those 20 test WordPress installations just on your laptop. Now, going through Options, setting things the same every time is boring.

There are, of course, better ways. In this post we’ll see how to automate this task with a plugin. In one of the near future posts we’ll see how to do even better with a custom install.php file.

Read the rest of this entry »

Posted in Options, Plugins, WordPress | 35 Comments »

A look inside the WordPress database

Posted by Leonid Mamchenkov on August 8, 2007

Update: This article is also available in Chinese (thanks to Denis).

WordPress, as most other modern content management systems, is a very database-centric application. It keeps all information in the database – blog settings, posts, comments, links, users, etc. Therefor it is important to understand how the database is organized, what types of data is stored there, and how different things are linked to each other.

Read the rest of this entry »

Posted in Database, WordPress | 95 Comments »

Quick access to WordPress options

Posted by Leonid Mamchenkov on August 7, 2007

One of the first things that you probably check right after upgrade to a new WordPress version is the Options menu in the administration interface. Is there something new? Are there more ways that WordPress can be tweaked and tuned now? Can I … Anyway, I don’t have to tell you about it. You know.

But what you probably don’t know is that there is a quick way to see all WordPress options on one screen. Even those that aren’t accessible through the Options menu interface. And not only that, but you can even edit all those options at once.

To access the page with all options, go to your administration interface, and append options.php to the URL, so that it looks something like http://domain/blog/wp-admin/options.php .

All WordPress Options on a single screen

We will come back one day to this topic to see how this can be useful (hint: plugin development). Until then remember that it is pretty easy to break and destroy your WordPress installation buy editing these options directly. You should stick to the regular interface of the Options administration. Be warned.

Update: Obviously, I left out the most interesting part – how to do a cleanup of old options, left by plugin installations. All these options are stored in wp_options table in your WordPress database.  You can use your favorite MySQL administration tool (be that mysql command or PHPMyAdmin or something else) to remove the rows which you are totally sure you don’t need.  You can either use “DELETE FROM wp_options WHERE option_name = ‘some_option’” SQL statement, or a bit safer version – “SELECT option_id,option_name FROM wp_options WHERE option_name = ‘some_option’” to find out the ID of the option, and then “DELETE FROM wp_options WHERE option_id = XX” (substitute XX with option ID that you find in the previous query).  Note that these SQL queries assume that the prefix of your WordPress tables is “wp_”.  You should change table names in the queries accordingly, if you use a different prefix.

Posted in Options, WordPress | 56 Comments »

 
Design a site like this with WordPress.com
Get started