CSS Viewport Tricks
Note to self: you can specify various viewport properties such as initial-scale and user-zoom via <meta /> tags or directly via CSS.
WordPress Prefix Post Titles
A reader recently asked how they can prepend the post date to the post title. Here is a quick and easy way to do it by filtering WordPress’ the_title hook.
jQuery Truncate Text
Here are a few choice code snippets to truncate text with jQuery. Useful for fine-tuning responsive layouts, or just truncating strings of text in general.
PHP foreach loop
I am always using this PHP code snippet, which basically loops through an array that may or may not include nested arrays. So to make things easier, I am posting here for quick reference.
WordPress repair and optimize InnoDB
This tutorial explains how to use WordPress’ built-in tools for optimizing database tables that are of the InnoDB type. Also works for good ’ol MyISAM database tables.
Force file download with .htaccess
Here is a quick .htaccess snippet that will force files to download instead of displaying in the browser. This method works for any site running on an Apache server.
CSS box-sizing all elements
The CSS box-sizing property makes it much easier to work with elements that have padding and borders. Here is a ruleset that will apply the box-size property to all elements.
Share links without sending referrer information
Here is a quick tip for sending links without including any referrer information. I found this service used at WordPress.com.
Specify images for web pages
This is a general technique for specifying an official image for your site, without actually displaying it on the front-end. Useful for catch-all social-media purposes.
WordPress Change Excerpt Length
This code snippet is SO easy.. check it out if you want to change the default number of words included by default in WordPress excerpts.
WordPress Create New User
Two ways to programmatically create new users in WordPress. The first method uses wp_create_user() and the second method uses wp_insert_user().
PHP Sanitize Form Data
On the Web, Cross-Site Scripting (XSS) is one of the most common types of attacks. Fortunately, there is an easy fix: always filter input data and always escape output data.