WordPress: insert a user into the database

WordPress stores all user data in two tables, namely wp_users and wp_user_meta. If you've ever tried to insert a new user in the database, you've surely stumbled on some WordPress error while trying to display user preferences or profiles. The point is that both tables work together, so that if you fail to specify some data in one of these tables, you'll get an error. Fortunately, there's a solution.

jQuery: serialize elements outside forms

A good question today from Stack Overflow: how can we serialize an element which is not a form? jQuery provides the serialize() and serializeArray() methods that operate on forms by turning attributes and values into properties and values of a returned JSON object (the latter) or by building a standard query string (the former). However, creating a JSON object from an element is quite simple. Let's see why.

Coding doubts: what clients should know

Web projects fail not because they're poorly coded, but because our clients are full of doubts about the overall goal they want to achieve. Generally speaking, clients know only how a web site should look like, not how it should work. Information architecture, usability and SEO are the big taboos for them. Clients often ask to change the visual layout of a page or to add a new feature to the web site. They give us some PSD files, a couple of documents and images and they think it's all set and ready to be launched online. But they are not aware of the implications of what they're publishing. No briefing, no analysis, no brainstorming and no planning. Therefore a web developer should be an IA expert, a usability tester and a project manager, all in one (person). Too bad.

jQuery: password strength checker

We can use JavaScript regular expressions together with jQuery to create a simple plugin that checks the strength of a user-defined password. The concept behind is quite simple: every time a user types a character in the input field, the value inserted is compared against the corresponding regular expression. Passwords can be medium, weak or strong in terms of strength. Strength doesn't depend on the number of characters inserted, but on the combination of letters, digits and special characters. Let's see the details.

WordPress: display images from custom fields

A couple of weeks ago I finished a WordPress project which consists of a jQuery slot machine product slideshow. The problem with this plugin was to allow the administrator to insert all the required images and captions in order to make the slideshow work. For that reason, I used WordPress custom fields. The tricky part is to fetch the images attached via custom fields. Let's see how.

jQuery: smart Lavalamp menu plugin

Yesterday a friend of mine was in trouble because he desperately needed to create a jQuery Lavalamp menu for a client featuring some peculiar characteristics, such as the ability to start from the current page item and an intelligent movement sensor which allows the cursor to stay on the last selected item. I created for him a simple jQuery plugin that performs all these tasks. Let's see the details.

Integrating jQuery plugins in WordPress

One of the most frequently asked questions on forums, blogs and mailing lists concerns the integration of jQuery plugins with WordPress. Integrating jQuery plugins with WordPress is not a matter of queuing scripts only, but it also means understanding the correct hierarchy and order by which scripts are executed within WordPress. Let's see the details of this topic.

WordPress is for blogging: any other use is a costly mistake

I don't understand why most web agencies tend to use WordPress as a catch-all for every project they work on. In short, WordPress is a CMS designed to manage blogs or blog-like web sites. WordPress was not designed to manage e-commerce sites, communities or even newsletter or file downloads. The more the task diverges from the original design, the more it's likely that your project will fail or, if you're lucky and patient, need continuous assistance for bug fixing, maintenance and plugin customization. You'll probably end up with a disappointed and angry client and a significant increase of your budget costs. You don't deserve this.

jQuery: Observer Pattern on slideshows

I've just finished to work on an interesting jQuery/WordPress project (you can find it here) where I had to build an interactive slideshow very similar to a classic jQuery slot machine in its inner functioning. The only problem was to keep track of the visibility of the slides, that is, being sure that the current slide was visible. This is a fantastic use case for the Observer Pattern.

CSS reset considered evil

CSS resets are wrongly considered as a necessary part of any CSS template. After fixing a long series of WordPress themes that relied massively on this feature, I have to say that CSS resets are evil. More precisely, they're overused even when they're not necessary. Let me put it in this way: are we absolutely sure that all HTML elements must be reset? Are we absolutely sure that, in any circumstances and templates, we have to normalize the default rendering of all elements? Are we absolutely sure that all the default styles used by browsers on all elements need to be reduced to a lowest common denominator? Or, more properly, should we start rethinking the whole process behind normalization and realize that perhaps some default styles might be useful in some cases?

Alternatives to CSS hacks

The so-called "CSS hacks" are particular patterns used by authors to deliver style rules only to one browser or to prevent a browser from reading certain rules that might cause rendering problems. These patterns may rely on parsing bugs, wrong DOM implementations or syntactical constructs supported only by the targeted browser. Hacks may validate or not. In this article I'll review the most popular hacks used by authors, explaining why such patterns should be avoided and how one can actually target a browser by deploying other techniques.