Blog Revival

Hello! I just came up with a new theme. Nothing fancy. No images. No galleries. Just plain old text. It looks like a blog design circa 2005. One thing for sure though, it’s fast since there’s not much overhead. This theme is based on the _s framework, a good starter theme kit developed by the WordPress development team themselves. How about that! If you’re interested in learning how the WordPress theme is constructed, download the underscore theme and study its code. You’ll be surprised what you’ll see. You’ll learn quite a bit by analyzing how this theme is constructed. Anyways, I think it’s time to revive this old crusty blog. It’s time to breathe some new life into it. You are probably asking, “where have you been?” Well, I’ve been concentrating on all my other blogs for the last several months. I just didn’t have the cycles to maintain this blog among all the other web projects. So maybe, a new theme will jumpstart the old blog. We shall see, indeed!

Twenty Twelve Title Contain No Spaces

There is a conflict between the Twenty Twelve WordPress and the All in One SEO Pack plugin. When the plugin is installed and you happen to be using the Twenty Twelve theme, the result is, there will be no space between your site title and blog title. You’ll notice this if you look at the title bar of your browser. After a couple of searches, I found a fix online. It involves editing the Twenty Twelve functions.php file and commenting out line 185 which contains the code below.

You will need to change:

add_filter( 'wp_title', 'twentytwelve_wp_title', 10, 2 );

and comment out:

// add_filter( 'wp_title', 'twentytwelve_wp_title', 10, 2 );

Also, you need to clear your browser cache to see results.

Twenty Twelve Theme

I recently changed themes from a custom made one, that I’ve used for a long time, to a theme called Twenty Twelve, the current WordPress default theme. I made one slight change though which alters the entire look of the theme. I changed font from the default ‘Open Sans’ to ‘Lato’ which is available from Google. To facilitate the change, I’m using my Webfonts plugin and this CSS code:

#page {font-family:'Lato', sans-serif;}

WordPress 3.5 Media Manager

I recently upgraded to WordPress 3.5. One thing about WordPress updates, they are super easy. One of the best features of WordPress 3.5 is the new Media Manager. Uploading images is a breeze. Just drag and drop a file, or manually choose file and click. Viewing previous uploaded images in the Media Library is a total experience now. Thumbnails of recent uploads are displayed in rows and columns, and they are scrollable. Selecting an image and inserting it to a post is way too easy. Kudos to the development team for a fantastic job with this upgrade, and especially with the work on the new Media Manager.

Tricky WordPress Multisite Setup

I was converting a regular WordPress blog to a Multisite blog the other day. I got stuck in the part where I needed to edit the wp-config.php file. I applied the changes to wp-config.php as suggested in the installation instructions. The problem was I wasn’t seeing the Multisite menus you would normally find under ‘My Sites’ inside the WordPress Dashboard. The installation instructions tells you to add the following lines to your wp-config.php file.

/** Enable WordPress Multisite */
define('WP_ALLOW_MULTISITE', true);
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
$base = '/';
define('DOMAIN_CURRENT_SITE', 'domain.com');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);

It was a silly mistake on my part. I placed these entries at the end of the wp-config file. It is important that these lines remain above the absolute path statement and before the wp-settings are loaded. See below.

/* That's all, stop editing! Happy blogging. */
 
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') ) define('ABSPATH', dirname(__FILE__) . '/');
 
/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');

Keep these lines at the end of the wp-config.php file.

WP-Admin Trailing Slash Problem

I had this WordPress wp-admin trailing slash problem for a couple of weeks now. When I don’t include a trailing slash after the wp-admin directory when logging in to WordPress, I will get a 404 missing page error. It’s a little annoying if you ask me, but it doesn’t really affect blog readers. It only shows up if you want to login to the WordPress Dashboard, and you forget to type the trailing slash at the end of wp-admin. Example below.

site.com/wp-admin/ <– this redirects to the WordPress login ok.
site.com/wp-admin <– this will result in a 404 missing page error.

So, I tried a couple of suggestions I found online, but the suggested changes to the .htaccess file didn’t seem to fix the issue. A couple of occasions, the suggestions were exactly the same code I already had in my .htaccess file. So, I tried a couple more suggestions. I noticed one blog post had a couple more lines in the .htaccess file that I haven’t seen in mine. So, I tried it and it worked. So, here are the changes I made.

I added these two lines to my .htaccess.

RewriteEngine On
RewriteBase /

I think the key code is in the second line. It basically establishes the base URL.

Regain Your WordPress Admin Account

So, I decided to get cute and changed my WordPress admin username to a username I wanted via a utility called phpMyAdmin. I went to the wp_users table and made a simple username change to the user_login field. I logged out and logged in back to the WordPress Dashboard. Disaster! I just lost both my WordPress admin and network admins rights. My former admin account has been reduced to a regular plebe. So, this is how a regular WordPress subscriber looks like.

It was a scary five minutes at WordPress land. I’m laughing now, but I wasn’t then. So, I went back to phpMyAdmin and also changed the user_nicename and display_name to the wp_users table hoping that would fix it. No cigar. Panic set in. After a few Google searches, I finally found the solution. Thanks to people who post their solutions online.

What a relief! First, you have to make sure you have the right user_id, especially if you have a multisite blog. Go to your wp_users table and make a mental note of your admin ID. It’s usually an ID of 1.

Next, I went to the wp_usermeta table and changed the wp_capabilities entry to a:1:{s:13:”administrator”;s:1:”1″;}.  The key here is the entry s:13. My account was reset to s:1 for some reason. I temporarily changed it to s:10, but it didn’t work. Setting it to s:13 did the trick. It worked wonderfully.

Now, I’ve regained all the admin rights for each blog that’s on the network, except that I’ve lost the Network Admin. Well, another Google search. Thank you. To make the story short, I also had to edit the wp_sitemeta table. Look for the meta_key and change to a:1:{i:0;s:11:”yournewname”;}. The s:11 is the length of “usernewname” which is 11.

That was the fix. Whew. A close shave. All in all, all is good once again at WordPress land. I am one happy admin. Just a bit on the adventurous side, but otherwise a happy camper. I’m posting this article because, I know some dufus admin in the future will probably do the same thing that I did. It wasn’t all that bad. It was just a little bit disconcerting when you lose all admin rights.

Use UUIDGEN For Passwords

An impenetrable system is only as good as its weakest password. Computers systems are often attacked using brute force. Most users tend to use really simple and easy to guess passwords. The use of complex passwords on the other hand, makes it almost impossible for them to remember. That’s why passwords typically fall in the 6-8 character range.

For systems and applications, that don’t need human intervention, when communicating to databases and other systems, a much more complex password can be assigned. These passwords typically do not need to be typed-in on forms, so they can be long, difficult and outrageous. There’s a Linux utility called UUIDGEN which randomly creates and generates unique universal identifiers.

A typical output would be:

150152b0-cd0e-11e1-9b23-0800200c9a66

These keys are perfect for systems and applications. For example, WordPress requires a username and password to talk to the MySQL database. The database credentials are typically stored in wp-config.php file. A key generated by UUIDGEN can be used in this scenario. This is just one example where long and difficult passwords can be deployed. They can be used for other purposes as well.

So, if you have access to a Linux system, to generate a unique key, all you have to do is type the command, “uuidgen” in the Terminal.

Linode Kicks Ass

Get a web server running within minutes. Choose a Linux distro, resources, and node location. That’s essentially Linode in a nutshell. I signed up with Linode about two weeks ago. I’ve been playing around with it since then. I can happily say that I’m very impressed with Linode. It has exceeded my expectations.

If you want total control of your web server, Linode VPS is really the way to go. You will be asked to choose server size when you sign up. They come in many configurations. I chose Linode 512. You also need to choose a data center location. There are six data centers worldwide. I choose the one in Fremont since I live in California.

So far, I’m loving the guaranteed server resources. My websites are running faster . I chose Ubuntu 12.04 LTS 32 bit because it’s a Linux distro I am very familiar with. Apparently, 57% Linode users have chosen Ubuntu as well. I already transferred a couple of domains over to Linode. The websites are screaming.

I plan to migrate more websites later. If you are curious about how Linode works, here is a short list of features to get you started:

  • Full ssh and root access
  • Guaranteed Resources
  • 4 processor Xen instances
  • Out of band console shell
  • Dedicated IP address, premium bw
  • Six datacenters in the US, Europe, and Asia-Pacific
  • HA and Clustering Support
  • Bandwidth pooling
  • Managed DNS with API

MySQL mysql_connect new_link

I want to share a database connection access problem I had last week, while working with a custom PHP script inside WordPress. I had created this WordPress Page Template containing some PHP code that needs access to the database. The problem was that the database connection for my custom script overwrote the WordPress database connection that was previously establish, causing certain parts of WordPress to not display properly.

It took me a while to figure out that it was the newer database connection of my custom PHP script that was causing the previously established WordPress database connection to disappear. Hence, certain parts of the WordPress page were not displayed. Little did I know, that the fix was quite simple. So, here’s a sample of my mysql_connect code. Prior to this line, I’ve already set the variables.

Mysql_connect

$db=mysql_connect($host,$username,$password);

The Fix

Simply add a fourth parameter called new_link and set it to TRUE.

$db=mysql_connect($host,$username,$password,TRUE);

What this does is basically telling mysql_connect to establish a new connection, while keeping the older mysql_connect connection around, in case we need to access it at a later time. It’s amazing how one little switch in a command can make a huge difference to this seemingly simple code. Anyways, adding a fourth parameter and setting it to TRUE was the solution.