How to create a simple and efficient PHP cache

Step one: Create the top-cache.php file

We need to create two files. Here’s the first one: Create a new file named top-cache.php and paste the code below in it.

<?php
$url = $_SERVER["SCRIPT_NAME"];
$break = Explode('/', $url);
$file = $break[count($break) - 1];
$cachefile = 'cached-'.substr_replace($file ,"",-4).'.html';
$cachetime = 18000;

// Serve from the cache if it is younger than $cachetime
if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile)) {
    echo "<!-- Cached copy, generated ".date('H:i', filemtime($cachefile))." -->\n";
    include($cachefile);
    exit;
}
ob_start(); // Start the output buffer
?>

So, what this code does? The first 5 lines create the cached file name according to the current php file. So, if you’re using a file named list.php, the cached file will be named cached-list.html.

Line 6 creates a $cachetime variable which determines the life of the cache.

Lines 9 to 13 are a conditional statement which look for a file named $cachefile. If the file is found, a comment is inserted (line 10) and the $cachefile file is included. Then, the exit statement stops the execution of the script and the file is sent to the client brother. Which means that if a static file is found, no php code is interpreted by the server.

Line 14 creates a buffer, if the $cachefile file isn’t found. That’s all for the top-cache.php file.

Step two: Create the bottom-cache.php file

Now, create a second php file, named bottom-cache.php and paste the code below in it.

<?php
// Cache the contents to a file
$cached = fopen($cachefile, 'w');
fwrite($cached, ob_get_contents());
fclose($cached);
ob_end_flush(); // Send the output to the browser
?>

If a file named $cachefile isn’t found on your server, this code is executed and create the file, so next time the page will be called, the $cachefile static file will be served to the client browser instead of executing the whole PHP file.

Step three: Include cache files on your page

Now that you have created the two necessary files, you simply have to include them on the php page you wish to cache. As you probably guessed, the top-cache.php file must be included in the beginning of your php page and the bottom-cache.php at the end, as shown below:

<?php

include('top-cache.php'); 

// Your regular PHP code goes here

include('bottom-cache.php');
?>

Now if you test the cache on a slow page, you’ll be amazed by how faster the page is. This easy cache is my favorite solution when working on “from scratch” PHP websites.

How to prevent WordPress from asking FTP credentials

Paste the following line in your wp-config.php file. This file is located in the root of your WordPress install.

define('FS_METHOD', 'direct');

Please note that the code snippet provided above might not work on all hosting providers, and might even cause security issues if your host is badly configured, so avoid using it if you’re not sure about your hosting.

I use VidaHost on WPRecipes and my other blogs. WP Web Host is also good for smaller websites.

Thanks to WP Tuts+ for the cool tip!

How to hide theme editor from WordPress dashboard

Simply paste the following code on the theme functions.php file. Specify the admin username on line 7 so the admin will still see the theme editor link.

function wpr_remove_editor_menu() {
  remove_action('admin_menu', '_add_themes_utility_last', 101);
}

global $remove_submenu_page, $current_user;
get_currentuserinfo();
if($current_user->user_login == 'admin') { //Specify admin name here
    add_action('admin_menu', 'wpr_remove_editor_menu', 1);
} 

How to secure your WordPress blog uploads directory

Create a file named .htaccess and paste the following code in it. Once done, upload the filet into your wp-content/uploads directory.

The following example will only accept images files. If you need to be able to upload other file types, such as .pdf, don’t forget to add the file extension to the list on line 5.

<Files ~ ".*..*">
	Order Allow,Deny
	Deny from all
</Files>
<FilesMatch ".(jpg|jpeg|jpe|gif|png|tif|tiff)$">
	Order Deny,Allow
	Allow from all
</FilesMatch>

Thanks to Jeff Starr for the great tip!

Useful PHP code snippets and functions

Convert .pdf files to .jpg using PHP and Image Magick

Here is a simple snippet to convert a .pdf file into a .jpg image. This is extremely useful if you need to generate preview images of your .pdf files. Please note, you must have the Image Magick extension installed on your server to use this snippet.

$pdf_file   = './pdf/demo.pdf';
$save_to    = './jpg/demo.jpg';     //make sure that apache has permissions to write in this folder! (common problem)

//execute ImageMagick command 'convert' and convert PDF to JPG with applied settings
exec('convert "'.$pdf_file.'" -colorspace RGB -resize 800 "'.$save_to.'"', $output, $return_var);


if($return_var == 0) {              //if exec successfuly converted pdf to jpg
    print "Conversion OK";
}
else print "Conversion failed.<br />".$output;

Credits: http://snipplr.com/view/48513

Sanitize database inputs

In order to keep your database safe, you have to be very careful about the input you’re going to save. Here is a super handy function which sanitize inputs to make sure you’re not inserting malicious code into your database.

function cleanInput($input) {
 
  $search = array(
    '@<script[^>]*?>.*?</script>@si',   // Strip out javascript
    '@<[\/\!]*?[^<>]*?>@si',            // Strip out HTML tags
    '@<style[^>]*?>.*?</style>@siU',    // Strip style tags properly
    '@<![\s\S]*?--[ \t\n\r]*>@'         // Strip multi-line comments
  );
 
    $output = preg_replace($search, '', $input);
    return $output;
  }

function sanitize($input) {
    if (is_array($input)) {
        foreach($input as $var=>$val) {
            $output[$var] = sanitize($val);
        }
    }
    else {
        if (get_magic_quotes_gpc()) {
            $input = stripslashes($input);
        }
        $input  = cleanInput($input);
        $output = mysql_real_escape_string($input);
    }
    return $output;
}

// Usage:
$bad_string = "Hi! <script src='http://www.evilsite.com/bad_script.js'></script> It's a good day!";
  $good_string = sanitize($bad_string);
  // $good_string returns "Hi! It\'s a good day!"

  // Also use for getting POST/GET variables
  $_POST = sanitize($_POST);
  $_GET  = sanitize($_GET);

Credits: http://css-tricks.com/snippets/php/sanitize-database-inputs/

Create image data URIs using PHP

Instead of providing a traditional address to the image, the image file data is base64-encoded and stuffed within the src attribute. Doing so saves a network request for each image, and prevent exposure of directory paths. Please note that IE7 and below are not compatibles with data URIs.

// A few settings
$image = 'cricci.jpg';

// Read image path, convert to base64 encoding
$imageData = base64_encode(file_get_contents($image));

// Format the image SRC:  data:{mime};base64,{data};
$src = 'data: '.mime_content_type($image).';base64,'.$imageData;

// Echo out a sample image
echo '<img src="',$src,'">';

Credits: http://davidwalsh.name/data-uri-php

Generate CSV file from a PHP array

Here is a simple but efficient function to generate a .csv file from a PHP array. The function accept 3 parameters: the data, the csv delimeter (default is a comma) and the csv enclosure (default is a double quote).

function generateCsv($data, $delimiter = ',', $enclosure = '"') {
       $handle = fopen('php://temp', 'r+');
       foreach ($data as $line) {
               fputcsv($handle, $line, $delimiter, $enclosure);
       }
       rewind($handle);
       while (!feof($handle)) {
               $contents .= fread($handle, 8192);
       }
       fclose($handle);
       return $contents;
}

Credits: http://snipplr.com/view/66856/generate-csv-file-from-array-using-php/

Unzip files with PHP

The following function takes two parameters: The .zip file to unzip, and the destination directory.

function unzip_file($file, $destination){
	// create object
	$zip = new ZipArchive() ;
	// open archive
	if ($zip->open($file) !== TRUE) {
		die ('Could not open archive');
	}
	// extract contents to destination directory
	$zip->extractTo($destination);
	// close archive
	$zip->close();
	echo 'Archive extracted to directory';
}

Credits: http://www.catswhocode.com/blog/snippets/unzip-zip-files

Detect location by IP

Here is an useful code snippet to detect the location of a specific IP. The function below takes one IP as a parameter, and returns the location of the IP. If no location is found, UNKNOWN is returned.

function detect_city($ip) {

        $default = 'UNKNOWN';

        if (!is_string($ip) || strlen($ip) < 1 || $ip == '127.0.0.1' || $ip == 'localhost')
            $ip = '8.8.8.8';

        $curlopt_useragent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)';

        $url = 'http://ipinfodb.com/ip_locator.php?ip=' . urlencode($ip);
        $ch = curl_init();

        $curl_opt = array(
            CURLOPT_FOLLOWLOCATION  => 1,
            CURLOPT_HEADER      => 0,
            CURLOPT_RETURNTRANSFER  => 1,
            CURLOPT_USERAGENT   => $curlopt_useragent,
            CURLOPT_URL       => $url,
            CURLOPT_TIMEOUT         => 1,
            CURLOPT_REFERER         => 'http://' . $_SERVER['HTTP_HOST'],
        );

        curl_setopt_array($ch, $curl_opt);

        $content = curl_exec($ch);

        if (!is_null($curl_info)) {
            $curl_info = curl_getinfo($ch);
        }

        curl_close($ch);

        if ( preg_match('{<li>City : ([^<]*)</li>}i', $content, $regs) )  {
            $city = $regs[1];
        }
        if ( preg_match('{<li>State/Province : ([^<]*)</li>}i', $content, $regs) )  {
            $state = $regs[1];
        }

        if( $city!='' && $state!='' ){
          $location = $city . ', ' . $state;
          return $location;
        }else{
          return $default;
        }

    }

Credits: http://www.catswhocode.com/blog/snippets/detect-location-by-ip

Email error logs to yourself

Error logs are extremely useful, but you have to read them to know if a problem happened. And let’s be honest: When we think everything is fine, we do not look at logs very often.

This function will email you the log when an error has been raised on your site. Very handy to stay in touch with your website activity.

function nettuts_error_handler($number, $message, $file, $line, $vars){
	$email = "
		<p>An error ($number) occurred on line 
		<strong>$line</strong> and in the <strong>file: $file.</strong> 
		<p> $message </p>";
		
	$email .= "<pre>" . print_r($vars, 1) . "</pre>";
	
	$headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
	
	// Email the error to someone...
	error_log($email, 1, '[email protected]', $headers);

	// Make sure that you decide how to respond to errors (on the user's side)
	// Either echo an error message, or kill the entire project. Up to you...
	// The code below ensures that we only "die" if the error was more than
	// just a NOTICE. 
	if ( ($number !== E_NOTICE) && ($number < 2048) ) {
		die("There was an error. Please try again later.");
	}
}

// We should use our custom function to handle errors.
set_error_handler('nettuts_error_handler');

// Trigger an error... (var doesn't exist)
echo $somevarthatdoesnotexist;

Credits: http://net.tutsplus.com/tutorials/php/quick-tip-email-error-logs-to-yourself-with-php/

Remove Microsoft Word HTML tags

If you’re working with clients, I guess you already had many problems with people pasting text from Microsoft Word, which results in bad markup and various code problems…

The following function takes some nightmarish Word HTML and return a clean HTML output that you can use safely on the web.

function cleanHTML($html) {
$html = ereg_replace("<(/)?(font|span|del|ins)[^>]*>","",$html);

$html = ereg_replace("<([^>]*)(class|lang|style|size|face)=("[^"]*"|'[^']*'|[^>]+)([^>]*)>","<\1>",$html);
$html = ereg_replace("<([^>]*)(class|lang|style|size|face)=("[^"]*"|'[^']*'|[^>]+)([^>]*)>","<\1>",$html);

return $html
}

Credits: http://tim.mackey.ie/CommentView,guid,2ece42de…

Watermark images automatically

If you’re displaying your own images on your websites, chances are that you don’t want to see them everywhere on the web the next day. To prevent image theft and make sure to be credited as the original creator of the image, watermarking them is generally a good idea. The following function allows you to automatically add a watermark on your images.

function watermarkImage ($SourceFile, $WaterMarkText, $DestinationFile) { 
   list($width, $height) = getimagesize($SourceFile);
   $image_p = imagecreatetruecolor($width, $height);
   $image = imagecreatefromjpeg($SourceFile);
   imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width, $height); 
   $black = imagecolorallocate($image_p, 0, 0, 0);
   $font = 'arial.ttf';
   $font_size = 10; 
   imagettftext($image_p, $font_size, 0, 10, 20, $black, $font, $WaterMarkText);
   if ($DestinationFile<>'') {
      imagejpeg ($image_p, $DestinationFile, 100); 
   } else {
      header('Content-Type: image/jpeg');
      imagejpeg($image_p, null, 100);
   }
   imagedestroy($image); 
   imagedestroy($image_p); 
}

/******** usage **********/
$SourceFile = '/home/user/www/images/image1.jpg';
$DestinationFile = '/home/user/www/images/image1-watermark.jpg'; 
$WaterMarkText = 'Copyright phpJabbers.com';
watermarkImage ($SourceFile, $WaterMarkText, $DestinationFile);

Credits: http://www.phpjabbers.com/put-watermark-on-images-using-php…

Automatic mailto links

The following snippet looks for an email address in a string, and replace it by a mailto link. Pretty useful on private applications, but for obvious spamming reason I do not recommend using this on a website, blog or forum.

$stringa = "This should format my email address [email protected]";

$pattern = "/([a-z0-9][_a-z0-9.-]+@([0-9a-z][_0-9a-z-]+\.)+[a-z]{2,6})/i";
$replace = "\\1";
$text = preg_replace($pattern, $replace, $stringa);
echo htmlspecialchars($text);

Credits: http://css-tricks.com/snippets/php/automatic-mailto-links/

How to display a custom message on WordPress registration page

First, update the code below with your message on line 6. Then, paste it into your functions.php file. You’re done! Just remove the code to remove the message if needed.

add_action('register_form', 'register_message');
function register_message() {
    $html = '
        <div style="margin:10px 0;border:1px solid #e5e5e5;padding:10px">
            <p style="margin:5px 0;">
            Joining this site you agree to the following terms. Do no harm!
            </p>
        </div>';
    echo $html;
}

Thanks to Kevin Chard for the code!

jQuery plugins for awesome web typography

FitText.js


FitText is a simple jQuery plugin that automatically make a text fit the width of its parent element. Perfect for awesome, responsive headlines!
Download: http://fittextjs.com/

Lettering.js


Although CSS3 and the @font-face directive have definitely improved web typography, it doesn’t offer complete down-to-the-letter control. This is why Lettering.js have been created. If you’re looking for a simple solution to get the control of each individual letter of your headline, then this plugin is for you.
Download: http://letteringjs.com/

Kern.js


When I create design or front-end code, I love being able to test things in my brother. Kern.js is not a jQuery plugin, but a bookmarklet that allow you to edit texts from websites: Make them bigger, rotate letters, add space… A very useful tool for testing and finding new possibilities.
Download: http://www.kernjs.com/

SlabText.js


SlabText is a very useful jQuery plugin that splits headlines into rows before resizing each row to fill the available horizontal space. Basically, it means that your headline will always look great whatever of the client screen size. A must-have for responsive websites!
Download: http://www.frequency-decoder.com/2012/01/08/slabtext…

Bacon.js


Bacon is a jQuery plugin that allows you to wrap text around a bezier curve or a line. Very cool for magazine-like wrapped text effects!
Download: http://baconforme.com/

Approach


Approach is an interesting plugin if you’re looking to give a text (For exemple, a call-to-action button) a special effect to attract the reader attention. This plugin works in a very similar manner to jQuery animate, but it animates over distance instead of time. The closer you get to the text, the more the style will be applied.
Download: http://srobbin.com/jquery-plugins/approach/

Arctext.js


Here is another cool plugin, based on Lettering.js, which arrange each letter along a curved path. Can be really nice for titles, headlines or other fancy texts!
Download: http://tympanus.net/codrops/2012/01/24/arctext-js-curving…

jMetronome


According to 24ways.org, vertical rhythm is the spacing and arrangement of text as the reader descends the page and is contributed to by three factors: font size, line height and margin or padding. All of these factors must calculated with care in order that the rhythm is maintained.

jMetronome is a jQuery plugin which can take care of maintaining a correct vertical rhythm on your pages, even if they contain media elements such as images or videos.

Download: http://www.fortes.com/2008/jmetronome-using-jquery-to-keep-typographic-rhythm

How to create a dropdown menu of tags

Simply paste the following code where you want the dropdown menu to be displayed. Note that you can use your own taxonomy: Just modify the code on line 5 according to your needs.

<h2><?php _e('Posts by Tags'); ?></h2>
<form action="<?php bloginfo('url'); ?>/" method="get">
<div>
<?php
$select = wp_dropdown_categories('taxonomy=post_tag&show_option_none=Select tag&show_count=1&orderby=name&echo=0');
$select = preg_replace("#<select([^>]*)>#", "<select$1 onchange='return this.form.submit()'>", $select);
echo $select;
?>
<noscript><div><input type="submit" value="View" /></div></noscript>
</div></form>

Thanks to WP Lover for the code!

Awesome CSS3 generators to simplify front end development

CSS3 Generator


This generator is definitely one of my favorites, as it allow you to generate more than 10 different CSS3 effects, such as border radius, text shadows, transitions, and more.
Visit css3generator.com

CSS Gradient generator


CSS gradients are cool, but it’s also a bit tricky to remind all the possibilities. This generator will help you to create a perfect looking CSS gradient with no headache.
Visit CSS Gradient generator

CSS button generator


In my opinion, this is the most advanced CSS3 button generator available on the internet. Adjust settings, copy the code, and you’re done!
Visit CSS button generator

CSS3Gen


CSS3Gen is a nice generator which allows you to easily create useful snippets of CSS3 and copy them straight into your projects. CSS3Gen take care of all the vendor prefixes.
Visit CSS3Gen

CSS3 Please


CSS3 Please is a very effective tool to test your CSS3 code: Just edit the CSS rules from the editor, and a special container will receive instant changes so you can have a preview of what you’re doing.
Visit CSS3 Please

Layer Styles


If you’re familiar with Photoshop, there’s no doubt that you will love Layer Style, a CSS3 generator which replicate the look and feel of the popular software from Adobe.
Visit Layer Styles

Border image generator


As you can guess, this tool helps you to create borde images. Simple and efficient!
Visit Border image generator

CSS3 Pie


Internet Explorer has been a front-end coder nightmare since 10 years, and unfortunately, it’s not going to end very soon. That said, tools like CSS3 Pie can definitely help when a IE compatible code is needed. This very useful generator makes Internet Explorer 6-9 capable of rendering several of the most useful CSS3 decoration features.
Visit CSS3 Pie

CSS Easing Animation Tool


With this tool, every developer now have a simple way to generate CSS easing animations. Vendor prefixes are supported so you don’t have to worry about cross-browser compatibility.
Visit CSS Easing Animation Tool

Font-Face generator


Want to use fancy fonts on your website? Simply upload it to Font Squirrel font-face generator, and get your CSS code as well as your font in all formats needed by the different browsers. This tool helped me a lot in the last two years.
Visit Font-Face generator

Practical tips to save bandwidth and reduce server load

Use CSS instead of images

Images can definitely consume lots of bandwidth. As most browsers are now able to render graphics such as box shadows or rounded borders, you should definitely use CSS instead of images when possible, as CSS code consume a lot less bandwidth than images.

If you need your website to be compatible with old browsers such as the infamous IE6, the solution is to use an alternative stylesheet and images only for the old browser. Use a conditional comment to link to your IE6 only stylesheet:

<!--[if IE 6]>
<link href="ieonly.css" rel="stylesheet" />
<![endif]-->

Always make sure that your images are optimized

Although you can replace many images with CSS, images are still an important part of a website. But when you need to use images, you have to make sure they are optimized for being displayed online.

If you’re using Adobe Photoshop, you can use the “Save for web” option that allow you to easily find the best compromise between quality and image size. Another option is to use a free online service to reduce image size while keeping its quality high. This service is called Smush It and I can’t stop using it to optimize my images.

If you’re using WordPress, you’ll be happy to read that a free Smush It plugin is available. Install it, and it will automatically optimize any image you’ll upload to your WordPress site using the uploader. Cool, isn’t it?

Use a cache on your website

Caching is the action of retrieving data from a ready storage (called cache) instead of using resources to generate it every time the same information is needed.

The code below will add caching to files as such as .jpg, .gif, .swf. The cache will last 1 week. For other file types, you may adjust the cache life. For example, CSS and JavaScript files should be cached for 12 hours.
Paste it into your .htaccess file.

<filesmatch "\.(jpg|jpeg|png|gif|swf)$"="">
Header set Cache-Control "max-age=604800, public"
</filesmatch>

WordPress user? Then I definitely recommend installing the W3 Total Cache plugin. It is a free and complete caching solution that helps optimizing every aspect of your blog or website. It makes your site running faster and use less bandwidth.

Prevent bandwidth stealing and hotlinking

A bad but very common practice on the internet is hotlinking: What is hotlinking? Here is a quick example: Website A host an image to display on a html page. Website B wants to display the same image that website A use. Website B link to website A image, causing website A bandwidth to be consumed every time website B is loaded.

So definitely, you don’t want to pay bandwidth to others, right? To do so, create an image (it can be a 1*1 transparent gif image, or an image stating “don’t steal my images” and upload it to your server, or even better to a free image hosting website. Then, add the following code into your site .htaccess file. Don’t forget to update the code with your own website and image urls:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yourdomain.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yourdomain2.com [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ http://yourserver.com/yourimage.gif [NC,R,L]

Use Minify to compress CSS and JavaScript files

Minify is a PHP5 app that helps you follow several of Yahoo!’s Rules for High Performance Web Sites. It combines multiple CSS or Javascript files, removes unnecessary whitespace and comments, and serves them with gzip encoding and optimal client-side cache headers.

Please not that Minify is included in the WordPress W3 Total Cache plugin, so if you already installed this plugin you have nothing else to do to minify your blog.

Use hosting websites to host big files

If you have to host big files (videos, photoshop psd files, big images, etc) you should definitely rely on a third party service such as Dropbox to host your files. That way, when someone will download it, it will not consume your server bandwidth but instead the bandwidth of the third party service.

Use GZip compression on your PHP files

GZip compression is a technique that compress data being sent out from your web server, and have the browser decompress this data on the fly, thus reducing the amount of data sent and increasing the page display speed. Recent browsers all supports GZip compression.

To achieve GZip compression on your website, you have to create 2 files. Name the first one gzip_header.php:

<?php
$phpver = phpversion();
$useragent = (isset($_SERVER["HTTP_USER_AGENT"]) ) ? $_SERVER["HTTP_USER_AGENT"] : $HTTP_USER_AGENT;

if ( $phpver >= '4.0.4pl1' && ( strstr($useragent,'compatible') || strstr($useragent,'Gecko') ) ) {
if ( extension_loaded('zlib') ) {
ob_start('ob_gzhandler');
}
} else if ( $phpver > '4.0' ) {
if ( strstr($HTTP_SERVER_VARS['HTTP_ACCEPT_ENCODING'], 'gzip') ) {
if ( extension_loaded('zlib') ) {
$do_gzip_compress = true;
ob_start();
ob_implicit_flush(0);
header('Content-Encoding: gzip');
}
}
}
?>

Now, create a second file and name it gzip_footer.php:

<?php
$gzip_contents = ob_get_contents();
ob_end_clean();

$gzip_size = strlen($gzip_contents);
$gzip_crc = crc32($gzip_contents);

$gzip_contents = gzcompress($gzip_contents, 9);
$gzip_contents = substr($gzip_contents, 0, strlen($gzip_contents) - 4);

echo "\x1f\x8b\x08\x00\x00\x00\x00\x00";
echo $gzip_contents;
echo pack('V', $gzip_crc);
echo pack('V', $gzip_size);
?>

Once you have created the gzip_header.php and the gzip_footer.php files, you can create a new file which includes your regular template between the gzip_header.php and the gzip_footer.php files:

<?php
include('gzip_header.php');
include('your_template_file.php');
include('gzip_footer.php');
?>

Source article for the codes: http://www.techiecorner.com/7/speed-up-and-save-your-website…

Use a reliable web hosting

At last but not least, it is obvious that you should use a reliable web host if you want your website to be fast. I’ve used lots of web hosts and some are really good and some other sucks. For example, you should definitely avoid Phpnet.org and Maven Hosting, both of them shut my websites down just because they were receiving too many visits.

On the other hand, I was pleased with WP Web Host, which is really good if you’re hosting a small or medium WordPress site or blog. If you have a popular and/or large website, I definitely recommend Vidahost, which is CatsWhoCode webhost. My site is still fast although I receive lots of traffic. If you want to get some hosting from Vidahost, don’t forget to use my custom coupon CATSWHOCODE to get 10% off anything.