Preview Google Webfonts with Fontjuggler

Last week I’ve been busy in my spare time writing a tool to preview Google webfonts on a live website. I always found it hard to chose a font from the Google webfonts list so I came up with a more visual way to pick a font for your website.
Fontjuggler let’s you load your (allready existing) website so you can chose the dom elements you want to apply a Google webfont to. Try it on http://www.fontjuggler.com.
Continue reading

Custom styles for Getsatisfaction feedback-widget button

I wanted to create a custom button for the Getsatisfaction feedback widget. The button on the left, right or bottom wasn’t satisfying me. I just wanted a link in my main menu. Sounds easy right? Well it drove me mad! So for those who wan’t a custom button themselves, a quick guide:
Continue reading

Delete malware warning counter-wordpress.com

There is a leak in old versions of TimThumb, read the article about it here. This week (started on august 22) many WordPress (with TimThumb) users encountered problems with there websites. Google marked there websites as a risk (including one of my websites).

The websites connected to counter-wordpress.com. The script/malware had the abbility to enter your database, create a database dump, play sounds (?), get your WordPress password and more.. With the curl_setopt function there were able to install php scripts on your server.
So for those who have problems, a quick guide to fix this. And for those who doesn’t have problems yet. Update TimThumb (latest version here)!

Fix this malware warning step by step:

Continue reading

Change the language of a Multisite

This week I had problems with changing the language of my multisite, for those who have the sample problem I wrote a quick guide:

On a normal WordPress installation you can change the language in your wp-config.php file. When I like to change the language to Dutch (by example) I define:

define ('WPLANG', 'nl_NL');

Make sure the language files (.mo) are located in your languages folder in wp-content.

But I recently tried this on a multisite, and nothing happened!

Continue reading

List subpages of a parent page

I’m using the wp_list_pages function a lot for displaying parent pages in the main menu.

I usually only show the parent pages without children (on a homepage). In the function I use depth=1 to only sum up the top level pages:

wp_list_pages('title_li=&depth=1' );

When visiting a page i like to sum up the subpages of the parent page in a submenu. Sometimes (when using a submenu on a left sidebar) i like to show the parent page again on the top of the subitems. I created a function for this which you can put in your functions.php template file. This function is only created to list 1 level of subpages, no sub-sub is supported (yet) on the moment. Maybe I will update the function when I need it myself :)

Continue reading

Add ‘first’ and ‘last’ class to wp_list_pages

As a frontend developer I like to have a lot of pre-defined classes in page lists, menu’s and things like that. Unfortunately WordPress doesn’t have a first and last class in the wp_list_pages function. I think this should be there by default!

Based on this piece of code (thanks Robert) I created a hook you can put in your functions.php template file. So the generated page list will get first and last classes, good luck!

/* last and first classes on wp_list_pages */
function wp_list_pages_firstlast($pageList) {
 
	$pageList = preg_replace('/class="/','class="first ', $pageList, 1);
 
	$reversedString = strrev($pageList);
	$reversedSearch = '/'.strrev('class="').'/';
	$endClass = strrev('class="last ');
 
	$pageList = strrev(preg_replace($reversedSearch,$endClass, $reversedString, 1));
 
	return $pageList;
}
add_filter('wp_list_pages', 'wp_list_pages_firstlast');

TimThumb upscale fix: stop timthumb from upscaling small images

TimThumb is hosted on http://code.google.com/p/timthumb/, more documentation on the website of the author BinaryMoon.
I had problem with TimThumb, first off all with my multisite but i found a nice fix written by my Dutch colleagues on http://www.letuslook.nl/how-to-make-timthumb-work-in-wordpress-multisite/.

Then TimThumb was scaling up my small images!

I searched for a couple of hours for a fix but no good results. The only interesting result I found was about the same issue I had (over here). In the issue they refered to an older version of TimThumb which is located here (#69). Well with that version i was capable of fixing my upscaling problem.

Continue reading

WordPress random post order not working (orderby=rand)

I had a situation where my random post wasn’t working at all, it just displayed the last added post or page (or custom post type).
I was running a custom query like:

<?php 
   query_posts('orderby=rand'); 
?>

I could be a plugin (like WP Sticky or in my case an other plugin) which is causing the problem. You can try to find and disable the plugin but a more easy solution is this:

Remove the filter before running the query:

<?php 
   remove_all_filters('posts_orderby');
   query_posts('orderby=rand'); 
?>

But watch out, the plugin which is causing the problem doesn’t adds the filter for fun, so you can wreck a plugin functionality with this solution, but it’s fast and easy :)

Verve Meta Boxes – WordPress Multi Site Timthumb fix

Timthumb doens’t work with a WordPress multi site (MU), fortunately there is a fix for this problem on the Binarymoon blog (developer of Timthumb).

Update: This fix is now included in the new version of Verve Meta Boxes!

But I also had this problem with Verve Meta Boxes. I didn’t generate thumbnails within my multi site installation. That’s because Verve is using Timthumb too.

Based on the solution by Binarymoon I managed to fix the Verve timthumb problem to by editing the plugin.

I’m using Verve meta boxes 1.2.6

On line 435 of verve-meta-boxes.php you will find the following code:

echo '<div><img src="'.plugins_url().'/verve-meta-boxes/tools/timthumb.php?src='.$meta_box_value.'&w=180&zc=1&q=95" alt="" />';

Change this to:

$theImageSrc = $meta_box_value;
global $blog_id;
if (isset($blog_id) && $blog_id > 0) {
$imageParts = explode('/files/', $theImageSrc);
    if (isset($imageParts[1])) {
        $theImageSrc = '/blogs.dir/' . $blog_id . '/files/' . $imageParts[1];
    }
}
echo '<div class="verve-img"><img src="'.plugins_url().'/verve-meta-boxes/tools/timthumb.php?src='.$theImageSrc.'&w=180&zc=1&q=95" alt="" />';

And your Verve meta boxes will generate thumbnails again within your WordPress multi site!

Update: This fix is now included in the new version of Verve Meta Boxes!

5 most used WordPress plugins (2)

An update on my 5 most used WordPress plugins. I’m working hard on a couple of WordPress websites and discovered some pretty nice plugins. So my list (of the last two months) changed:

  • More Fields – You can create more (meta) fields with this plugin for post, pages or custom posts. It’s easy and very user friendly. There are plenty of fields to chose from, but no image upload field.. well that’s why i developed Multiple Template Images. You could also look at Verve Meta Boxes. It has a image field but it’s not as user friendly like More Fields.
  • Custom Post type UI – You could also define your custom post types true your functions.php. Continue reading