WordPress Move Domain Names

Switching domain names when using WordPress involves a few steps you may not think are required. Since WordPress saves the domain name permanently to the database, we have to modify the database along with a few configuration files to move WordPress to a different name. Below is a step by step guide to move your WordPress installation from your old domain name to your shiny new domain name.

This tutorial requires a few key pieces of software. You can either use the programs I list off or use your favorite alternative for each of these programs. Also, with any tutorial in which you have to edit files, creating a backup of everything is highly suggested

PHP Calculate Time Since

While working on a few changes to this website, I needed to code or find a relative time function for PHP. A function that will turn a timestamp or unix_timestamp into how long ago it was performed. For instance, if the timestamp is from yesterday, it would return the string of “1 day ago”, up to values of years. But there was an issue. Whenever I went online to find a function to do this, they all had a ton of nested if statements and a huge list of cases also. So I’m here to show you a simple way to code a PHP function to get relative time.

PHP Display Database Table

For administration panels or at times just data shown on the site, you will need to show a full database table. Now, you can manually enter the column’s rows names, but an easier way and more dynamic way is to just get the column names from MySQL or various other databases you use.

In this tutorial, we will be using the PHP class PDO. PDO is more secure than the original mysql_ functions, and if you haven’t yet, you should make the change right away. I should mention, that using this code could cause some security issues with your site. If you display personal information, account information, password hashes, session keys, or any other information similar, you will most likely have accounts hacked. Also, showing column names can help hackers run SQL injections because they will know the column names you are using. You can always use the MySQL alias for table names, so they return as a different name from the database column name.

PHP Send HTML Email

With the PHP mail function you can send all sorts of emails, including HTML emails and emails that have various attachments. But you will have to generate the proper headers and change the message text. The way the mail function in PHP works, is sending “plain text” emails. HTML emails are plain text emails but with additional headers and the proper encoding set. Below I will show you how you can simply send your HTML emails using PHP without using huge libraries that a lot of people will suggest.

JavaScript Tag Cloud

In a previous tutorial we made a PHP Tag Cloud generator function. But, some people don’t have access to PHP or need the tag cloud to update live using ajax or other means. Below is the JavaScript function and code. The code is fairly similar to the PHP Code, but just modified slightly for use with JavaScript. You call the function by identifying the DOM which all the words are listed in, and you also have to specify the Node Name, such as span or div.