WordPress Jeopardy

The idea of a little game in WordPress came at the WordCamp Switzerland in early 2011. For an interactive session at the WordCamp Germany in Cologne in 2011, one of the creators Thomas, thought that it’d be nice to have a game-session.

On 24th of September started the first WordPress Jeopardy Game Session. For that, the whole room was divided in two teams to battle each other. The points were counted, but nobody really knows who won.
Continue reading …

Replace p-Tag on Images in Content of WordPress

Personally I think the use of HTML5 makes sense and I like the new possibilities, also in the field of semantics. WordPress has a feature on delivering content that come from the editor – setting breaks and paragraphs. Since forever WordPress is the reason for that, not TinyMCE and the same applies to the integration of images or other elements of this kind. In order to use HTML5 in a perfect way I had to replace the p-Tag with the figure-Tag and so is this small filter was created.
Continue reading …

Force Reload of Scripts and Stylesheets in your Plugin or Theme

If you're developing a WordPress theme or plugin you may have had the problem that scripts or stylesheets are not reloaded from the source when you refresh the page because they are cached somewhere on the way from the server to the browser. There are various methods to suppress this behaviour like disabling the browser cache in the options or by using a web development add-on. Sometimes this simply does not work because it's not always apparent where the content is cached since there are so many possibilities and you may have missed to disable all of them.

WordPress provides a simple method to ensure that all stylesheets and scripts are reloaded from the source when they have changed by providing a version parameter:

wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer );
wp_enqueue_style( $handle, $src, $deps, $ver, $media);

You can increase the $ver parameter every time you've changed the files:

wp_enqueue_script( 'my_script', 'my_script.js', '', '0.11' );
wp_enqueue_style( 'my_style', 'my_style.css', '', '0.11' );

The URL of the stylesheet/script will be changed to '.../my_script.js?ver=0.11' so that every caching system detects the changed file and reloads it from its source and the user always gets the recent version.

But to change the version number manually every time in the development stage would be a bit tedious and you're a programmer, right? So let's automate this:

wp_enqueue_script( 'my_script', 'my_script.js', '', time() );
wp_enqueue_style( 'my_style', 'my_style.css', '', time() );

The value of time() changes every second so the version ID of the file changes constantly and it's reloaded from the source and not from some cache.

It's a bit disadvantageous that you have to substitute the time based version parameter by a "real" version number every time you deploy your code since the actual user still should have the benefits of cached scripts and stylesheets. Let's extend the idea:

define ('VERSION', '1.1');

function version_id() {
  if ( WP_DEBUG )
    return time();
  return VERSION;

wp_enqueue_script( 'my_script', 'my_script.js', '', version_id() );
wp_enqueue_style( 'my_style', 'my_style.css', '', version_id() );

This way you can make sure that in your development environment everything is reloaded from source all the time but a productive server takes advantage of caches.

Frank holding a session at WordCamp Germany

Winner of Xtreme One WordPress Framework And Pictures of WordCamp Germany!

Thanks a lot for the great participation to win 5 Xtreme One WordPress Framework licenses inclusive a Childtheme!

We did the drawing of the winner this weekend at the WordCamp Germany right after our session, where we also introduced the new features of the upcoming version 1.4. Congratulation to all winners and if you didn't win, get a WordCamp Germany special discount of 20% until October 3rd 2011. Just use the coupon code WCK11.

The lucky winners are:

Gabe Casalett
Affan Ruslan
محسن غیاثی (http://www.newbie.ir)

We will contact each winner and they can also choose their favorite Childtheme. Congrats!

Everybody else might grab a copy for 20% discount!

You can check out some pictures of WordCamp Germany 2011 in Cologne here.