WordPress Bits

Hacking WordPress. Keeping the bits together.

Archive for the ‘Widgets’ Category

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 »

Writing WordPress plugin. Widget Loader.

Posted by Leonid Mamchenkov on June 18, 2007

One of the best things about WordPress is its flexibility. For any given problem there are several solutions (“There is more than one way to do it” paradigm at work). There are many places where you can add code and markup – widgets, templates, plugins…

In this post, we’ll look at WordPress plugins. What are they? What can we do with them? How do we write them? We’ll go as far as create our own WordPress plugin from scratch. And it will be a useful one too.

Read the rest of this entry »

Posted in Plugins, Widgets, WordPress | 15 Comments »

Advanced widgets. Widgets with controls.

Posted by Leonid Mamchenkov on June 17, 2007

Hopefully, by now you understand how cool and powerful WordPress widgets are. Widgets 101 demonstrated how to create simple widgets with text paragraphs, HTML markup, and even some PHP code. What else is there? Not much, but something.

In this post we’ll take a look at how to create widgets which support options and easy configuration via administration interface. WordPress calls these widgets with controls.

Read the rest of this entry »

Posted in Widgets, WordPress | 11 Comments »

Simple widgets. Widgets 101.

Posted by Leonid Mamchenkov on June 16, 2007

In the last post I covered widget containers and promised to tell you how to create widgets. I also mentioned that widgets can be of a varying complexity – from simple text and HTML blocks, through customized WordPress function calls, to mini applications with their own administration interface.

That sounds like a lot to cover in one post. So, I’ll leave the advanced widgets for the next time. In this post we’ll look at simple things – text, HTML, some PHP and tailored WordPress function calls.

Read the rest of this entry »

Posted in Widgets, WordPress | 15 Comments »

Widgetized web site. Beyond sidebars.

Posted by Leonid Mamchenkov on June 16, 2007

WordPress widget is a powerful tool when used properly. Too bad, many people who use WordPress for web site building haven’t heard of them. And many of those who heard of them, don’t realize the full potential. In this post, I’ll try to put some light on WordPress widgets.

So, what is a widget and what is it good for? WordPress widget is a block of something. It can be as simple as a paragraph of text or a piece of HTML markup. It can be a customized call to some WordPress function. It can be a mini application. It can have its own options. And it can have its own administration area.

Read the rest of this entry »

Posted in Widgets, WordPress | 24 Comments »

Disable default WordPress widgets

Posted by Leonid Mamchenkov on June 15, 2007

I am currently building a web site, which uses WordPress as a platform. It’s not a blog, but an extended a very customized content management system (CMS) with several authors and a lot of custom plugins.

One of the things the client requested was maximum flexibility of the front page. They want to have a number of information blocks, such as currency quotes, market analysis, navigation menu, and advertising units; and they want to be able to rearrange them once in a while.

This is, of course, a perfect task for WordPress widgets. If you are not familiar with WordPress widgets, I only have two things to say to you right now:

  1. You are missing on a lot of fun.
  2. Subscribe to RSS feed of this blog, as I’ll be talking a lot about WordPress widgets.

Anyway. I have created all the widgets that they wanted, and I tested them to work properly. But there was a tiny problem. WordPress install comes with a few widgets of its own. Things like archives, blogroll, recent comments, and search box – all have a widget version. But most of these widgets, as good as they are for a regular blog, didn’t make any sense for this web site that I am working on. There are no archives. Calendar has a totally different meaning. And comments are disabled and hidden.

Of course, I could just left the widgets out of the sidebars. But why give user a choice which doesn’t work or makes no sense, right? I wanted them removed. Hidden. Unavailable. And I didn’t want to modify any core WordPress files, so that upgrading this web site to a newer version of WordPress is easier in the future.

Here is my solution to the problem.

Read the rest of this entry »

Posted in Widgets, WordPress | 12 Comments »