Friday, July 15, 2016

WordPress shortcodes and line breaks.

WordPress automatically adds break tags to new lines. Normally this is useful behaviour but it can prove a major annoyance when combined with shortcodes.

Following user requests I had added a set of column shortcodes to my Utopia theme. The shortcodes are currently just a way of adding a Bootstrap grid to the content, but as we will be replace Bootstrap with an alternative grid system in future this is a way of future proofing the content.

I found a couple of really useful tutorials for adding a columns menu to the TinyMCE visual editor in WordPress:

All well and good, but when I published the content WordPress added break tags between the div
tags and the columns did not display.

My first solution was to change the order of WordPress' shortcode_unautop and wpautop filters, as per these instructions.


//move wpautop filter to AFTER shortcode is processed
remove_filter( 'the_content', 'wpautop' );
add_filter( 'the_content', 'wpautop' , 99);
add_filter( 'the_content', 'shortcode_unautop',100 );

Bad move! Suddenly my other shortcode output was messed up. So I had to remove those lines.

The solution? Write a custom filter using regular expressions to remove line breaks between the shortcode tags and run it before the normal WordPress line break filters kick in. A regex tester proved very useful here!

function utopia_cols_strip_breaks( $content ) {
$content = preg_replace('/(\[utopia_col_row\])([\s]*)(\[utopia_col)/i','$1$3',$content);
$content = preg_replace('/(\[\/utopia_col_)([\_\d]+)(\])([\s]*)(\[utopia_col)/i', '$1$2$3$5', $content);
$content = preg_replace('/(\[\/utopia_col_)([\_\d]+)(\])([\s]*)(\[\/utopia_col_row)/i', '$1$2$3$5', $content);
    return $content;
}
add_filter( 'the_content', 'utopia_cols_strip_breaks', 0 );

I had to use three expressions as there are shortcodes for rows and columns of different widths. Whilst WordPress is supposed to handle breaks between individual shortcodes, the issue here is that we are mixing different shortcodes together and the content between them should have paragraph and line break tags added. The code above only applies to the added shortcodes and seems to work well, so problem solved!

Saturday, June 25, 2016

Brexit

Wind dies down
Bad choices
A mess remains.

Friday, June 24, 2016

TV vs Tablet



I inadvertently performed a little test of consuming a television program via a television as compared with a tablet.

After catching up with the previous episode of the ABC's excellent series Cleverman on their iView app on my tablet I then watched the following episode "live" on a dumb television.

On iView I had constantly paused at the difficult bits, when I wanted more information about something or been interrupted. Now that wasn't possible - it was all in one go.

I quite enjoyed it, plus the 576i picture quality looked better on a 37" full HD screen at a distance than on a 10" 2K screen up close.

Didn't stop me from catching up on some Chaser's Election Desk on iView afterwards. The freedom of being able to watch things at your own convenience is great, but so is doing something free of distraction.


Thursday, June 23, 2016

The horizon


Something I really miss about my previous house was a view of the horizon from my study. I love to stare out towards a distant horizon and imagine the adventures that lie beyond it.

A couple of days ago when I was heading home from my office at North Ryde I stopped to photograph the golden sunlight reflecting off the mirror windows off an office block.

Today I see a crane being erected, which means in the not too distant future that sunlight will be blocked by yet another apartment tower. Already there are fences around the train station hiding the horizon behind red wood and stacked demountables.

With the view gone we turn inward and selfishly forget that there is a needy world outside.

Fortunately I can still watch from my office window the aircraft flying to and away Sydney Airport, the storms sweeping over the city. But even this is temporary as we must vacate within a few years, our land to be turned into more apartments for those from elsewhere.

And we will all be in search of other horizons.

Sunday, June 19, 2016

Hollywood Rhapsody and Vivid 2016



I had quite a surprise when I opened an email from the Sydney Symphony Orchestra a few days ago. They warned me that the area around the Sydney Opera House would be crowded for the last night of Vivid and I should leave early for my concert.

What concert?

Was it Raiders of the Lost Ark or Back to the Future?

I quickly checked my calendar.

Phew, no, it was Hollywood Rhapsody, the bonus concert in the Orchestra Package that I had exchanged for the Raiders concert I already had tickets for. I had prevaricated whether to see this one or a classical concert.

I'm not a huge fan of "The Golden Age of Hollywood."

It was rather a bit before my time.

There was no way that B or Alex would want to join me for this one. So I headed off alone into the city, rather exhausted after a tough week, a morning of karate and a stint running the library at Alex's Chinese school.

Another thing I hadn't planned on doing was seeing Vivid, Sydney's festival of light and other stuff this year. We were told that Circular Quay station was closed, so after jumping off at Town Hall to buy B a bottle of Japanese tonkatsu sauce, I alighted at Wynyard and walked the closed off streets to Circular Quay along with the rest of the crowd.

The crowding itself wasn't too bad and the lights were fantastic. The sides of buildings and the Harbour Bridge were colourfully lit, coloured searchlights illuminated the clouds and there were stunning projections against Customs House, the MCA and the Opera House.








At the Opera House box office they suggested that I might like to sell my two unused tickets to the young tourist attempting to get cheap seats to a performance. I gave them away to him. Hopefully he'll be nice to someone else one day.

Then I squeezed into my seat. A few rows closer than the nosebleed section of the last concert and quite a good view of the orchestra.





Having checked the program I knew the night wouldn't be a complete disaster as John Williams' Star Wars Main Title was the first piece after the 20th Century Fox Fanfare.

The pace was a bit fast and the brass began a little ragged, but it was a decent performance of the piece that I've heard live more than any other.

The rest of the music I was largely unfamiliar with except in passing. David Raksin's theme from Laura was quite pleasant, the string section was faultless tonight. They had a real workout with a suite from Bernard Herrmann's Psycho score, the famous shower sequence eliciting a few laughs from the audience.

Herrmann's music continued with Salammbo's Aria from Citizen Kane, performed by the soprano Lorina Gore. Having developed an ability to ignore the sound of opera thanks to my parents' musical tastes the best that I can say is that she could certainly hit all the notes.

I recall hearing some of Erich Korngold's The Adventures of Robin Hood played my the Melbourne Symphony and enjoying it. But not so much this time. As conductor John Wilson said, Korngold became the sound of Hollywood and in my opinion the music sounded cheesy. Except for the first part of the final fight, which could have come from a contemporary battle sequence.

After the interval we heard the Americana of Jerome Moss' score to The Big Country, which enjoyed, though the style has been reused many times.

Fifteen minutes of Max Steiner's 3 hour 10 minute score to Gone With The Wind was as much as I could stand. It had some familiar highlights before sinking into bland romantacism.

In contrast, Franz Waxman's suite from A Place in the Sun contained a number of interesting themes, including some passionately played saxophone solos, enough to keep me listening.

The most fun of the night was John Wilson's arrangement of Scott Bradley's music from the Tom & Jerry cartoons. Unlike most film scores, this kind of cartoon music is not the kind of thing you'd listen to in isolation from the screen. Except in this case, it was almost a live action cartoon performed by the percussionists as they used slide whistles, bowls of water and even smashing plates to achieve the zany musical effects.

The final piece in the program was the Parade of the Charioteers from Miklos Rozsa's score to Ben Hur. Loud, brassy, but I didn't really like it.

It would have been a pity to end on that note, but of course there was an encore. And what an encore it was! Franz Waxman again, this time the Ride of the Cossacks from Taras Bulba.  A frenetic piece that gave the orchestra a true workout.

The concert didn't convince to start listening to film music from the fifties and before, but I could sense some of the musical heritage that has contributed to more modern scores. I actually feel that John Williams' latest Star Wars outing has an even greater nod to the older romantic scores than his original work.

But you shouldn't need to know all the antecedents of a piece of music to enjoy it. Once again the program, and what I caught of the pre-concert talk, portrayed each composer as being genuine only because they had a classical background or composed concert pieces in addition to films. The elitist snobbery of the SSO grates. At least the conductor didn't let them get away with lazy performances this time.

After the concert I ran into an ex-work colleague and joined the crowds walking back past the ranbow lights. Fortunately, Circular Quay station was open again. It felt a bit strange to see a number of people clutching concert programs like me get off at Padstow. I didn't get home until almost midnight, but in the end I'm glad I decided to go.



Friday, May 20, 2016

Silicon Vallergy


"Nobody talks about teleports to Japan."

Not true!

Few things give me a headache like tech marketers. Unfortunately my organisation has been invaded by Silicon Valley alumni. You can tell. Long term scientific programs have been cut in favour of short term trendy "research" and "innovation". Apparently, a huge amount of data simply comes into existence in a magic cloud without anyone needing to do the unexciting task of collecting it in the first place.

So there I was stuck in a meeting with an ex-Yahoo marketing "guru" and entrepreneur.

He was "taking us on a journey" in our quest for "followers". Or some such crap. I was busy wondering how anybody could speak so many words yet say so little.

At the same time he spruiked Zeetings, some Web presentation/conversation web application he had some connection with. What I found telling is that as soon as he stopped using it, so did we. Not a compelling piece of technology then.

Marketing dude asked us for some words to describe the venture.
"How come nobody is talking about disruption?"
In the best moment of the day, somebody piped up that it was because the organisation has been in a permanent state of disruption for the past 5 years and everyone (barring the consultants) is sick of it. Disruption is a dirty word, we said.

And so the tide turned in the meeting, with the more forceful techies and researchers taking control and the only one paying attention to Mr Marketing was his offsider. We actually got some real work done figuring out practical requirements rather than meaningless aspirational buzzwords.

I still got a headache.

Sunday, May 15, 2016

Holey bags Batman!

You know the superstition that bad luck comes in threes? Happened to me today. I was carrying a bag of cypress woodchips out of the garage when the bag disintegrated.

I thought the leaf blower/vacuum was doing a pretty good job of cleaning the mess up. Then I looked behind me and the garage was covered with cypress dust while the vacuum bag was virtually empty. The vacuum bag's zip had failed.

Later I was making dinner and had just finished putting half a packet of dried spaghetti into the pot. I tipped the packet containing the remaining spaghetti upright when the contents suddenly emptied on to my feet. The spaghetti packet had developed a hole in the bottom.

Lucky the groceries survived the trip home!

Popular Posts