Terrible experience with BDO Groningen

For my company I hired an accountant in Groningen, The Netherlands. In my case BDO Groningen. They also advice on taxes but unfortunately don’t understand that their clients benefit from paying less taxes.

An advice I received was described too near in the invoice which resulted in not being able to deduct it from taxes as a cost.

After mailing a couple of times, the company never wanted to change the description in such a way that I could deduct it from taxes. While my company always plays by the rules, there were some good arguments why it could be changed, at least for part of the process.

The end result,  a whopping 1400 EURO extra in tax obligations. Thank you BDO Groningen…

Posted in Uncategorized | Comments Off on Terrible experience with BDO Groningen

WordPress 3.5 – Image / Gallery Media uploader to custom plugin / meta box (easy)

With this simple and relative short code you can add the WordPress 3.5 Media Uploader to your own plugins. It will return single or multiple images and returns them in a comma seperated list.

If you want to return other attributes then  monitor the attributes using the console.


jQuery('#image_button').click(function(e) {
 frame = wp.media({
 title : 'Add your title here',
 frame: 'post',
 multiple : true, // set to false if you want only one image
 library : { type : 'image'},
 button : { text : 'Add Image' },
 frame.on('close',function(data) {
 var imageArray = [];
 images = frame.state().get('selection');
 images.each(function(image) {
imageArray.push(image.attributes.url); // want other attributes? Check the available ones with console.log(image.attributes);

 jQuery("#imageurls").val(imageArray.join(",")); // Adds all image URL's comma seperated to a text input


<input type="text" name="imageurls" id="imageurls" />
 <input type= "button" class="button" name="image_button" id="image_button" value="Add Image(s)" />
Posted in Wordpress | Tagged , | 2 Comments

Fixing WordPress error: An error occurred in the upload. Please try again later

I’ve been spending a considerable amount of time in fixing the WordPress error: An error occurred in the upload. Please try again later. I received this error when trying to add image upload functionality to my own custom plugin.

I had a hard time debugging and first focussed on the Javascript. Unfortunately I couldn’t find the cause of the error and nearly gave up.

Then I remembered the obvious. The media upload element uses Ajax for uploading and return information about the uploaded image.

I assume you have WP_DEBUG = true in your config file, if not, make sure to add it to wp-config.php.

After that, use FireFox or Chrome developer tools and monitor the Ajax requests. You’ll notice requests to admin-ajax.php and async-upload.php. By looking at the responses the error was obvious, there was a conflict with (in my case, the custom permalink plugin) which gave me notices in the Ajax response. When I changed some code, it was solved and uploading media worked great!

So if you want to debug the mentioned issue, then make sure to monitor the Ajax requests, you might find the cause. Good luck and feel free to ask in case you need help!

Posted in Wordpress | Tagged , | 2 Comments

Google now also reports about old versions of software

When I logged in to Google Webmastertools today I was presented with a message that I’m using an old version of Vbulletin on one of my websites. Vbulletin is currently in the 4.x.x. version but in the 3.x.x versions there is still a maintained one, which we’re using. But it’s probably good that Google monitors for it as many outdated versions come with security vulnerabilities. I hope to update to the 4.x.x. branch soon but as our forum is rather large this is more than simply running the update script.

Posted in Google | Comments Off on Google now also reports about old versions of software

WordPress wp_list_comments callback explanation

When working with comments you might want to drastically change the appearance of the comments. You can use a new comment template with

comments_template( '/my-comments.php', true )

which you call from the template where you want to list the comments. But if you want each single comment to be different, you can use the callback function of wp_list_comments.

You use wp_list_comments in your comments template. Default is comments.php in your theme function, but if you used the comments_template function from above, you have to look for that file (of course). You should see wp_list_comments like the The Loop on it’s own. It goes through all of the comments and lists them. With the callback you can modify The Comment Loop and totally make it to your own likings.

global $my_object;
wp_list_comments(array('type' => 'all', 'callback', array($my_object, 'my_custom_comments'));

I’m using classes in my plugins, hence the inclusion of the global, you can also put the function in your functions.php and simply remove the references to the object. Then you can create a function in your class or functions.php and start the fun:

function my_custom_comments($comment, $args, $depth){
        $GLOBALS['comment'] = $comment;

In it, you can use the Comments Tags which are listed here. Questions? I’m happy to help you a little further, so don’t hesitate to post!

Posted in Uncategorized | Comments Off on WordPress wp_list_comments callback explanation

WordPress get_comment_meta and update_comment_meta

WordPress now features a function to allow you to store meta data for each comment. Just like it’s able to do so for posts. It seems that, under the hood, WordPress has functionality that potentially prepares it for metadata on whatever you want. As get_comment_meta is nothing but a call to update_meta with the first parameter prefilled with ‘comment’.

Anyway, when you are reading this you are probably looking for a way to get get_comment_meta working. It’s not documented in the Codex (yet) and other information on the web is not always easy to understand or complete. So here’s my try to make you understand get_comment_meta and with it comes update_comment_meta.

  • update_comment_meta -> will allow us to update a comment meta entry and is also used to create a meta entry
  • get_comment_meta -> will alows us to retreive the meta entry for each comment

The metadata for the comments is stored in the database in its own table and the comment ID is required to link the comment to its metadata.

To add comment metadata, a simple call to it like this will make it work:

update_comment_meta($comment_id, 'key', 'value');

If you save the data when someone is adding a new comment, you would probably receive the $comment_id from a call to e.g. wp_new_comment.

Retrieving the comment metadata is a little different than expected, it has a small (and simple) twist. The trick is in the third parameter here:

get_comment_meta($comment_id, 'key', true);

This will return a single result (e.g. string) while the following will result in returing an array:

get_comment_meta($comment_id, 'key');

It’s as simple as this! In case you want the comment ID while retrieving comments, you can replace $comment_id with get_comment_ID();

Posted in Uncategorized | 1 Comment

Features to expect in WordPress 3.2 (to be released Q2/Q3 2011)

WordPress 3.1 has just been released and I, as a WordPress addict, am already searching for information on WordPress 3.2. This release is scheduled for the first half of 2011. One thing seems to be sure, WordPress 3.2 will no longer support PHP4 and MySQL4. Besides that I found other features that are scheduled to appear in WordPress 3.2. Here is a list of features that affect end-users:

  • Minimum version for PHP: 5.2
  • Minimum version for MySQL: 5.0.15
  • Download required translations from GlotPress – This means that WordPress itself, themes and plugins are able to download translations from one, group a collaborative, web-based software translation tool. This would help getting translations automatically without any manual searching and downloading .mo files
  • Administration menu revamp – For plugin developers the current setup of the administration menu is a lot of hassle. With a rewrite/restructuring of the code this is improved
  • User can register/login with e-mail address, no username required anymore, functionality currently available in this plugin
  • Timezone suggestion, based on IP address
  • To be updated when more comes available, tips are very welcome!
Posted in Uncategorized | Comments Off on Features to expect in WordPress 3.2 (to be released Q2/Q3 2011)

How to make WPML compatible with W3C Total Cache

If you’re a heavy user of WordPress and use WMPL together with W3C Total Cache then you might have found out that it doesn’t work properly when using alias domains for each language. The language switcher doesn’t work correctly anymore. It seems that it switches to the first cached page and/or sometimes a random page. It might work for all pages except the home, but can also affect all pages on the website.

The default setting for the disk cache on W3C Total Cache is enhanced. Simply by changing this option to basic, both plugins will work together flawlessly. In enhanced mode the caching plugin fiddles with the headers of the HTTP request, in basic mode it keeps them as they are.

Update: Added clarifications as per the comment of Richard

Posted in Wordpress | 3 Comments

Retrieve server/host Windows version

Not one of the easiest jobs, is retrieving the version information of your Windows computer with PHP. Other methods are available, but they don’t show you the exact version, usually just report WINNT or similair strings. The code below will print the full information on your computer, easy as that…

    $com_object = new COM ( 'winmgmts://localhost/root/CIMV2' );
    $os =  $com_object->ExecQuery("Select * from Win32_OperatingSystem");

    foreach ($os as $os_data )
                //  Windows version information e.g. 6.1.7600  for Windows 7
		$windows_version = $os_data->Version; 
                // Full name of Windows version e.g. Microsoft Windows 7 Professional 
		$windows_caption = $os_data->Caption; 
                // Major Service Pack version (0 if not available)
		$windows_sp = $os_data->ServicePackMajorVersion; 

Posted in Wordpress | Comments Off on Retrieve server/host Windows version

WordPress shortcode output buffer versus appending to string

When your develop a WordPress plugin there is a big chance that you will need to include a shortcode. If you simply echo each line, you will notice that your output will not appear on the right place. This is because WordPress will output your code as soon as it encounters the echo. Therefore you should use a different way to get your output on the page. This will ensure that the output will appear on the place where you’ve added the shortcode.

1) You can use the output buffer of PHP, by starting it with ob_start(). Then simply use echo to output your lines. Once you’ve defined your output you can collect your output to a variable, with ob_get_contents() and return this:

function my_shortcode() {
echo 'hello world';
echo 'This is a WordPress shortcode';
$output_string = ob_get_contents();
return $output_string;

This will ensure that all your output will be catched by the output buffer and returned. When using multiple shortcodes on a page, this can cause conflicts.

2) Another option is to append strings, this would mean we would rewrite the code above to:

function my_shortcode() {
$output_string = 'hello world';
$output_string .= 'This is a WordPress shortcode';
return $output_string;

This should solve any problems with the output of your WordPress shortcode appearing on the wrong place.

Posted in Wordpress | 4 Comments