Recently…

Other than yesterday’s exciting Jet Journal news, here are a few pictures of what we have been up to the past few days.

It has been very hot, and very busy, but our very good friends from California were in Japan, and we got together in Okayama to see them for a few days. Their kids are crazy cute.

One of Kiko’s best friends, Sanae, has some very good news and is up from Tokyo to visit her boyfriends family in Takamatsu. We were really happy to be able to see them (and Kouichi for the first time!)

Finally, a very nice family, the Yamauchis, had Kiko, myself and Greg over for a great BBQ and a magic show. Don’t get me started with the magic show, the kid is amazing. I have some on video and hopefully I will start getting video up on this site.

Anyways, e-mail me and post in the ugly shoutbox already. Don’t say I don’t love you. 

Also, look at the pictures already.

Friends in Japan Picture   Friends in Japan Picture   Friends in Japan Picture   Friends in Japan Picture

Oh yeah… also had a Jamaican cooking class with semi-real Jamaican food and a real Jamaican. It was actually really good. Curry chicken, rice and peas and pepper jelly. nice. I know you’re jealous.

Jamaican cooking picture

 

Jet Journal 2005

Now… if you have been following this site, you may have seen me refer to myself as a Camera Genius, or a Picture Taking Machine (or something like that)…

 Well, it’s true. I submitted some pictures to this year’s Jet Journal (a magazine that goes out to all 6000 JET’s, and three of my pictures have been selected for publication. Take a look at the cover, and click on it to take a look at the pictures themselves. I’m super. emoticon

Jet Journal Cover 

Writing WordPress Plugins and Hooks

Original can be found here

Hooks: why?
————-

When you write a plugin you want to be able to switch it on and off whenever you want. This is not that trivial: say you write a function that does something useful, simply calling the function from your code gives an error when your plugin is deactivated. If you are lucky, it displays nothing, if you are less fortunate it displays all kinds of ugly debug information that people can abuse.

That is why ‘hooks’ were invented. Simply put, a hook is a point somewhere in the generation of your page where you can attach functions. When the hook is reached, all functions attached to it are executed in order of priority. When there are no functions attached to it, it does nothing.

So a plugin should do two tasks:

  • define a useful function
  • attach that function to the right ‘hook’

Many hooks exist already, and most people stick to those hooks. However, hooks are not black magic. Nothing stops you from defining your own hooks, and that is exactly what I’ll do in this page: I’ll create a trivial plugin, put it on my own hook at a place in the page where I like it.

Adding a hook
————–

The first thing I’ll do is the thing many people fear: I’ll create a hook. Using the default theme as an example, the page has a div called "content" which contains the posts in one page. I might want something to happen on the top of the "posts" section, maybe a status message, or a ‘recent comments’ section. That would be the right place to add my own hook.


Now before do that, there is some danger here: many hooks exist already, and before everyone starts defining their own hooks with the same names, let’s set a rule here: if you define your own hook, it should start with your own initials, to let the world know that it works for your plugins and to avoid name collisions. If it is a useful hook, it might become a standard hook for everyone one day.

Ok. Now let’s dive into the "default" theme directory (of course, we work on a backup) and start hacking on "index.php". The spot I had in mind was on line 4, right below the "content" div. I create a hook here called ‘lv_content_head’, because ‘lv’ are my initials, and it is the head of the content. I don’t use any parameters for now.

Below line 3 of "index.php", right below the "content" div, add the following line:

< ?php do_action("lv_content_head"); ?>

That’s all. If you load the page, you’ll see that nothing special happened. That is as it should, because there are no functions attached to it yet.

Now let’s write a "Hello World…" function.

A "Hello World" function
————————-

Now let’s create a real plugin; the file is called "helloworld.php", which will go in the "plugins" directory. The function is plain php; the "Plugin Name" entry in the commented section is is mandatory.

< ?php
/*
Plugin Name: Hello World
*/
function helloworld() {
echo "Hello World…";
}

Now if you would add the closing php-tag, you could see it already in the plugins part of the site administration. Right now, it is not a plugin yet, because it merely defines a function. The next step is to put the function on the hook. Keep the editor open!

Attaching a function to a hook
——————————

Just now we did two things:

  1. we created a hook somewhere in the generation of the page, and
  2. we created a function that is to be called when the hook is reached.

The next step is to attach the function to the hook. This is done by calling the function add_action, where its first parameter is the name of the hook (‘lv_content_head’ in our case), and its second parameter is the name of the function (‘helloworld’ in our case).

Our editor is still waiting for us, so add the function to the hook, and close the php part:

add_action("lv_content_head", "helloworld");
?>

Now the entire plugin looks like this:

< ?php
/*
Plugin Name: Hello World
*/
function helloworld() {
echo "Hello World…";
}

add_action("lv_content_head", "helloworld");

?>

Call it helloworld.php and put it in the wp-content/plugins directory.

From the admin panel it can now be activated, and it should display "Hello World…" on the top of the content area.

A few more pictures from Canada

I finally managed to pry a few more pictures off of my cellphone. This is Kiko, Chris, Franz & I celebrating Chris B’s birthday at a very good restaurant: Banzai sushi. I still owe him a present though… (not that seeing me wasn’t present enough mind you…) ps. Franz was kind of enough to treat Kiko and I to dinner. Thank you!! (my brain was not working, and I apologize, but upon reflection I could have used that as an opportunity to give Chris a birthday present and pay for his dinner. d’oh. chris, forgive me!)

 

chrisfranzdavidcanada2005.jpg   davekikojuly2005.jpg

The Sunflower Parade

I thought this post was going to be more exciting… (as you can see we have the first ever baby name poll happening to your right, SO VOTE!) but things have been pretty hectic. emoticon

We are finally getting over our jetlag, and even though my school visits are over until September I am preparing for the arrival of the new JET‘s to Japan as a member of the Tokyo Orientation Committee and the Kagawa Orientation.

This Friday I also have a Jamaican Cooking day in my town. Apparently I am in charge so I am going to try and make something resembling Jamaican cooking. They also are trying to get me to sing some Bob Marley… umm… no.

Other than that, I am reading Harry Potter 6 (yeah!) and am getting ready for a busy summer:

  1. July 30th to August 3rd: Tokyo Orientation (in Tokyo)
  2. August 5th: Kagawa Orientation
  3. August (dunno): Interning at the Canadian Embassy in Tokyo (yeah!)
  4. August 25th: Kagawa Orientation #2
  5. Rest of my life: Baby.

My town is known for sunflowers (and frogs, and rice, and being a really small town) and their festival was actually a lot crazier than I thought it would be. Take a look! (click on the picture to go to a gallery.)

2005 Sunflower

Here is a picture of me being a Japanese ninja archer from like 2 years ago. I ran into it on my computer a few days ago. I’m cool. 

I am a Japanese Ninja

Summer in Canada 2005

We are  back in Chunan!!! … and have begun the process to get rid of as much jetlag as possible. We both had a fantastic time back in Canada.

I had a scholarship interview that went fantastic emoticon(I’m gonna need something to do when my contract here ends in 2006/08 or 2007/08.) and we got to see a number of really good friends. That being said, we were completely strapped for time, and for everyone that we were able to see, there were 2 more people we would have loved to but couldn’t. Between my scholarship interview in the first week, my Dad’s operation in the second (he’s ok!) and the fact that we only had 10 days in Canada, we did our best.

For those that we did see: Thank you!!! We had an amazing time. emoticonFor those we didn’t: Next year, February. emoticonWe miss you all, and unfortunately because of the baby, this will be our only trip to Canada back this year. Next year we will be back with Baby Awesome (or whatever he/she is named at the time.)

In the meantime, here are a few sample pictures of what we did while back in Canada, and the full gallery can be seen by clicking here.

Canada 2005 Picture   Canada 2005 Picture   Canada 2005 Picture   Canada 2005 Picture   Canada 2005 Picture   Canada 2005 Picture   Canada 2005 Picture   Canada 2005 Picture   Canada 2005 Picture   Canada 2005 Picture   Canada 2005 Picture

On Our Way

yo.

Just a quick note… we are on our way! I am writing this at 5:32am and we have to be at the airport by 6. I have a sore throat, Kiko is large, and our suitcases are super heavy.

We will be posting a lot about our time in Canada, pictures, some amazing times seeing good friends and family, pictures of my good friend Mike and his new baby, and lots of other excitement. In the meantime, we have a 20+hr transport looming ahead of us, so wish us luck.

We will be missing everyone in Canada terribly, but I have to get back and water the watermelons… or something.

Look for pictures soon…

love david & kiko.

The Big News

Why is Kiko so large-ish in the previous entry???emoticon

Drumroll….

   Both Kiko and I would obviously like to be able to give everyone the good news face to face, but since that really isn’t much of an option, we want to take this opportunity to let all of our good friends and family (and the stragglers from the internet who accidently find themselves here… i guess) know the good news…
Introducing David Jr. aka Kunio aka We don’t have a name yet! emoticon

 

Now accepting name submissions. There will be a vote. You can forever improve or mess-up it’s life. Make it so.

 

davidjr.jpg 

 

 

Kiko & David! & Off to Toronto

Just a quick note before we set off for Toronto. It will be a very short and action packed filled trip as we head back to Toronto for 10 days. I have a big scholarship interview but after that is done (30th) I hope to see as many people as I can in the last 4 days. Wish me luck!

See you guys soon and wish us a safe flight! …

Kiko’s New T-Shirt 

No matter what she tells you, this is Kiko’s new favourite shirt. (you can tell by how happy she looks in it!!) 

Another big thanks to Chris and Lianne! Everything you guys have sent has been amazing…. miss and love you guys.  emoticon 

kiko-and-david!1.jpg