A good summary of Google’s recent announcement to support PHP (and thus WordPress) in their Google App Engine product.
Category: WordPress
If you’re writing a WordPress plugin, you may have a scenario where you have an attachment (file) URL, and you’d like to obtain the associated post (attachment) ID.
Luckily, this is very easy to do in WordPress 3.6 because of the new attachment_url_to_postid()
function.
The function’s syntax is simple – you pass it a string (the file URL), and it returns an integer (the associated post id), or zero on failure.
Here’s a simple example:
As mentioned above, this function is available in WordPress 3.6 – it will cause a fatal error if you try to use it in any earlier versions such as WordPress 3.5.x.
Thanks to Zack Tollman for the heads up about this handy new function.
Although WordPress themes typically use Responsive Web Design to tailor website for mobile devices, there is sometimes a need to use PHP (backend code) to detect whether the visitor’s web browser is running on a mobile device.
For example, there may be scenarios where you may want to output certain HTML markup (such as a mobile navigation menu) on mobile devices.
Alternatively, you may only want to output a slider containing large images on desktop and not mobile devices. Doing this via PHP (instead of CSS) means that the visitor’s mobile browser won’t have to download all of the slider images even though the slider is never displayed.
WordPress’ wp_is_mobile() function to the rescue!
wp_is_mobile()
is a litte-known function built into WordPress that detects whether the visitor is using a mobile devices such as iPhone, iPad, Android, Silk, Kindle, BlackBerry, Opera Mini, and Opera Mobi.
The function was introduced in WordPress 3.4, and it can be used in a WordPress plugin or theme.
It’s a simple function that accepts no parameters, and returns a simple boolean (true/false) value.
Here’s a simple example:
Interestingly, WordPress core currently uses this function in a few different places:
- To completely disable the Visual Editor for Opera Mini.
- To enable jQuery UI Touch Punch in the WordPress dashboard for mobile devices.
- To detect whether the current device can upload files.
- To disable the “shake” effect on the WordPress login page when an incorrect username or password is entered using a mobile device.
Are you currently using the wp_is_mobile()
function in your plugin or theme? If so, I’d love to hear what your use-case is.
WordCamp Melbourne 2013
It’s been two years since I helped organise WordCamp Melbourne 2011. Time flies!
The good news is that WordCamp Melbourne 2013 has been scheduled for April 27-28 2013.
WordCamp is a conference for WordPress enthusiasts, designers, developers, or anyone who is using WordPress for business or pleasure.
This year’s conference is being organised by a fantastic group of people, and they’re going to be putting on a fantastic WordCamp.
The speaker list and schedule is jam-packed, and the venue is in the CBD so it’s easy to get to.
So if you’re in (or near) Melbourne, I’d definitely recommend coming along.
Best of all, tickets are only $50 for two full days of WordPress goodness!
Below are some statistics that demonstrate how popular the WordPress user groups are in Australia:
Location | Population | Number of Group Members |
% of Population in Meetup Group |
---|---|---|---|
Hobart | 216,276 | 93 | 0.0430% |
Bendigo | 89,666 | 23 | 0.0257% |
Brisbane | 2,146,577 | 342 | 0.0159% |
Sydney | 4,605,992 | 661 | 0.0144% |
Melbourne | 4,169,103 | 516 | 0.0124% |
Canberra | 367,752 | 42 | 0.0114% |
Adelaide | 1,262,940 | 81 | 0.0064% |
Perth | 1,832,114 | 66 | 0.0036% |
Wollongong | 288,101 | 9 | 0.0031% |
As you can see, Hobart has the highest percentage of their population being a member of their user group. Well done Japh!
Here in Melbourne, it looks like we have some work to do.
Population Figures are sourced from Wikipedia as of 10 October 2012.
Number of Group Members Figures were sourced from each meetup.com group page as of 10 October 2012.
WordCamp Sydney 2012 Wrap-up
Last weekend I attended WordCamp Sydney 2012 at the beautiful University of Sydney Camperdown campus:

The Statistics
There were approximately 230 people who attended the 2 day event. (Which makes WordCamp Sydney 2012 the biggest Australian WordCamp ever!)
According to Eventifier, there were:
- 110 Photos
- 1 Video
- 1916 Tweets
- 245 Contributors
The Audience
In previous WordCamps that I’ve attended, the number of WordPress end-users have easily outnumbered the number of WordPress developers. However at WordCamp Sydney, the developer stream was packed, and there were (from memory) more developers than end-users.
Highlights
I particularly enjoyed Brent Shepherd’s Word to the Future presentation, and also Jeff Waugh’s TurboPress: The High Performance Guide to WordPress.
The major highlight for me was the conversations at the pub on the Saturday night. It was great to see so many passionate WordPress business owners discussing their problems, solutions, and even talking about future WordPress-related events in Australia.
I also enjoyed catching up with some familiar WordPress faces, and also meeting some really interesting people.
Thank You!
Being one of the organisers of WordCamp Melbourne 2011, it was fantastic to see WordCamp popularity in Australia continue to rise.
Thank you to all the organisers and volunteers – from my point of view the the event ran without a hitch!
Bring on the next Australian WordCamp 🙂
Looking for a simple way to embed a Github Gist in your WordPress website?
I spent some time reviewing the available plugins in the WordPress plugin repository, so I thought I’d share my findings.
When writing a WordPress plugin recently, I wasn’t sure whether a translatable text/string is considered safe, or if it needs to escaped before being output.
Here’s a simple example:
The Problem
At first glance, that code looks like it should be safe, however what would happen if the string was translated to contained an angled bracket (<
or >
)?
That would result in invalid HTML code. Or even worse, what if the translation file contained a malicious <script>
tag?
The Solution
Yesterday was Automattic’s Worldwide WP 5k day, so Jen and I got on our bikes and went for a ride.
We must have got distracted, because we ended up riding for 2.5 hours in the Melbourne sunshine! In typical Melbourne style, the sunshine was interspersed with plenty of cloudy (cold) periods.
All in all, it was a lovely morning, although next time I think I’ll be taking a jumper with me!
Are you a WordPress user? Make sure you do your body a favour and participate in Automattic’s Worldwide WP 5k day 2012.
Page templates in subdirectories, new in WordPress 3.4 by Andrew Nacin.