Ultimate Web Tips

your Wordpress, jQuery, PHP, MySQL, Linux and CSS

Custom post typesCustom post type is a great way to customize your WordPress and adding new taxonomies makes it even more powerful. All functionality comes with WordPress core but it can be difficult to specific posts on a custom taxonomy. The key in this is the new tax_query argument.
More

Create a WordPress custom AJAX functionI came across a bit of complication when I for the first time needed to pass parameter to a function with setTimeout. The setTimeout() method calls a function or evaluates an expression after a specified number of milliseconds. It’s also supported in most browsers, brilliant tool if you want to create a javascript ticker.
More

ReflectionClassTo find out where a class is defined could be quite difficult is you are using frameworks you are not so familiar with. The ReflectionClass is a great tool to find out everything about your class and turn into objects.
More

Disk quota exceeded error in Linux

March 2nd, 2012 1 Comment, Linux, by Joakim Ling.

Index-node (inode) is a data structureAll of your services have disk storage space allocated to you. When you fill your disk storage space, you will receive a notification message “Disk quota exceeded” when you try to perform operations, such as storing cache files or sending email. Even if you have free space left on your disk, doesn’t say that you have space to add new files.
More

use WordPress Thickbox native supportThickbox is as jQuery plugin that WordPress use as it’s main popup window or modal view. It’s already built-in in WordPress so why not use that in front end. No need to download or import any extra files.
More

Make custom columns sortableWordPress has had the ability since a long time ago to add custom fields to posts. Also called as meta-data. It’s also possible to add these values to your table list and make them sortable.
More

Connect with a public key to SSH with PHP

February 14th, 2012 No Comments, PHP, by Joakim Ling.

Connect with a public SSH keyNot a lot of people knows that PHP supports SSH. I use it to execute remote commands, auto configure of web server configurations etc.

If you need to SSH to a server that only accepts a public key, the connection procedures get a bit more complicated.
More

Style HTML5 placeholder color with CSS

February 13th, 2012 No Comments, CSS, by Joakim Ling.

Placeholder CSS stylingFor now this is only possible in Webkit and Mozilla browsers, the discussion about best implementation is still an ongoing project.

You’ll have to use 2 rules, as the standards for this is not been set yet.
More

Don’t forget IPv6 if you are targeting Asia

February 9th, 2012 No Comments, SEO, by Joakim Ling.

IPv6 when targeting AsiaFor a long time we all have known that IPv4 limitations has come to an end. In the western world we are still heavily depending on IPv4 in a traditional way. However when it comes to younger and bigger Internet nations such as China and India, relaying on IPv4 is a disaster.
More

Use ssh-copy-id on a different port

February 9th, 2012 No Comments, Linux, by Joakim Ling.

Copy ssh-copy-id different portssh-copy-id is a script that uses ssh to log into a remote machine and install your public key. I recently had to do this on a server that had ssh on a different port. Normally as you do “-p 6000″ but in this case a bit tricky
More

Auto scaling with Amazon EC2 ELBUsing the Amazon Web services is a modern way to have your environment in the Cloud. It supports load balancing between your instances and thanks to Auto Scaling you’ll never need to pay for more than you use.

Basically the Auto Scaling launches additional instances to meet your demand, usually with help of a CPU alarm. Later removes them when not needed any more.
More

WP Easy Backup“WP Easy Backup” is a WordPress plugin that will create a database dump and zip all your media, theme and plugin files.
More

How to sudo echo to a file with help of tee

January 25th, 2012 No Comments, Linux, by Joakim Ling.

Sudo echo to file with teeI wasted a good few hours trying to find a good solution on how to save an echoed string with sudo. I tried “sudo echo ..” and lots of different combinations before I made it work.
More

Get Custom TaxonomyIf you’ve registered a custom taxonomy it’s a bit different to get data from than how you’d normally do for categories.
More

Update timezone and time in LinuxThe system time is often a symlink to the file /etc/localtime or the time zone file on the time zone directory. The definition for time zones can be written in short form as UTC±n (or GMT±n), where n is the offset in hours.
More

Replace html tags with regexp

November 29th, 2011 No Comments, PHP, by Joakim Ling.

Replace HTML tags with regexpRegular expressions are an easy way to match or replace pieces of your content, but can be tricky if you are new to it. Here are a few examples to replace html tags.
More

PCRE documentationThe PCRE library is a set of functions that implement regular expression pattern matching using the same syntax and semantics as Perl, with just a few differences. Some features that appeared in Python and PCRE before they appeared in Perl are also available using the Python syntax, there is some support for one or two .NET and Oniguruma syntax items, and there is an option for requesting some minor changes that give better JavaScript compatibility. from original documentation PHP PCRE
More

Rewrite/redirect URL tipsThis’s where you’ll work the magic to get the URL structure you want in the most optimized way possible. Some of the most common used rewrite usage are to shorten long URLs to short-friendly, protect your self against hotlinking, transforming dynamic ?page=title&section=foo to friendly /title/foo/ or redirecting missing pages and much much more.
More

Zend studio performance issues (typing lag)

November 9th, 2011 No Comments, PHP, by Joakim Ling.

One of the most common used IDE for PHP developers is Zend Studio for Eclipse. Great for lazy programmers as that is consider being a plus nowadays. Have a reliable refactoring, testing, debugging and integrated with subversion is a must if you want to increase your development time. Well who has time to look for all those FIXME and TODO?

But I’ve noticed that sometimes I get performance issues, specially with typing lag. Being a fast typer there is nothing more annoying then a machine slowing you down.
More

Remove slug from custom post type

November 8th, 2011 46 Comments, Wordpress, by Joakim Ling.

Remove slug from custom post typeIn WordPress 2.9 custom post type was introduced, that opened a new world for many WordPress developers. I’ve come across a painful issue when it comes to removing the slug and not destroying the rewrite rules for other post types. This only concerns those who are using %postname% as permalink structure and want to add a custom post type so that the urls for them are in the same way as normal posts and pages: http://siteurl/%custom_post_type_title%/.
More