Website Snapshots with WordPress Shortcode

screenshot

WordPress.com uses a nifty little tool to take screenshots of Commercial Themes. If you right click on a few of the screenshots on that page you’ll see that they have consistent URL form. The following shortcode makes use of the functionality on WordPress.com by rendering a screenshot of any webpage in your blog post. I [...]

Resizing Images using TimThumb.php

php-pics

I recently had a request for some shortcode that would render formatted images and text in a particular way. When I tried to imagine how the average author on one of my blogs would apply the shortcode, I ran into the problem of how image scaling would be handled. Some of the people I work [...]

Find and Replace Words in a WordPress Post

find-replace

This PHP function will search for a particular string of text in a WordPress post and replace it with alternative text of any kind. If you’re just getting into the affiliate business, this is a great way of instantly monetising your blog via specific keywords. If you’ve ever written about Thesis, you could, via the [...]

PHP Threaded Comment Class

thread

A few years ago I built a dodgy little site at Usenet.com.au that rendered Australian text Usenet newsgroups. I’ve since disabled posting while I give the website a complete face lift. One of the biggest challenges I faced in the early days was orientated around optimising threaded articles. With several million articles in the database [...]

Prevent WordPress Pages from appearing in Search Results

wp-search

Michael Harvey of New York, USA, asks: “I’ve set up private WordPress pages that I’m only giving to friends and family. However, when people use the WordPress search function, these private pages appear in search results. Do you know a fix?” I use the same functionality on my own site(s). I have countless private pages [...]

Calculate and highlight the differences between strings of text with PHP

php-differences

I was updating a CMS recently to archive various versions of data. If you’ve ever dealt with quality and version management you would appreciate the need to record all changes to specific text for the purpose of quality assurance. In my case, I needed to accomplish four tasks: Record specific changes to the published version [...]

Determine the Relationship between two Twitter Users

twitter-relationships

If you want to test the relationship between any two Twitter users (i.e. do they follow each other or don’t they), you can do so via a simple call to the following URL: http://twitter.com/friendships/exists.xml?user_a=martykhoury&user_b=kenpascoe This will return a XML file as follows: Alternatively, you could generate a JSON file that will simply render as either [...]

Include Twitter Data on your Website

twitter-data-website

Every application I build now is littered with various types of functionality that links them into different social network. If you’re reading this post it’s unlikely I’ll have to educate you on the merits of plugging your website into the social lives of your readers. What follows is some code that will help you integrate [...]

Randomly select rows from a LARGE database with MySQL

database

I have a particular database with over one million rows and was required to extract 10 random rows for inclusion on a page that featured products indiscriminately. My initial query looked a little something like this: SELECT id FROM table WHERE something = something ORDER BY RAND() LIMIT 10; The problem with a large table [...]

Force the Download of a File with PHP

force-download

I’ve recently created a large number of websites where I aggregate podcasts and provide a detailed backend subscription and collaboration platform for both publishers and content consumers. I’ll no doubt post details on what I’ve done (and how I’ve done it) another time, but the project(s) forced me to consider a number of issues that [...]

Zip a file or files with PHP

zip

I provided a simple function a few days ago that would unzip a file using PHP. As is usually always the case, it was followed up by a few emails asking for the best method of zipping a file or files. As it turns out, I’ve worked through some ZIP classes over the last few [...]