WordPress: add_filter or add_action? It actually doesn’t matter!

It’s a doctrine of WordPress plugin development:

Use actions to expand the functionality and filters to change information.

We’ve all heard it, we always follow that demand. Always? Well…

… if I want to add some functionality and nowhere near or far there is an action hook in the core but only a filter hook, I use that hook without considering the doctrine.

Surprisingly it works. But why? If we all insist that you have to use the right hook type, there has to be a difference between them. Let’s take a look behind the scenes (/wp-includes/plugin.php):

What? add_action does nothing but call add_filter and nothing else? There is no difference in functionality, it’s only a different name. So there is no reason why you shouldn’t use add_filter instead of add_action if you have no other solution.

I don’t say that you should interchange filter and action hooks at will. Using the correct hook type makes your code more readable and maintainable, for yourself and for others. Nevertheless, if there’s not other way to accomplish your goal but to use a filter hook instead of an action, don’t hesitate, it virtually makes no difference.

WordPress – You’ve got updates!

On March, 11th an update of the popular plugin “WordPress SEO” was published because the previous version contains serious security vulnerabilities (CSRF and blind SQL injection).
During the day some people noted that Yoast didn’t use all possible channels to call attention to the situation.

I personally couldn’t understand the problem because I already had installed the new version before noon. How could this be? Continue reading WordPress – You’ve got updates!

New version of Linklist (v0.4) WordPress plugin

A user of my WordPress plugin Linklist wanted to use it in conjunction with a Like/Unlike plugin.

Unfortunately Linklist also listed the like/unlike links of the plugin and put the list behind the Like icon:

linklist1

This is not the way it’s supposed to be. So I added two more options:

  1. You can define several class names of DIVs that will be excluded from being searched by Linklist. This option will also deal with incomplete DIVs (<div> without any closing div).
  2. You can set the priority of the plugin. This will enable Linklist to collect the links and add the list in the post before other plugins are adding their own content to the post.

In the above example the result will look like this:

linklist2

… and yes, Linklist is compatible with WordPress 3.8.

New ideas for pagebar v3 – Part 2: Customization by Drag’n Drop

Though pagebar is quite customizable you can’t define the overall look. “Previous page” is always on the most left, followed by “First” and so on but maybe you want the elements in a different order. I’m not aware that any of the paging plugins provide this feature, pagebar hopefully will do so in the next major version. Continue reading New ideas for pagebar v3 – Part 2: Customization by Drag’n Drop