WordPress Bits

Hacking WordPress. Keeping the bits together.

Tip #3 : Under Construction

Posted by Leonid Mamchenkov on August 20, 2007

It is often desired to have a final version of the project on the production server for testing purposes, but so that nobody other than site administrators could see things. Also, once in a while, one needs to have a “Site under maintenance” page, even if for just a little while.

There are, of course, many ways to achieve the desired effect (e.g.: using a custom theme or an index.html preceding index.php). But probably the easiest and the most “proper” is by using Maintenance Mode Plugin. It provides a number of options to customize the displayed message, as well give visitors a hint of when it is better to come back. But what is more important, it allows logged in Administrators to see and use the web site like usual – invaluable for testing, as well demonstrations of a ready project to the client.

Posted in WordPress Tips | 26 Comments »

Making WordPress themes I : static basics

Posted by Leonid Mamchenkov on August 17, 2007

We’ve spent some time on WordPress internals already.  We looked at how things work in general, and how we can create plugins and widgets.  It’s time to look at another powerful tool that we have at our disposal – WordPress themes.

The topic of WordPress themes is large, but not complex.  I think it is better to separate it into several posts, each covering smaller parts with specific goals and examples.  In this First Post ™ we’ll see how to use WordPress themes to create the basics of basic web sites, as static, small, and simple as possible.

Read the rest of this entry »

Posted in Themes, WordPress | 45 Comments »

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 »

Tip #1 : Lorem Ipsum – the king of test data

Posted by Leonid Mamchenkov on August 14, 2007

(With this post I’m starting a new category – WordPress Tips. It should carry small posts which make a life of WordPress hacker easier. If you have a tip, please let me know. )

While developing WordPress sites one often needs some test data. Sample blog posts, pages, comments, and thinks like that. When done manually, one often uses “this is a test” or “blah blah” sort of things. These are often too short, and longer version take too much time produce. There is a better way. It’s called “Lorem Ipsum“.

There are several tools online which generate Lorem Ipsum texts for you. However I found that Dummy Lipsum Firefox extension works best for me. Install it, restart your Firefox, right click over any text area, and select “Insert Dummy Lipsum“. Here is a sample of what you’ll get.

Aenean et risus eu purus porta aliquam. Proin rhoncus ornare elit. Donec leo dolor, posuere quis, mattis sit amet, pharetra id, pede. Proin nonummy vulputate augue. Cras mollis pretium pede. Sed consectetuer eros feugiat velit. Pellentesque elit. Curabitur nec dolor mattis sapien imperdiet mattis. Nam interdum ipsum. Sed tortor lacus, feugiat non, sollicitudin quis, interdum vel, purus. Proin ultrices ligula vel augue. Proin augue arcu, accumsan porta, fermentum sed, aliquam vitae, magna. Donec mauris metus, blandit a, egestas vitae, feugiat quis, risus.

Posted in WordPress Tips | 27 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 »