Integrating with WordPress

I probably should be working on the 2.7 upgrade, but instead I started looking at photo gallery options other than Gallery2. It is just too slow. There is too much of it I don’t use as well. I think I have settled on zenphoto. It seems to work pretty well, with out the feature creep that Gallery2 has. I figured I would convert the site to that.

It got me thinking though about how I might integrate it with WordPress. After seeing the tantan Flickr plugin, and how well it works, I figured that there must be a plugin for zenphoto. Well, no. Not really. There are a couple that will let you show pictures in the sidebar. And Trung’s presszen looked promising, but it didn’t seem to work. I started taking a look at the code for the tantan Flicker plugin, and saw how he was able to take control of a URI to insert his own code in with the current wordpress theme. I stripped out the relevant stuff, and got it to work. This is the code.

function parse_query(&$query) {
	$query->is_404 = false;
	$query->did_permalink = false;
function request($query_vars) {
    $query_vars['error'] = false;
    return $query_vars;

function cww_template() {
	echo '

Zen Integration

'; get_footer(); exit; } define("CWW_ZEN_BASEURL", "/blog/test"); if (strpos($_SERVER['REQUEST_URI'], CWW_ZEN_BASEURL) === 0) { status_header(200); remove_action('template_redirect', 'redirect_canonical'); add_filter('request', 'request'); add_action('parse_query', 'parse_query'); add_action('parse_request', 'parse_query'); add_action('template_redirect', 'cww_template'); } elseif (strpos($_SERVER['REQUEST_URI'].'/', CWW_ZEN_BASEURL) === 0) { header('location: http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'/'); exit; } ?>

I think that I may take a go at pulling in the zenphoto albums in a plugin, and see how it goes. I like how you create plugins in WordPress, and it is kind of fun poking around. It was frustrating for the longest time when I was trying to get it going, and I was getting the body of the blog showing up at the bottom. I finally realized that I needed to ‘exit’ the script to prevent the loop from happening. You would think you could override a WordPress function to prevent that instead.

WordPress Code Plugin

If you look at the tutorial I put up, you can see that the code snippets are syntax highlighted. Most of the java classes are initially hidden, but when you press the arrow to the right, the code slides down. Very cool. I found this WordPress plugin called WP-CodeBox. It works pretty slick.

One thing that I wasn’t completely happy with, was that there was no “name” to the code. The header for the top just looked like this:

code here

What I wanted was something like this:

code here

It took a bit of sorting through the code, but I found the section that parsed the parameters, and added a “name” parameter. Now I could add whatever text to the header I wanted, and have the name of the code stand out.

Wicket is Wicked

In the course of investigating some alternative web frameworks (other than Struts2, which I do like) I decided to take a look at Wicket. This is a vastly different way of creating web projects, and I am really starting to like it. The big difference is that you don’t need a lot of configuration, and you do a lot of coding that looks like real Java classes. You get to add components and listeners to a class that acts as your page. There is a html file that goes with each page, but it is just html. Only the wicket:id element to the span (or other html) tags indicates that there is anything different. You link to other html pages, and wicket does the rest.

Continue reading