Tagtips

About the "Lock in Effect" in WordPress Themes and Plugins

The WordPress themes and plugins market is huge these days. With all that wide range of products available, we sometimes stumble into situations where we’d like to change our mind, i.e. use a different plugin or theme instead of the one we’re currently using. Eventually we figure out that it’s incredibly tough to replace some of the themes and plugins, because as soon as...

How to Get the Current URL in WordPress

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...

Plugins vs. "… Without a Plugin"

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? It’s more difficult to manage and maintain. If something stops working...

Google Analytics Proxy with Nginx

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 ; break; } This rewrites the ga.js filename to...

Protected Meta in WordPress

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...

Quick Tip: Beware of the_content Filter

Here’s a quick tip! Don’t apply the_content filters because some plugins (especially social share plugins) will use that filter to add something extra before or after your content, assuming it’s your main post or page content, which is fair. I’m also pretty sure that attachment posts can add things like images there too. So if you’re using the_content filter...

Ubuntu 11.10 Wireless on Sony Vaio with RT3090

Updated my Sony Vaio VPCM12M1R netbook to Ubuntu 11.10. The update went quite smooth although wireless immediately stopped working. Well it didn’t quite work with Ubuntu 10.10 either but the RT3090 package fixed it last time. Luckily I didn’t remove the package and was lucky to get things working on 11.10 simply by: sudo dpkg -i rt3090-dkms_2.3.1.3-0ubuntu0~ppa1_all.deb And obviously...

VirtualBox and NFS for Web Development

If you’re using VirtualBox for web development and sync data between the host and guest VMs using folder sharing via Guest Additions, you might have noticed that VirtualBox is not too good ad syncing files and some of them tend to get lost too. Here’s a good tutorial on Setting Up NFS in Ubuntu which turned out to be a great alternative, works crazy fast, no permissions issue, syncs...

Custom Post Types Archives in WordPress

Did you know that register_post_type has got a has_archive argument which can be set to a string? In which case it will use that string as a slug for the archives and generate the proper rewrite rules for you. Don’t forget to visit your permalinks settings page though to flush rules when making changes.

Attachments Filename and Directory in WordPress

I was trying to figure out how to get the absolute directory of an attachment post in WordPress. Turns out there’s no easy function that can give you one, but there is one called wp_upload_dir which will give you an array of the upload directories and URLs. So here’s the secret sauce: $url = wp_get_attachment_url( $post_ID ); $uploads = wp_upload_dir(); $file_path = str_replace(...