Run PHP code in a WordPress widget

I had an advertiser who wanted his link to appear in the right sidebar of the site, but only on the home page of site. Sidebar widgets usually appear throughout the site, so I had to figure out how to make it work.

I knew WordPress supported an is_home() conditional statement, but PHP code can only be executed in themes and plugins, not in free text/HTML. I tried inserting the code into the functions.php code, but never got it to work exactly right.

It turns out there’s a WordPress plugin called PHP Code Widget that lets you execute PHP code inside a widget. Just type it in along with your text and HTML and it works. Here’s the code:

<?php if( is_home() ) : ?>
Text and HTML go here and will appear only on the home page.
<?php endif;?>

Posted in Ecommerce, Social Media, Tech | Tagged | Comments Off

11 Year Blogiversary

My first blog post was 11 years ago tomorrow.

In the past 11 years sometimes I’ve blogged more and sometimes less. It’s been almost two months since my last post, which is a personal record.

There are lots of reasons for the lack of blogging, all of them good. I started a new job in July and I still have consulting work coming in from the time I was unemployed last year and turned to consulting. Having three kids keeps me busy and I’m trying some new hobbies, like learning the ukulele with the kids.

So I’m still around and thanks to everyone who emailed to make sure everything was OK. I’ll still blog from time to time, so keep me in your RSS reader.

Posted in Home Life, Social Media | Comments Off

Words of the Day – Gray/Black/Brown Thursday and Green Monday

Things change, including where people buy stuff that people want. From downtown shops to the strip mall. Strip mall to indoor mall. Indoor mall to big box store. Big box store to online store.

People not only change where they shop, but when. Besides Black Friday and Cyber Monday there are new super dooper holiday sales days. I knew about Gray Thursday from my wife. She took our oldest daughter out to shop at 8 PM Thanksgiving night and didn’t come back until 3:00 AM.

In recent years, retailers have been trending towards opening on Black Thursday, occurring Thanksgiving evening. In 2011, Walmart began its holiday sale at 10 p.m. on Thanksgiving Day for the first time. In 2012, Walmart began its Black Friday sales at 8 p.m. the day before on Thanksgiving; stores that are normally open 24 hours a day on a regular basis started their sales at this time, while stores that do not have round-the-clock shopping hours opened at 8 p.m. Competitors Sears and Kmart will also be opening at 8 p.m. on Thursday night, while Target and Toys “R” Us will be opening at 9 p.m.

A number of media sources began referring to this instead by either the name Gray Thursday[55][56] or Brown Thursday.[57]

Green Monday on the other hand was a new one on me until the news started covering it this morning.

Green Monday is an online retail industry term similar to Cyber Monday. The term was coined[1] by eBay to describe its best sales day in December,[2] usually the second Monday of December. Green Monday is defined more specifically by business research organization comScore as the Monday with at least 10 days prior to Christmas. In 2009, $854 million was spent online in the US on Green Monday,[3] with sales in 2011 reaching $1.133 billion.[4] In 2012, Green Monday topped out at $1.27 billion, up 13% from 2011 and the third heaviest online sales day for the season behind Cyber Monday and, randomly, Dec. 4, 2012, according to comScore.[5]

Here’s a fine infographic on Cyber Monday. Thanks, Roger.

Continue reading

Posted in Ecommerce, Word of the Day | Comments Off

Star Wars, Nothing But Star Wars*

Stuff I’ve been posting on my Facebook. I remember the days when posting this stuff to a website you owned made you a blogger. Good times.

1374970_10201350015690788_1212157352_n(1)

1470313_10202331242019971_915183112_n 579625_10152002295039752_1134561094_n 1472842_10152091770762952_95147958_n

*

Posted in Star Wars | Comments Off

Spoiler Alert Fails

Google for “sons or anarchy recap.” I wonder if anyone died in this week’s episode?

1422474_10201804950383871_1873579699_n

OK, sure. Now I know who died. But who killed him is still a mystery, right?

1422605_10201803484107215_1663666951_n

That’s some mighty fine spoiler alertin’ there, Cletus.

Posted in A&E, Funny Ha-Ha | Tagged , | Comments Off

Natalie with Wet Hair and Mommy’s Glasses

Natalie with Wet Hair Wearing Mommy's Glasses

No time to blog about the news, so here’s a nice pic of Natalie. For a long time I’ve been been doing the conventional thing of chasing sharpness. Now I’m playing around with soft focus.

Posted in Home Life, Photography | 1 Comment

Former Federal Reserve Official Apologizes for Quantative Easing

CNBC:

“My argument is not that QE was not at all useful,” he said on CNBC’s “Fast Money.”

“I believe that at the time, it was just one more tool that the Fed introduced to try to help the economy,” he said. “My point, ultimately, is the idea that very quickly into QE, it started becoming obvious that it wasn’t working in the way that it was supposed to.”

The article quotes someone from Rutgers Business School, who wonders what the end game for QE is going to be. The stock market – particularly the banks buying stock – is addicted to the easy money of QE. When can the Fed withdraw the money without crashing the markets?

One other point from the article – the rise in the stock market mostly benefited the already wealthy, including the banks. That was the indirect transfer of wealth.

Other transfers were more direct. The Fed bought up hundreds of billions in the banks’ bad mortgages (as opposed to underwater mortgages from the little guy). The Fed loaned money to banks at a low rate and banks used the money to buy Treasuries that paid a higher rate of interest. Some of that may have been by design, to repair the damage done by years of bad lending, but the net result was moral hazard and a massive transfer of wealth to the wealthiest.

Posted in Economics | Tagged , | Comments Off

Conversation about Opposite Day

7 YEAR OLD NATALIE: Can I?
ME: Nope. Sorry.
7 YEAR OLD NATALIE: Can I pleeease?
ME: Nope.
7 YEAR OLD NATALIE: Today is Opposite Day. If you say I can’t, that means I can.
ME: It’s Opposite Day?
7 YEAR OLD NATALIE: Uh huh.
ME: If it’s Opposite Day then if you say it’s Opposite Day that means it isn’t Opposite Day.
7 YEAR OLD NATALIE: That’s not fair.

Posted in Home Life | Tagged | Comments Off

QoTD – James Baldwin

“Nobody is more dangerous than he who imagines himself pure in heart, for his purity, by definition, is unassailable.”
  — James Baldwin

Posted in Quotes | 1 Comment

Meet the Beatles

Nine year old Katie has discovered the Beatles. Now she can listen to my Beatles albums and we can talk about those together. Beatlemania sure beats the heck out of Bieber Fever.

Posted in Home Life | Comments Off

Cloudflare Update Week 2

Last week saw a 17% increase in page speed compared to the control period before using Cloudflare. I had a feeling I wasn’t seeing the full speed boost. Because lesjones.com has so many pages and images, it seemed likely that Cloudflare hadn’t seen them yet, so it hadn’t cached them.

To solve that problem I ran a linkchecker that accessed every linked page and embedded image on the site. That seems to have helped. Compared to the control period, performance has improved 34%. For my site that’s an average load time that’s about 2.3 seconds faster. Not bad at all considering it took almost no effort.

 

Cloudflare Results in Google Analytics

One thing that concerns me is that the page load sample for last week was extremely small – just seven pages compared to 24 for the control period. For various reasons Google Analytics can’t* and doesn’t** collect page timings for all pages.

GA-Oct-24-page-load-sample

Both of those page load samples are very small as a percentage of traffic – just 0.45 for last week. At work the number is about 16%. I’m really not sure why the sample here is so small, but I’m going to continue the test for another week to be sure the results aren’t a fluke.

* From Google Analytics Help: “Site speed tracking occurs only for visits from those browsers that support the HTML5 Navigation Timing interface or have the Google Toolbar installed. Typically this includes: Chrome, Firefox 7 and above, Internet Explorer 9 and above, Android 4.0 browser and above, as well as earlier versions of Internet Explorer with the Google Toolbar installed.”

** That same help section says that “By default, a fixed 1% sampling of your site visitors make up the data pool from which the page timing metrics are derived.” However, that doesn’t match the numbers on this site or the one I manage at work.

Posted in Ecommerce, Tech | Tagged , | Comments Off

Word of the Day – Brigantine (Sailing)

From Wikipedia:


In sailing, a brigantine or hermaphrodite brig is a vessel with two masts, only the forward of which is square rigged.

Origins of the term

Originally the brigantine was a small ship carrying both oars and sails. It was a favorite of Mediterranean pirates and its name comes from the Italian word brigantino, meaning brigand, and applied by extension to his ship. By the 17th century the term meant a two-masted ship.[1] In the late 17th century, the Royal Navy used the term brigantine to refer to small two-masted vessels designed to be rowed as well as sailed, rigged with square rigs on the foremast and fore-and-aft rigging on the mainmast.

By the first half of the 18th century the word had evolved to refer not to a ship type name, but rather to a particular type of rigging: square rigged on the foremast and fore-and-aft rigged on the mainmast.[Note 1] The word “brig” is an 18th-century shortening of the word brigantine, which came to mean a vessel square-rigged on both masts.[1] The early Oxford English Dictionary (with citations from 1720 to 1854) still defined brig as being either identical to a brigantine, or alternatively, a vessel of similar sail plan to a modern brig. By the middle of the 19th century modern meanings had more or less stabilised, although purists continue to debate the exact differences, or lack of them, between brig, brigantine, and hermaphrodite brig in both English and American usage.


I ran across this one  in the lyrics of The Stone Roses’ “Waterfall.”

Previous WOTDImage Macro

Posted in Word of the Day | 1 Comment

Cloudflare One Week Update

Last week I routed the lesjones.com domain through Cloudflare. Their service serves as a content delivery network (CDN). They have locations around the world and can deliver files faster than my one location.

When a browser requests a file, Cloudflare fetch the file from my site and caches it. The next time the file is requested it comes from Cloudflare instead of my site. Their servers and Internet connectivity are faster than mine, so visitors get the file faster. The caching also reduces the number of requests my website has to handle, which should increase the speed of the website for other tasks.

www_google_com_analytics_web__hl=en#report_content-site-speed-overview_a124590w148298p100625___u_date00=20131009&_u_dat

One week later, total page transfer time (the page plus the images) across the entire site is a little faster, about 17%. Roughly the entire 1 second load time speed up looks to be the average server response time.

Question is, is the change in page load time a fluke not related to the CDN/Cloudflare change? Or did relieving my website from serving all of those files free it up to serve out pages faster? It’s hard to say. I’m going to keep running Cloudflare for a few weeks to get a better idea.

Cache misses

I’m going to try something to see if I can improve the performance. I’ve got a big site with a lot of posts and images. Many of them may not have been requested yet. Cloudflare probably has just a fraction of the images cached. When those files are requested, Cloudflare doesn’t have them (what’s called a cache miss) meaning they’re still having to download them from the website for the first time.

To get all of the files  in the cache I’m running a link check this morning. The linkchecker will access all of the links and embedded images on the site, which will prime the cache.

Posted in Tech | 1 Comment

This Is Your Train on Drugs – Sydney and Minnesota Zoos Mothball Monorails

WiredAnother ‘Outdated’ Monorail Bites the Dust:

First, the pylons of Sydney’s monorail came tumbling down. Now, the Minnesota Zoo in Apple Valley, MN has shuttered its aging monorail for good.

The troubled traincars took their last loop around the zoo campus on September 2, and now the zoo has announced the line won’t run ever again.

“It was an outdated system that had reached the end of its useful life,” spokeswoman Kelly Lessard told the Minneapolis Star-Tribune. Back in 2011, the train stalled, leaving passengers stranded 18 feet above ground. Firefighters rescued them with ladders when they couldn’t get the monorail running again.

Maintenance on a 34-year-old system was certainly an issue. But the biggest problem with the zoo monorail was that it didn’t have any stops along its route. Instead, it looped around the zoo, and those on board could only catch glimpses of animals as it drove past.

That’s the problem with trains. They stop at a fixed number of places which are set in stone when the train is built.

Meanwhile, buses can stop at any number of places and their routes and stops can be changed as demands change. Buses good. Trains bad.

Posted in Economics | Tagged | Comments Off

45 year old spoiler alert!

45 year old spoiler alert! Charlton Heston didn’t land on an alien planet. It’s really Earth after apes have taken over.

Posted in Funny Ha-Ha | Tagged | Comments Off