jQuery and WordPress No Conflict

Last night, I was doing some work on my blog as ever since I wrote the custom theme I use (and since updated it) I have neglected my mobile visitors and the mobile views not only looked awful but in some cases, depending on the device you were using made the content totally invisible due to the black wallpaper background and the black body text appearing on top of each other.

I decided I wanted to add a fixed top header that faded away as you scroll down the page and reappeared as you scroll back up as I’ve seen it on a number of sites before and the effect is both aesthetically pleasing and maximises the real estate on devices with small screens such as smartphones. I found a site which had a good reference on how to implement this using jQuery and I added the script to the site and the relevant CSS selectors but it wasn’t working.

Using the Developer Tools in Internet Explorer, I could see that my script file containing the jQuery was generating an error on line 1 with the error $ is not defined. Being that I’m just about good enough to write and tweak the jQuery for my needs, I had to resort to searching online to find the solution so I thought I would post it here in the hope that I help some other WordPress administrator out there struggling with the same issue.

The problem arises not because of a problem with jQuery but a nuance with WordPress and how it implements jQuery. With a normal site under normal conditions, you load the jQuery library to allow you to invoke jQuery on the site and in doing so, jQuery assign itself the $ symbol as a variable used for invoking jQuery. jQuery includes an optional mode called noConflict which helps to prevent conflicts with other libraries and extensions that may also use the dollar symbol as a variable. WordPress implements jQuery in no conflict mode and as a result, the dollar symbol is not available and instead, we have to invoke jQuery using the jQuery named variable.

When writing jQuery scripts for use on a WordPress site, we need to replace all instances of the dollar symbol with the jQuery notation. Below is an example line from the script I first wrote for the disappearing menu bar script referencing jQuery using the dollar symbol which causes the $ is not defined error.

$(window).scroll(function(event){
    didScroll = true;
});

To make the script function properly on the WordPress site, I had to modify this section of code to replace $ with jQuery as shown below.

jQuery(window).scroll(function(event){
    didScroll = true;
});

After changing this and all the remaining references in the script and saving it back to the site, the Developer Tools ceased to report the error and the script started to function as expected.

Repairing a Damaged SQL Azure Sync Group

As a follow-up to my TechNet Guide published previously on Configuring a Windows Azure SQL Sync Group, in this post, I will explain how to repair a broken sync group.

Firstly, let me explain how I broke it. I have two SQL Azure databases in sync: one database in the North Europe region and another in the West Europe region. Following some security advice for WordPress, I decided I wanted to change the table prefixes for my database from the defaults of wp_. I made all of the required change to the config.php file, on the database tables and all the other changes required as per the article guide I used at http://wpcanada.ca/2009/how-to-change-wordpress-table-prefix/. After doing this, I couldn’t do anything to the blog: edit posts, author new posts, delete posts. I busted out SQL Server Management Studio to manually delete the post I was trying to clear out and I got an error message that there was a problem with the trigger.

I’m not a SQL expert so I hadn’t encountered triggers before but I could tell from the trigger name, wp_posts_dss_delete_trigger what this was. The trigger was based on the old wp_ table prefixes and now my prefixes are different. I logged into Windows Azure Management console and tried to update the database schema through the Sync Group configuration which succeeded but nothing was working still.

After much T-SQL research and experimentation, I got the fix.

Backup Everything

I can’t stress this point enough which is why it is in red, a colour which I normally try to avoid at all costs.

If you chose to follow this post to help recover a broken SQL Azure Sync Group and a potentially broken application trying to use that database, please make sure you back everything up. The changes we will make to the database in the following steps have the potential to ruin your day if done improperly and I can’t be responsible for any data loss as a result.

The easiest way to backup a SQL Azure database is from the Windows Azure Management portal which allows you to generate a .bacpac file which is an export of the entire database schema and table contents. This .bacpac file will be written to a Windows Azure Storage BLOB Container of your choice.

Clear and Delete the Sync Group

Firstly, you need to clear out the Sync Group. Full instructions for this are on Windows Azure MSDN at http://msdn.microsoft.com/en-us/library/windowsazure/jj991914.aspx but in a nutshell, remove any reference databases from the Sync Group first, leaving only the Hub database. Once this is done, delete the Sync Group, leaving you with standalone, non-communicative databases.

Next, login to your SQL Azure database using either the Windows Azure SQL Management console or via SQL Server Management Studio from your own machine. You should be connecting to the database which was formerly the Hub database as this is our primary and the one which needs rescuing. We’ll deal with the Reference databases at the end of the process.

Drop the Sync Group Database Tables

View the tables in the database and you should see a number of tables which have the prefix DataSync instead of the usual dbo. There are four tables as standard for all databases which have the following names:

  • DataSync.provision_marker_dss
  • DataSync.schema_info_dss
  • DataSync.scope_config_dss
  • DataSync.scope_info_dss

There will also be other DataSync tables which match you existing pre-change table names. Drop all of the DataSync tables. The T-SQL query for this is as follows:

DROP TABLE DataSync.provision_marker_dss
DROP TABLE DataSync.schema_info_dss
DROP TABLE DataSync.scope_config_dss
DROP TABLE DataSync.scope_info_dss

Repeat this process for your custom name DataSync tables. In my case these were WordPress table names such as DataSync.wp_posts_dss_tracking.

Drop the Sync Group Triggers

This was the hardest part for me to find information on and complete. With all of the tables dropped, we’re halfway there but the triggers are the actual problem not the tables. Each table has three associated triggers for INSERT, UPDATE and DELETE actions. The triggers are what tells the Sync Group that the Hub database has a change that needs to be replicated to other copies of the database.

First, we need to find all of your triggers. The following code is courtesy of Joe Stefanelli on Stack Overflow athttp://stackoverflow.com/questions/4305691/need-to-list-all-triggers-in-sql-server-database-with-table-name-and-tables-sch.

SELECT sysobjects.name AS trigger_name 
    ,USER_NAME(sysobjects.uid) AS trigger_owner 
    ,s.name AS table_schema 
    ,OBJECT_NAME(parent_obj) AS table_name 
    ,OBJECTPROPERTY( id, 'ExecIsUpdateTrigger') AS isupdate 
    ,OBJECTPROPERTY( id, 'ExecIsDeleteTrigger') AS isdelete 
    ,OBJECTPROPERTY( id, 'ExecIsInsertTrigger') AS isinsert 
    ,OBJECTPROPERTY( id, 'ExecIsAfterTrigger') AS isafter 
    ,OBJECTPROPERTY( id, 'ExecIsInsteadOfTrigger') AS isinsteadof 
    ,OBJECTPROPERTY(id, 'ExecIsTriggerDisabled') AS [disabled] 
FROM sysobjects 

INNER JOIN sysusers ON sysobjects.uid = sysusers.uid 

INNER JOIN sys.tables t ON sysobjects.parent_obj = t.object_id 

INNER JOIN sys.schemas s ON t.schema_id = s.schema_id 

WHERE sysobjects.type = 'TR'

This will output a query result with a list of all of the triggers on the database, the trigger name and the table for which it is registered. Right click the trigger_name header in the query result and select the Copy option. Open a New Query window and paste the output into the query window which now gives you a list of all of the triggers. On the first line, prepend the syntax DROP TRIGGER to the line then copy the DROP TRIGGER syntax down onto the start of each line.

For me, this gave me the following query ready to execute (for WordPress remember):

DROP TRIGGER wp_term_taxonomy_dss_insert_trigger
DROP TRIGGER wp_term_taxonomy_dss_update_trigger
DROP TRIGGER wp_term_taxonomy_dss_delete_trigger
DROP TRIGGER wp_commentmeta_dss_insert_trigger
DROP TRIGGER wp_commentmeta_dss_update_trigger
DROP TRIGGER wp_commentmeta_dss_delete_trigger
DROP TRIGGER wp_terms_dss_insert_trigger
DROP TRIGGER wp_terms_dss_update_trigger
DROP TRIGGER wp_terms_dss_delete_trigger
DROP TRIGGER wp_comments_dss_insert_trigger
DROP TRIGGER wp_comments_dss_update_trigger
DROP TRIGGER wp_comments_dss_delete_trigger
DROP TRIGGER wp_usermeta_dss_insert_trigger
DROP TRIGGER wp_usermeta_dss_update_trigger
DROP TRIGGER wp_usermeta_dss_delete_trigger
DROP TRIGGER wp_links_dss_insert_trigger
DROP TRIGGER wp_links_dss_update_trigger
DROP TRIGGER wp_links_dss_delete_trigger
DROP TRIGGER wp_users_dss_insert_trigger
DROP TRIGGER wp_users_dss_update_trigger
DROP TRIGGER wp_users_dss_delete_trigger
DROP TRIGGER wp_options_dss_insert_trigger
DROP TRIGGER wp_options_dss_update_trigger
DROP TRIGGER wp_options_dss_delete_trigger
DROP TRIGGER wp_postmeta_dss_insert_trigger
DROP TRIGGER wp_postmeta_dss_update_trigger
DROP TRIGGER wp_postmeta_dss_delete_trigger
DROP TRIGGER wp_posts_dss_insert_trigger
DROP TRIGGER wp_posts_dss_update_trigger
DROP TRIGGER wp_posts_dss_delete_trigger
DROP TRIGGER wp_term_relationships_dss_insert_trigger
DROP TRIGGER wp_term_relationships_dss_update_trigger
DROP TRIGGER wp_term_relationships_dss_delete_trigger

Ensuring that your query is pointed at the correct database if you are using the SQL Server Management Studio, now press the Execute button to execute the query. You should get the response Command(s) completed successfully.

Testing the Database

With this done, the triggers are now history which should bring your database back to life. Either use your application which drives the database or if you are comfortable doing so, try some INSERT or UPDATE queries against the database to verify this. If you get any errors it means you either missed a table or a trigger during the drop phases. If your database works then congratulations, your application is no longer a brick but we now need to restore the Sync Group functionality.

Delete the Reference Database(s) (Optional)

This step is optional but I did it for cleanliness. As we’ve basically just completely doctored with the schema and operation of a database, I didn’t like the idea that my Reference replica of the database was in an even worse state. I elected to delete the Reference database and create a new database in it’s place. You can either delete the database from the Windows Azure Management portal or from SQL Server Management Studio while connected to the SQL Server.

Please make sure you delete the Reference Database and not the Hub database if you do this though as if you delete the Hub by accident then you’ve just deleted the database which we spent the time fixing up.

Recreate the Sync Group

Recreating the Sync Group to get you back in business for resilient SQL Azure databases services means following the steps in my previous post Configuring SQL Azure Sync Groups. The only thing which you need to account for is the fact that your SQL Servers already exist and your Hub database already exists. Assuming you performed the optional step above to delete the Reference databases, you’ll need to do the following:

  1. Create new Reference databases.
  2. Create a new Sync Group.
  3. Configure the Hub and Reference partnership for the Sync Group.
  4. Scan the database schema and select the options to Sync.
  5. Enable automatic time based sync (if you are using this mode).

The previous post has the full details and screenshots should you need it for referral.

Hopefully you’re all back in business now and this post has helped you get out of a hole. The lesson I learnt here is that if you are making major changes to a database which is configured in a SQL Azure Sync Group then consider removing the databases from the Sync Group and deleting the Sync Group first then, once all your changes to the schema and table names are complete, then you can re-create the Sync Group and get your resiliency back on.

WordPress Database Index with SQL Azure

As part of a moving my online services between two Windows Azure subscriptions last week, I did some upgrades to the blog including moving the database to Windows Azure SQL (SQL Azure). To facilitate this, I’m using the WP DB Abstraction plugin for WordPress available from http://wordpress.org/plugins/wordpress-database-abstraction/. Using this plugin does take a bit of guts I hasten to add as it hasn’t been updated in over two years and it will prevent some plugins from functioning but for core WordPress it’s great.

After migrating the site to the new subscription I was doing some validation checking in the SQL Azure Management portal. I was querying the database for various things and I noticed that there were no indexes on any of the tables, a byproduct of the WP DB Abstraction plugin translating the native WordPress MySQL syntax into MSSQL I suspect. Luckily for me, WordPress have a great in-depth article on their Codex for the database schema, mappings for all of the primary and foreign keys and most importantly, all of the indexes.

Using the SQL Azure Management Designer, I was able to create the indexes in SQL Azure to match the WordPress MySQL specification. If you are using WP DB Abstraction for your Widows Azure Web Sites WordPress installation with SQL Azure, I strongly recommend you take a look at your own indexes to see if any exist and if not, look at all of the details on the WordPress Codex article at http://codex.wordpress.org/Database_Description for what indexes should exist.

If I get a chance in the coming days, I’ll update this post with a T-SQL snippet which you can dump into SQL Server Management Studio to create the indexes for you.

Google Sitemaps XML Plugin on Windows Azure

On the blog here, I use the great Google Sitemaps XML plugin for WordPress by Arne Brachold (available from his site at http://www.arnebrachhold.de/projects/wordpress-plugins/google-xml-sitemaps-generator/) to automatically generate my sitemaps. Since moving to Windows Azure for my hosting I’d been having a problem with it automatically building the file on site changes. The fix was actually really simple but I completely overlooked it initially.

First off, this plugin is great for two reasons and credit to the author. It’s really customizable allowing you to configure what is included in the sitemap and what is not such as categories, tags, archives, search page and you can even specify individual post IDs. This is all so that you can match your sitemap.xml to your robots.txt configuration to help Google and Bing (and yourself for SEO) but more importantly longer term because it automatically rebuilds and notifies Google and Bing when it is updated by means of new or updated posts being published. As a blogger, all I have to worry about is finding the time amongst work and life to think of something awesome to post and for you all to read.

It goes without saying that Windows Azure web instances are running on IIS and in counter, the plugin is designed primarily for Apache installations. The reason I hadn’t thought of this previous before now is that my last host was running IIS too and I had no problems with it there.

Google Sitemaps XML Plugin Path

Head over to the settings panel for the XML-Sitemaps plugin in your WordPress admin site and scroll down to the area titled Location of your Sitemap File. The installation tries to select an automatic location from the web server paths. Credit to it, it got the paths right, but the direction of the slashes wrong and it turns out that this was the problem.

Change the setting to Custom Location and simply replace all of the forward slashes in the path with backslashes. Hit the Update Options button at the bottom and you’re done. I submitted a very short hello world post after the change to test it and once published, go to the XML-Sitemaps panel and I was given a message to show that the sitemap will be rebuilt in 10 seconds and sure enough after 10 seconds, it rebuilt and notified Google and Bing as designed of the changes.

Making the Blog Better and Faster

After moving the blog to Azure, I was really happy with the performance, but I decided this weekend I wanted more so I set off on a personal mission to improve to make the blog better and faster. This post is a quick update on the changes I’ve made to the site to get it to where it is now.

So What Have I Done?

Lots of people recommend YSlow as a Firefox plugin for assessing website performance. I use the Internet Explorer Developer Tools normally for my needs, but YSlow outputs nice reports which tells you what you need to do to get results where as unfortunately, the developer tools only tell you what you’ve got currently.

CSS Removal and Compressing

YSlow identified a number of issues with the site which I’ve worked on resolving to varying degrees. Firstly, it wasn’t happy with the number of CSS stylesheets I referenced due to the theme colour switcher. As I figured this was a gimmick added at the time and nobody would actually really use this, I’ve removed it which allowed me to drop 19 stylesheets from the HEAD section of the site.

Once I’ve removed these stylesheets, I used a plugin called Dust-Me which scans the site and finds unused CSS styles in the stylesheets. When a stylesheet is only 2KB, ever little helps. Dust-Me found about 10 styles across my CSS which I was able to remove and marginally reduce the filesize.

Compressing happened by using a great website, CSS Drive. Their CSS Compressor tool. You copy and paste your CSS into their site and it outputs a shrunken version of it with a large chunk of whitespace removed and where possible is reduces the length of colour codes and converts your CSS into shorthand. Doing that saved me about 20% on the size of my stylesheets, dropping the colour specific sheets from 856 bytes to 777 bytes and dropping the main stylesheet from 6,686 bytes to 5,636 bytes.

Whilst this may not sound like a lot, the smaller the page, the faster it appears to the user and the less load it also puts on the server delivering the page so it’s a double win.

Image Resizing

All of the images on the site which make up the page layout I have designed with high DPI users in mind. This means that users who are operating their displays at 125% or 150% aren’t penalized for doing so and get the same high resolution images and people set to 100%. I realized this weekend that my images where actually scaled to about 225% which is way bigger than high DPI users need so I’ve resized all of the images which make up the standard site page. This has had a big impact on the page weight for the site as a whole. The images which have been updated include all of the logos in the header section on the tiles and all of the images in the sidebar for the navigation.

Page Bloat Removal

I’ve never been 100% happy with my pages on the blog. I do what I can to tweak it when I have time and this weekend, I had time. I’ve made a whole load of changes to the site which will work to improve it’s usability, some of which I’ll list below.

  • Updated page TITLE attribute to include the post title.
  • Removed a JavaScript and some CSS references from the page HEAD to speed things up.
  • Removed the messy looking pagination links at the bottom of singular post pages.
  • Removed a load of bloat and fluff from my about me personal page.
  • Used a WordPress function to HTTP 301 redirect the author archives to my about me page as there isn’t any point in having author archives on a single author website.
  • Added a plugin to manage my sitemap.xml file for Google and Bing search indexing.
  • Created myself a Google+ account and setup author verification for the site so that Google can show my face against results from this blog.

New Picture Time

I figured this weekend that I’d been using the same boring head and shoulders shot of myself for my social presence for nearly eighteen months now and I wanted a change. I’ve got myself a nice new image for all of my social sites. The picture was taken on our holiday to Spain in 2011. With me always being the person taking the pictures in our family, it’s rare find a picture of me and even rarer to find one that I like. With a little bit of Adobe Lightroom magic, what was a wide angle shot including me and some flowers because a lovely little super-crop of me and the flowers with an Instragram-esque vignette and black and white filter to finish the look.

The Results

When I started the journey of updates this weekend, the page weight for the site was about 210KB which was pulled together by nearly ~75 HTTP requests. After all of the work this weekend, the page weight is now down to 140KB (50KB per page saving) and the number of HTTP requests is down to 25 (~50 per page saving). Yes, all of this has taken me quite some time to achieve over this weekend, but the results are really worthwhile and goes to show that even a well performing website has room for improvement.

My current Pingdom score is 88 and my current YSlow small website/blog score is grade B (86). If I change YSlow to the YSlow 2 test pattern then my score drops to grade C (74) but that’s still a pretty good score in my view. I think I could probably get my score up to 90 for the small website/blog category with a little bit more effort in the coming weeks.

On my radar for future changes and updates to the blog are going to be going back through my historical posts and updating them all to use the Azure BLOB Storage for the image hosting and correctly some of the ASCII character errors which where caused by using Windows Live Writer to upload my posts on a previous iteration of the site which didn’t have the UTF-8 encoding set properly.

Setting Up Shop in Windows Azure

Several months ago after numerous outages with my old American web host, I moved some of my sites over to a UK hosting company. For this reason and that reason, I didn’t complete the migration of all of my sites over to the UK host and the time is upon me that the agreement with the old American host is up for renewal in a couple of weeks.

After some persuasion, I’ve managed to convince a the other half that some of the sites could be dropped as they just weren’t used anymore – Just one site left to sort and that’s in the hands of a friend to arrange.

This left me in a position where I only had one site of my own left, this blog. When I was first reviewing options for moving to a new host, I looked at Windows Azure. I’m working with Azure heavily in a project at work so I was comfortable with the environment enough to want to deploy a multi-language enterprise site there so why not my own sites? Well at the time, cost was an issue. To run all of my sites in Windows Azure Web Sites Shared mode would have cost about three times as much as the hosting agreement elsewhere. This is down to the fact that in Windows Azure to use a custom domain name you need to be on either the Shared or Standard tier; the Free service tier limits you to using *.azurewebsites.net addresses.

So with just one site left my thoughts returned to Azure. I did some sums and it looked like it was going to cost about the same for Windows Azure as it was going to, to renew the UK plans but on a way more solid platform which tonnes more features, scalability and support. Not to mention that Windows Azure services outperform those of its competitors up to 3x if you believe the hype (I do for the record). I’m hedging my bets actually on my costs being lower. The Windows Azure Pricing Calculator puts a Shared Web Site at £6.16 per month but that’s based on 684 hours (28 days @ 24 hours per day) of compute time as Windows Azure now calculates billing based on hours of compute time. As my blog isn’t visited that heavily and I’m using the amazing WP Super Cache plugin for WordPress, I think I can do it for about half of this actually but month one will tell – I’ve always got the bug out option with Azure as I’m on pay as you go monthly with no upfront commitment.

So after migrating the MySQL database in the ClearDB free 20MB database service which fits perfectly for my MySQL WordPress instance database at a wee 9MB and after copying over all my files and doing some WordPress PHP magic to move some of the URLs I had it working. Makes you realise how quickly WordPress moves though! I was already two versions behind the latest and all of my plugins were out of date so first job was to fix those which I did in quick order.

Custom Domain registration is a simple case of configuring a few CNAME records and updating my domain root A record and done. My registrar FastHosts have a great interface for updating DNS and they use a 1 hour TTL which means that the updates happen really quick although one thing I think Microsoft are doing actually is that they are performing live queries each time and not relying on cached DNS entries and potentially long TTL times. I updated my A record and Azure knew about it within about a minute of the change.

So surely I did more than just move host and upgrade? Damn right I did 🙂

I’ve finally fixed the Twitter hook on the blog which means my latest tweet is now actually shown. This was fixed by replacing the Twitter plugin I am using with one which actually works with the new Twitter oAuth developer framework. I’m now using Advanced Twitter Feed Integration if anyone else out there is looking for a Twitter plugin that works. I’ve removed the old jQuery Lightbox plugin as the new version of WordPress has improved this functionality so renders it pointless. In a more functional space, I’ve fixed the CSS which was causing issues with the collapsible navigation from working properly so you’ll now actually be able to read the text as well as see the pretty Windows Phone inspired plus and minus buttons. I’ve also updated my permalink structure to drop the year/month/day element. My URLs are now simply the domain plus the post name. Much cleaner and the chances of me wanting to recycle a post name are slim to zero so it shouldn’t come back to haunt me.

The coolest thing I’ve setup is the Windows Azure Storage for WordPress plugin. I’m not sure what my mileage with this but I’ll give it a month or two and see – purely a cost factor though, not functional.

This plugin connects to a Windows Azure Storage Account and stores content that you upload to the blog into Windows Azure Storage BLOBs instead of directly into the Web Site instance. This is good news in theory because it offloads transactional tasks and storage from the web instance giving me the potential to reduce my compute time on the web instance and it also allows me to use the Azure CDN feature for even more massively improved performance if I wish (although the performance is pretty awesome already). Configuration of the plugin is super simple thanks to the fact that the plugin is actually written by Microsoft and once connected to the Storage Account Container and enabled, anything you upload either in the web interface as media or via a third-party editor like pictures, videos or other post content get’s stored out in the Storage Account Container. Simples.

No Further Questions

I took the decision today to globally disable comments on the site. I’ve been getting in the region of 250 spam comments daily and I’ve had about 5 actual, real person comments in just as many months. To have the Akismet plugin for WordPress running to filter and manage all of these spam messages adds overhead to the blog and overhead for me to moderate those comments and it just isn’t worth it for the number of comments I receive.

To those of you who do want to contact me, please use the contact page on the site which has all of my social interaction addresses and handles listed.

I just want to stress that I’ve taken this decision not because I don’t want to hear from people about my thoughts and topics of conversation, but just because there isn’t enough real people interested in my material to warrant dealing with the spam.

I hope you understand?

I Need More Power Captain

So, anyone who frequents my blog may have noticed a performance improvement in the last two days. The reason? I’ve moved house, or at least my blog has.

Previously hosted by a US company called ASPHostCentral, I had been having a lot of issues with MySQL of late where the blog couldn’t even connect to the instance. Several support tickets were raised for the issue and every time they resolved the issue, but never fixed the root cause which they claimed was a customer on the same shared server as me hammering the database engine. When the blog could connect to the MySQL database, I was seeing round-trip ping responses to the server of over 175ms at all times, with it sometimes peaking to 250ms. I setup a free website monitoring tool (http://www.uptimerobot.com/) to monitor the blog and a few other sites I own. I was receiving upwards of 10 alerts a day per site to say that they were offline for a few minutes and then back up again.

I haven’t fully completed the move as I have a forum site I run with a large database I need to migrate, but the blog and a few other mini-sites are moved over but so far it’s great. The blog is now hosted by HostingUK.net, a British company with datacentres based in the London area so the geography is much better for me and my primary user base. The new server is running Windows Server 2012 which means I get some of the newer features in IIS 8 for running the site not to mention a sub 20ms ping response from my home. If anyone is wondering, the reason I used the US to host the sites previously is that UK based web hosting hasn’t really been able to compete with the US companies until recently and being that this is all paid and run by me personally, I need to keep it cheap.

I’m going to be doing some performance tweaking of the blog soon, playing with caching plugins for WordPress, maybe even tweaking my theme to try and optimize some of the images to try and make the site fly, but I’m really happy with the new service I’m receiving so far, it’s faster and seems more dependable, I can get support in my time zone and the couple of questions I’ve had for their support people have been answers by certified IT Pro’s who actually sound knowledgeable.

Enjoy 🙂

WordPress Upgrade and Hosting Woes

So after typing the Surface Pro article earlier today, I realised that all of my WordPress plugins and my WordPress were out of date. After about an hour of tinkering with plugin versions, authorizing Twitter OAuth plugins and upgrading the main install.

So what’s new? Well the media manager in the admin interface is very nice and welcoming over previous iterations. Internet Explorer 10 still doesn’t get recognized as a modern browser still as logging into the admin interface produces an error that looks like it thinks I’m running IE6 – Something I as hoping would be fixed. Looking at the categories in the admin interface makes me a little sad too because my categories are all over the place so I think I need to spent a few hours aligning and rearranging them, and I also noticed a few quirks with my custom theme which I need to resolve.

Every time I upgrade my WordPress instance though, it reminds me how junk my current hosting provider are. I was only able to get between 10-20Kbps transferring files to and from the FTP site. A ping to the site results in a round-trip time of 165ms and the load times are terrible not to mention the HTTP500 errors I’ve been getting on a couple of my other sites recently because of some new user on the shared server pillaging the MySQL instance.

Normally, I forget about the issue by the time I get round to sorting it, but I’m determined to remember this time especially as my hosting is up for renewal soon, so I’m going to be finding a new home in the UK as UK hosting prices have dropped in recent years. I did take a look at Microsoft Azure earlier today, but the free instance doesn’t allow the use of custom domain names and the shared instance works out at about $45 a month for my sites which is too much.

If anyone knows a good UK hosting provider for £15 or less a month then please feel free to drop me a line.

WordPress Development – functions.php

As I travel down the road of WordPress theme development, I have discovered many things.

A problem that has been hurting me for the last week at least as I develop the new theme is errors I would occasionally receive, which would read Cannot modify header information – headers already sent. For me as a non-programmer, this didn’t really mean an awful lot, and trawling the WordPress support forum didn’t help me hugely as I didn’t understand some of the lingo being used.

I had a starting point, which was my functions.php file. This filename was referenced in the errors, with a line number however upon inspection of that line, I couldn’t see a fault, so I looked elsewhere.

This evening, I compared my functions.php file to that of the TwentyTen theme which ships with WordPress 3.1, and I noticed something interesting. My functions.php file used multiple PHP statements opened and closed as needed, however the TwentyTen functions.php file only had a single set of PHP tags, opening at the start of the file and closing at the end, with each of the functions contained within it.

When I looked back at my file, I saw that the line indicating the error was in fact a closing PHP tag.

This post is more to serve as reference for other newbies out there trying to develop your first WordPress theme. Make sure that your functions.php file is a single PHP statement from start to finish with no leading or trailing line breaks or spaces. For me, this problem caused PHP errors when trying to modify Widgets in the admin interface, configure Plugins, manage the Theme settings and also stopped RSS and XMLRPC from working, so it’s a pretty big issue.