I turned commenting off on articles older than 14 days a copule of months ago and here’s the impact shown by Akismet’s stats page. No wonder why I stopped receiving a bunch of “please moderate” e-mails every day.
Here’s a quick tip! I was wandering around the web for the perfect solution to retrieve the current URL in a WordPress theme or plugin. I found a bunch of solutions for PHP, but not directly related to WordPress so I thought there has to be an easier way, and after a few hours of examining with global variables seems like I found it.
global $wp; $current_url = add_query_arg( $wp->query_string, '', home_url( $wp->request ) );
Beats all the $_SERVER approaches and no need to identify whether the host is using SSL, etc. You can add a trailing slash to that with trailingslashit if you need to, and it looks much cleaner too. Hope you enjoy that, and thanks for tweeting ;)
You know what the worst thing is during the process of learning the Dvorak keyboard layout? You quit applications when trying to cut (Cmd+X)
— Konstantin Kovshenin (@kovshenin) January 7, 2012
I wrote earlier that I’ve been training myself on the Dvorak keyboard layout lately, so the fun part is that the Dvorak Q is right where the Qwerty X is and I’m a crazy user of shortcut keys, so there you have it! Can’t wait to make the full switch. By the way, I’m using this plugin to embed tweets.
Actual IRC discussion. “the core of wordpress use smarty?” “no” “is possible than in the future wordpress change the core to django?”
— Andrew Nacin (@nacin) January 5, 2012
I couldn’t not post this tweet by Andrew Nacin. Seriously, why not change the WordPress core to Django? ;) Perhaps the author of the quote meant a Django-style templating engine, which is indeed cool and quite popular too. Oh well, that was a good laugh, thank you!
Custom Post Types are not new to WordPress, they’ve been around since version 3.0 and have really changed the “WordPress as a CMS” game ever since. Custom taxonomies though, have been around even earlier and are used to group your posts and custom post types.
This post will give you a short insight on taxonomies in WordPress and show you how to add different taxonomies to different post types without having to alter any of the core or third party plugins and themes code.
Tip: Stop this “without a plugin” crap. Your functions.php snippets are as much overhead as plugins, but harder to maintain. #wordpress
— Konstantin Kovshenin (@kovshenin) January 4, 2012
Posted this yesterday on Twitter, thanks for all the retweet and fave love! I started seeing quite a lot of tweets and posts on how to do things “without a plugin” in WordPress and 99% of them involve writing snippets in your theme’s functions.php file. Now, how does that differ from writing a plugin?
I’m pretty sure there are a lot more reasons. So dear all, write plugins, even if they’re dead simple and do one thing only. The “all in one” plugins carry the real overhead which is never used. Then, when you’re ready, submit your plugins to the WordPress.org Plugins Directory to give back to the community. That’s why the open source WordPress is so strong.
Here’s a quick tip! If you need to serve a specific script, stylesheet or any other file from your own domain, you can easily proxy it with nginx. A good example is the ga.js file for Google Analytics. Here’s how I proxy it with nginx, in the server context:
# Google Analytics Proxy
rewrite ^/ga\.js$ /ga/ last;
location /ga/ {
proxy_pass http://www.google-analytics.com/ga.js;
break;
}
This rewrites the ga.js filename to the /ga/ pseudo-directory, in the context of which I can use the proxy_pass directive to fetch the file from Google. This way I have total control over the file that’s being served and especially the HTTP headers, which I was after in the first place.
You can repeat the trick with basically any file, but keep in mind that each one is a little extra load on your server, so add a caching layer where possible.
As some of you might have noticed on Twitter and Facebook, I recently started learning a new keyboard layout called Dvorak Simplified Keyboard Layout, so I decided to share a couple of links that inspired me. The Dvorak Zine uses comics to explain the history and promote the layout. They also have a Dvorak typing course.
Matt Mullenweg’s On the Dvorak Keyboard Layout (written back in 2003) explains the advantages, why and how he switched to the Dvorak layout. Matt also quoted:
I knew that however long it took me to learn it would be incrementally paid for by the increased productivity and comfort in the future.
Quite inspired by all this, I made a 2012 resolution to learn touch typing on Dvorak at least as fast as I can touch type on Qwerty (around 100 words per minute.) I can also touch type the Cyrillic keyboard layout at around 80 words per minute but that won’t change with Dvorak ;)
I was doing a few tweaks to the Twitter Embed plugin earlier today and found out that authors that access to the custom fields interface could exploit them to print unfiltered HTML. This happened because I cached the HTML retrieved from the Twitter API in an unprotected meta field to the post.
The easiest workaround was to add an underscore prefix to the meta key, so my_meta_key for example, would become _my_meta_key. For a second though, I thought that somebody might type in the underscore in the custom fields interface too, so I spent a few minutes reading the admin ajax source code.
It turns out that there is a call to a function called is_protected_meta defined in meta.php, which does the check for the preceding underscore, so the custom fields interface will not allow working with protected meta fields no matter on what user level, which is good! It still allows themes and plugins to use get_post_meta and update_post_meta.
So the lesson learned today — if you’re storing sensitive data in your post meta fields, don’t forget to protect them from eyes by prefixing your meta keys with underscores.
My company, CryoSitters, is developing a way to cryogenically freeze children for short periods of time to help parents that cannot find babysitters, with plans to eventually package our technology in affordable home kits.
via TechCrunch