I recently ran into a problem making FoxyShop compatible with the WordPress theme Thesis. I have to start out saying that I really don’t like WordPress theme frameworks that unhook all the wonderful things that make WordPress so flexible and easy to use. The header and footer functionality is something that many plugin developers rely on and unhooking it in favor of a proprietary method is something that can be very difficult to work around.

The Problem

FoxyShop uses the template _include filter to utilize its own template files. Thesis doesn’t use header.php and footer.php but instead uses its own proprietary functionality to place template elements on the page. This results in pages that don’t initiate thesis functions and subsequently don’t show any of the website elements (header, footer, sidebars).

The Solution

I’ve tried to use the Thesis custom template hook but it’s never worked right. The solution that I finally found involved wrapping the custom page content in a function and loading in the thesis_hook_before_content action. This seems to work well:

The Problem, Part 2

Because this is just getting inserted before the content, it still shows the page content and Thesis either tries to redisplay content or give an error warning about a missing page, etc. There’s no way to turn that off without hacking the core (which is really not the point).

The Solution, Part 2

I finally hit upon a solution which feels like a real “hack” but works very nicely. At the end of my display function, I tap into the global $wp_query and reset some variables to make WordPress/Thesis think that the page is a 404 page and then I remove the 404 actions so nothing gets displayed, essentially ending the content display box:

It struck me that this is rather an epic story and I thought that Flish should be remembered. So I present to you The Tragic Tale of Floor Fish, an epic narrative that will hopefully pay honor to the memory of poor, heroic Flish.

The Tragic Tale of Floor Fish

‘Tis a dark and dreary tale I have to tell today,
After hearing, you’ll wish you’d stayed away.
It was a bright and sunny day,
Just the fourth or fifth of May,
When seventeen fine fishy friends were all together in a cart,
They were being taken to their new home in bright Wal-mart.

In that intrepid bunch were found
Bill, Fred, Kate, George and Drew,
Gavin, Pete, and Trudy-Lou,
Marlene, Fredericka, Sue,
And lots and lots of others too,
But our tale does not concern these watery friends,
‘Tis toward another that our story bends.

Among these wondrous creatures lived our hero
Bright of eye, quick of fin, his shiny scales did sparkle like the rain,
But sadly, among his friends he was considered as a weirdo,
For you see, our friend the fish, he did not have a name.
His friends would laugh and taunt and jeer,
“Hey FISH,” they’d call; he’d shed a bitter tear.

For forty days our fishy friend lived each day and night,
Hoping, praying, that some kindly friend would save him from his plight.
A name was chiefly what he needed, but still his prayers remained unheeded.
“If only,” he thought to himself, “I could be adopted,
why then I’d have a proper name; my dreary life co-opted!”

‘Tis here our tale turns most morose, in fact you might just think it’s gross,
It was a hot and sunny day quite late in June,
Our fishy friend was swimming ‘round and ‘round, humming a fishy tune,
When out the corner of his eye, he spied a horrid sight,
Indeed, it gave him quite a dreadful fright.
It rose before him till it filled his field of vision,
A human child, making his final fish decision.

Our hero swam and swam and swam away, but the scooper had its way.
Quicker than a shot, our friend was caught, his fate was sealed—or so he thought.
“Oh no,” he thought, “it is no use! This child will doubtless name me Bruce.
I’d rather have no name, than to be saddled with such a shame!”

But fate, it seemed, had other plans, depending chiefly on two clumsy hands.
For as the child turned to go, his new fish safely in tow,
Out slipped the baggie from his grasp, and from his throat slipped a ragged gasp.
The bag fell to the floor—what a blunder—and with a splash it burst asunder!
Our fishy friend lay gasping on the tiled floor, about to be a team member’s chore.
“Ah what an inauspicious end,” he thought, “I had so much to do, my lifetime still to spend.”

The rotten child turned to run, for courage he had none.
All seemed hopeless for our friend, so this was how it was to end.
Then to his rescue sprang a spritely shopper,
She scooped him up, thrust him into the water,
“Poor little fishy,” she sighed, “you almost, almost died.”

Our friend the fish, now had a hero, his life no longer was a zero,
His kindly benefactress had saved him from the utter blackness.
With a smile she bent close and whispered, “you are just what I had pictured.”
Our hero’s fishy heart began to soar, could life be this and so much more?
Perhaps, he thought, the time had come; his heart beat like a drum.

Again he saw the scooper, this time he acted like a trooper,
Into the baggie he was plopped, she held him close; he was not dropped.
To his fishy friends a parting fin he raised,
A brand-new trail his fate had blazed.
She took him home and placed him in a brand new tank,
With a contented sigh, he looked into her eye with thanks.

“Now ‘Fish’ simply will not do, you need a name, this much is true.”
She thought and thought and with a smile she said:
“Floor Fish shall be your name, and for short I’ll call you ‘Flish’.
You are quite the little critter; you’ll be popular on Twitter!”
Our hero’s heart was filled with pride, he very nearly cried,
His haunting shame, it was no more; he thrilled to his very core.

Though he wanted to swim fast, he could only take a short repast,
He had faced a huge ordeal, he could barely see or feel,
You see, our fishy friend was sensitive, and his ordeal had made him tentative.
This had been a banner day and it was time for him to hit the hay.

Despite his happy circumstance, poor Flish was in a trance,
He just knew that things weren’t right, and that haunting thought led to his plight.
For two days he fought and fought. He tried and tried to buck the plot.
But his psyche had been damaged and it simply wasn’t bandaged.

Poor Flish held on, he had a courage that seemed unstinting,
But when he woke, he couldn’t see or feel a thing,
Inside his fishy ear there rang a hollow ring,
He knew his time had come; to life he simply couldn’t cling.

And so our fishy friend passed on to immortality,
Just another victim of life’s cruel brutality.
His kind friend, she shed a bitter tear,
Whispering a sad goodbye inside his unhearing ear.
When she was sure his spirit indeed had flown,
She laid him down to rest, inside the porc’lain throne.

WordPress dev’s, ever wished you could set the target on a custom menu item? I sure wish it was easier than doing some fancy jQuery-trapping and attribute-adding. Well, as it turns out, it is a lot easier.

On /wp-admin/nav-menus.php , click on the link for Screen Options in the top right of your screen. Hidden away in the dropdown there, below the usual Show on screen checkboxes, is another line of Show advanced menu properties checkboxes.

Just check the box for Link Target and then all your Menu Items will have the additional option of Link Target : “Same window or tab” or “New window or tab”

When changing the title of your post, it would be really handy to have a Reset button next to the Edit button on the permalink line. The Reset button would simply remove the current permalink and regenerate it based on the current title.

You can currently do this by clicking edit, erasing the content, and clicking okay. I suggest that it would be clearer and a time-saver to add a Reset button.

I’ve been hard at work over the last several weeks on my second WordPress plugin. I’ve built a shopping cart plugin that utilizes FoxyCart’s (terrific) service to turn the WordPress CMS into a product inventory manager.

Through the process of building this plugin I’ve learned a lot more about WordPress and action hooks (and their priority levels) and the real nitty-gritty of how WordPress template redirection actually works. Fascinating stuff!

If you are looking for a plugin that will run your store or if you are currently using FoxyCart, certainly check this out!

I’ve been feeling vaguely creative over the last few days. I’m sure the sensation will pass if I beat it down with enough football-watching and mind numbing work, but for the moment I couldn’t sleep and was thinking about writing. This was probably brought on by my very brief ownership of this game at a white elephant party.

As I was thinking about writing, I remembered what is possibly my favorite opening to any story. Of course, it is by O. Henry.

It was a day in March.

Never, never begin a story this way when you write one. No opening could possibly be worse. It is unimaginative, flat, dry and likely to consist of mere wind. But in this instance it is allowable. For the following paragraph, which should have inaugurated the narrative, is too wildly extravagant and preposterous to be flaunted in the face of the reader without preparation.

Sarah was crying over her bill of fare.

There’s nothing very world-changing here. Just some simple enjoyment over a clever turn of phrase. Hope you enjoyed it.

Yesterday British actor and comedian Ricky Gervais posted an op-ed in the Wall Street Journal called “Why I am an Athiest”. It is filled with the usual shots at faith and tributes to science and on the whole is pretty unremarkable. His arguments pretty much come down to this:

The universe is logical and there are no scientific proofs for God.

It’s arrogant to say that what works for you is the only truth and beat me up with it.

The burden of proof is on the believer.

It’s wrong to kill people because they don’t believe in your God or follow your rulebook.

There are many gods so it isn’t logical to say that just one of them is the true one.

The only reason that many people believe in God is because it is popular and culturally acceptable.

Written out like that, his arguments look pretty silly and I imagine that a more profound apologist than I would have fun picking them apart. The thing that really struck me, though, was a passage in the middle of his article which talks about his childhood faith. Read this:

I used to believe in God. The Christian one that is.

I loved Jesus. He was my hero. More than pop stars. More than footballers. More than God. God was by definition omnipotent and perfect. Jesus was a man. He had to work at it. He had temptation but defeated sin. He had integrity and courage. But He was my hero because He was kind. And He was kind to everyone. He didn’t bow to peer pressure or tyranny or cruelty. He didn’t care who you were. He loved you. What a guy. I wanted to be just like Him.

One day when I was about 8 years old, I was drawing the crucifixion as part of my Bible studies homework. I loved art too. And nature. I loved how God made all the animals. They were also perfect. Unconditionally beautiful. It was an amazing world.

I lived in a very poor, working-class estate in an urban sprawl called Reading, about 40 miles west of London. My father was a laborer and my mother was a housewife. I was never ashamed of poverty. It was almost noble. Also, everyone I knew was in the same situation, and I had everything I needed. School was free. My clothes were cheap and always clean and ironed. And mum was always cooking. She was cooking the day I was drawing on the cross.

I was sitting at the kitchen table when my brother came home. He was 11 years older than me, so he would have been 19. He was as smart as anyone I knew, but he was too cheeky. He would answer back and get into trouble. I was a good boy. I went to church and believed in God -– what a relief for a working-class mother. You see, growing up where I did, mums didn’t hope as high as their kids growing up to be doctors; they just hoped their kids didn’t go to jail. So bring them up believing in God and they’ll be good and law abiding. It’s a perfect system. Well, nearly. 75 percent of Americans are God-­‐fearing Christians; 75 percent of prisoners are God-­‐fearing Christians. 10 percent of Americans are atheists; 0.2 percent of prisoners are atheists.

But anyway, there I was happily drawing my hero when my big brother Bob asked, “Why do you believe in God?” Just a simple question. But my mum panicked. “Bob,” she said in a tone that I knew meant, “Shut up.” Why was that a bad thing to ask? If there was a God and my faith was strong it didn’t matter what people said.

Oh…hang on. There is no God. He knows it, and she knows it deep down. It was as simple as that. I started thinking about it and asking more questions, and within an hour, I was an atheist.

Wow. No God. If mum had lied to me about God, had she also lied to me about Santa? Yes, of course, but who cares? The gifts kept coming. And so did the gifts of my new found atheism. The gifts of truth, science, nature. The real beauty of this world. I learned of evolution -– a theory so simple that only England’s greatest genius could have come up with it. Evolution of plants, animals and us –- with imagination, free will, love, humor. I no longer needed a reason for my existence, just a reason to live. And imagination, free will, love, humor, fun, music, sports, beer and pizza are all good enough reasons for living.

This passage really impacted me. His simple, honest childhood faith is palpable. And the loss is painful. It’s also a reminder of how important it is that as parents we can answer our children’s questions honestly. It’s tragic that to a young Ricky Gervais, the God of the Bible was on a level with Santa Claus.

I don’t know that there’s much more I can add to what Gervais wrote… it really does say it all: “Why was that a bad thing to ask? If there was a God and my faith was strong it didn’t matter what people said.” The point is that there is a God, and it is always okay to ask. The truth is never threatened by honest inquiry, there’s nothing to hide when you are really, honestly looking for the truth.

When Sarah Palin was selected as John McCain’s running mate in 2008 I was interested. When she gave her acceptance speech I fell in love (politically speaking). Here was a sharp, principled conservative who breathed life into John McCain’s campaign. The more I found out about her, the more I liked her. I read her book and was impressed. I started to think that she might have a chance to run for president. She had a history of winning as an underdog and a political outsider and impeccable conservative credentials. This is what I wanted in a president. Could Sarah Palin be the next Ronald Reagan? Okay, I guess I’m getting a little ahead of myself.

This election cycle is revealing some things about Palin, though, that are giving me concern. First of all, she is supporting John McCain over J.D. Hayworth in the Arizona senate race. Now I understand the importance of loyalty, especially in politics. I don’t expect her to betray her friend, especially the one who was responsible for her big break into national politics. But she should recognize that John McCain is not very conservative. J.D. Hayworth is clearly the better candidate. She should state her support for John McCain and then stay out of the race. But that isn’t what she’s done. Instead, she’s actively supported McCain, campaigning and fund raising for him.

What has really soured me on Sarah, though, is her involvement in Idaho’s first congressional district race between Vaughn Ward and Raul Labrador. She met Vaughn Ward during the presidential campaign where he managed the state of Nevada for John McCain. Later on she endorsed him in the race against Labrador which wasn’t a complete surprise but was a disappointment.

You see, Ward seems to be a carpetbagger who moved to Idaho in order to campaign here. He owns a home in Virginia where he and his family live. More disturbing still, he’s received endorsements from much of the Washington elite and the “good old boy” Republican establishment here in Idaho. He doesn’t have a legislative record and has made one campaign blunder after another. So far, he has shown himself to be a poor politician who won’t stand a chance against Walt Minnick in November. (See Tea Party Boise’s Labrador endorsement for more details.)

His opponent, Raul Labrador, was one of the strongest conservatives in the Idaho house. With four years of legislative experience, Labrador has built a great conservative record and has made enemies of the political establishment because he hasn’t been willing to compromise on conservative issues. According to what she has said about herself, this is the kind of candidate that Sarah Palin should be supporting, right? Apparently not.

Still, I could understand Sarah Palin supporting her friend. This Friday, though, she will be coming to Idaho to campaign for Vaughn Ward and against Raul Labrador. She’s fighting against a “common sense conservative,” the kind of candidate she claims to support. It’s not just Idaho: she’s done the same thing in Arizona and California and this makes me question her reliability. Can I trust her judgment at all?

A political leader (and especially a president) is only as effective as the people with which they surround themselves. It would not appear that Sarah Palin has displayed very good political discernment and it seems to be a continuing trend.

Sarah: be a champion for conservative values and keep an open mind. Choose the best candidate every time. Your intense loyalty to your friends seems to be blinding you to political and ideological flaws that are pretty obvious to the rest of us. I want to like you, but I don’t trust your judgment any more and that is crucial.

It’s easy to get the YouTube thumbnail for a video, but Vimeo is a little bit harder. I’ve run into a few situations where I was using PHP and needed to get the thumbnail pulled. Each time I have to go back and reconstruct code that I’ve found from the web. I’ve also run into fopen errors, so I rebuilt the code to use cURL and wrapped it in a handy function. This code will get you any data you need from Vimeo: