Tuesday 30 June 2015

Enable gzip compression with GoDaddy Linux Hosting (Apache)

GoDaddy’s documentation claims to have mod_Deflate installed by default on all but its Classic Hosting accounts but any basic HTTP sniffer (YSlow or Fiddler) suggests text-based resources like Javascript, CSS, XML, etc aren’t being compressed. Google’s Web Master Tools will likely flag this to you as well and you can use an online tool like redbot.org to inspect your headers.

If you’re not seeing a header like this one, your content is likely not being encoded:

Content-Encoding: gzip
To enable compression on one of the site’s I’m working on, I added this line to the bottom of the .htaccess file at the root of my site:
AddOutputFilterByType DEFLATE text/text text/html 
text/plain text/xml text/css application/x-javascript 
application/javascript
Bear in mind compression is only one aspect of a performant site. Among other things, you’ll also want to ensure your content is cacheable for a suitable length of time. Consider combining and minifying your CSS and Javascript and use a free content delivery network (CDN) like CloudFlare to accelerate the local delivery of your image assets.

If you’re really keen (or suffering performance problems) consider using image sprites to reduce the number of resources a page needs to download and move away from server-side code where you can. The vast majority of your page content is likely static (even if it’s being generated dynamically—but isn’t personalised) and should be cacheable at the browser level.

Tuesday 23 June 2015

How to increase the size of the shopping cart icon in WooCommerce

I found the default size of the WooCommerce shopping cart icon (in the Storefront theme) was a bit on the small size.

The icon is textual and comes from Font Awesome. Normally, this would be an easy change by adding fa-2x or something similar to the style declaration. Inspecting the CSS in Chrome didn’t offer me such an option (I’m new to Font Awesome) so I added this CSS to the custom CSS in my Storefront child theme:

/* Increase size of shopping cart icon */
    .site-header-cart .cart-contents:after
    {
        font-size: 1.25em !important;
    }
The 1.25em increased the size of the cart icon to better reflect the size of the menu text and stand out better.

Woocommerce Shopping Cart Icon

Tuesday 9 June 2015

WooCommerce tax not displaying ($0)

Had an annoying little problem with taxes not showing in WooCommerce recently. Despite my best efforts to configure the Tax pages correctly, all I was getting was $0 for taxes. I had specified an address in the checkout but the tax amount would consistently come back as $0. This was on two separate, new installs of Wordpress v4.2.4 + WooCommerce v2.3.10 and I had no other tax plugins installed.

Thankfully, a response to my post to the Wordpress support forums got me back on track. It was suggested I may be missing the wp_woocommerce_tax_rate_locations table in the database, and sure enough, upon inspection I had no such table.

I created the table using the following SQL from another post describing an identical problem:

CREATE TABLE wp_woocommerce_tax_rate_locations (
location_id bigint(20) NOT NULL,
location_code varchar(255) NOT NULL,
tax_rate_id bigint(20) NOT NULL,
location_type varchar(40) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Next, I clicked Save on the WooCommerce/Settings/Tax/Tax Options screen before taxes would show.

Thanks lorro! Read the full thread here: https://wordpress.org/support/topic/tax-displays-as-0

Sunday 7 June 2015

How to set a product as a featured product in WooCommerce

If you want to mark a product as “featured” in WooCommerce (so it will display in the Featured Products widget, for example), you’ll soon find it’s nearly impossible to figure out how to do so.

There are two ways to set a product as a featured product in your WordPress admin screen:

  1. From the products list
  2. From the edit product page

Products List

Most forum posts, etc will suggest you can toggle a product as featured or not featured in the Products list by clicking the empty or filled star icon for each product. This is easy enough—especially for setting multiple products quickly—but requires you to drop out of the product edit page.

Featured Product Star

Edit Product Page

If you’re setting up a new product you may want to set it as a featured product from within the edit product page. To do so, expand (edit)  the Catalog visibility: section in the Publish widget. The last option is a checkbox to flag the product as a featured product.

Expand Catalog VisibilityFeaured Product Checkbox

You may also want to read the Adding and managing products documentation from WooThemes for more information.

Wednesday 3 June 2015

Can’t access Wordpress wp-admin after changing the site URL

I’m in the process of pointing a domain root to a Wordpress install that resides in a /wordpress folder below the root. I’m following these instructions—or rather trying to!

I first modified the Site address (URL) from https://store.mydomain.com to https://store/mydomain.com/wordpress, moved (instead of copying) the /wordpress/.htaccess and index.php files to the root, cleaned up those files how they should have been in the first place (!), and then promptly lost access to wp-admin.

I backed up the site content before starting all of this but, naturally, elected not to back up the Wordpress database. Which was a bit silly.

Fortunately, I was able to roll back to the start—without access to wp-admin, by modifying the value of the siteurl row in the wp_options table (in the MySQL database via phpMyAdmin).

This article also has some great options to get you up and running again without modifying the database: http://codex.wordpress.org/Changing_The_Site_URL

Saturday 30 May 2015

Wordpress SSL causes 404 for images

After installing first a self-signed SSL certificate (replaced with a free Comodo SSL certificate in order to troubleshoot this problem) I installed Wordpress and started building a WooCommerce-based store. Because I'd installed Wordpress on the https:// site, the Settings > General screen automatically configured the site address as https://

All was going well apart from a niggling problem with images not displaying on the site itself (anonymously) or logged into the WP dashboard. Inspecting the image HTML in Chrome allowed me to extract the full problem URL and I found I could load the image successfully in its own window. Chrome also allowed flagged the 404 response for images when loaded through the Wordpress page. Weird.

Apart from images I uploaded to the Media library, other images being served locally from my Wordpress installation (e.g. theme thumbnails) were also failing to load.

I found that by changing the site address (again in WP > Settings > General) to http:// (not https://) the images would display so I came to believe the problem was somehow related to SSL. Interestingly, after changing this setting, the images appeared when I browsed to either the http:// or https:// site. Images on the http:// site using absolute image references to the https:// site also worked.

After a bit of head scratching and a bit of searching around (this problem doesn't seem to be particularly common), I came across this page which suggests hotlink protection can cause problems for the SSL protocol. Apparently "HTTPS is configured correctly when resources that are available via HTTP are also available via HTTPS." As far I could tell, my images were available through both HTTP and HTTPS but I had enabled hotlink protection on the site before installing Wordpress.

Sure enough, disabling hotlink protection solved the problem.


Thursday 28 May 2015

Windows Live Writer and Blogger returned the following error: Notfound: not found

Ah Windows Live Writer--you've been there all along and now you're not working because Google ended support for ClientLogin OAuth 1 (3LO), AuthSub, and OpenID2. Great for Google, no doubt, not so great for the thousands of users still clinging to WLW.

Microsoft insiders (Scott Hanselman) are talking about open sourcing Windows Live Writer, which would be great as the application hasn't seen any major updates since the 2012 product release. Hanselman has also suggested a fix may be a while off--in the hands of the open source community. 

Apparently Google is also considering a fix at their end, which would be great to keep us bloggers running in the meantime: https://plus.google.com/u/0/+RickDoyle/posts/GUPJcu5sZHo

Update: a few workarounds have popped up around the web:
  1. View source in WLW and copy/paste into Blogger (web). See http://mybeerbuzz.blogspot.com.au/2015/05/blogger-windows-live-writer-blogger.html
  2. Configure posting by email. See http://www.hackinguniversity.in/2015/05/live-writer-not-found-error.html
Update 2 (3 June 2015): seems to be working again as expected :-)

If you found this post helpful, please support my advertisers.

Tuesday 31 March 2015

How to recreate a windows folder and file structure with empty (zero byte) files

I have an external drive full content that I reference only periodically. I don’t connect the drive regularly to my laptop but I often want to know if a file is on that drive. I recently thought it would be helpful to have a zero-byte copy of the drive contents on my local machine.

Although I thought about writing a PowerShell script to accomplish this, robocopy includes a feature to do exactly what I want through the /Create command:

robocopy source dest /E /Create

Robocopy has been bundled with Windows since Vista.

Sunday 15 March 2015

Infix PDF Editor Pro Review

I may have finally found a fully-featured desktop PDF editor that won’t blow the budget (hence this review: Iceni Technology offer a free license for promoting the Infix product). I’m referring to Infix PDF Editor from Iceni Technology.

In the last few years I’ve committed to reducing the volume of physical paper in my house and to that end, I’m scanning existing documents to PDF. As my multifunction device only scans single-sided, I have a need to merge PDFs and reorder pages, at a minimum. On occasion I’ve also had a need to edit the PDF content—the text within the PDF.

To date, I’ve used a hybrid  solution for manipulating PDFs including the CutePDF Writer to print documents from other applications to PDF and the free, online CutePDF Editor for manipulating and combining PDFs. Although the Cute printer is great, the Editor product is painfully slow, especially when reordering pages and joining PDFs. Plus, I’m not terribly comfortable uploading sensitive (private) PDF documents to an unknown web server.

The obvious benchmark for PDF editing is Adobe’s Acrobat and I installed a trial version of the Acrobat XI product. It worked amazingly but the price tag is also amazing—over $400.

Finally, I’ve integrated third-party PDF solutions into my web applications in the past, notably WebSupergoo’s ABCpdf.NET product. I was literally just about to write my own PDF editor using their product when they pointed me to Infix.

I’ve previously searched high and low for free PDF editors (open source or otherwise) but found very few products that meet my primary requirements:

  • Desktop-based for performance and security reasons
  • The ability to merge PDF documents
  • The ability to reorder PDF documents (preferably graphically)
  • No watermark
  • No dodgy adware or crapware

Most of the merge and reordering features I require aren’t available in freebie products. The closest thing I’ve found previously was a product called PDFill, which works but is really only a basic Windows application with a fairly painful UI.

Enter Infix Pro (v6.36). The Professional pricing is $159, I see and the evaluation version will, unfortunately, watermark your files. For promoting the product, however, you’re eligible for a free license.

I’ll reserve final judgement about the watermark until I’ve received my free license but from the evaluation I can see all of the requirements I list above are met.

The application is an .exe install that installed no other programs as far as I can see. No browser extensions or toolbars, no random stuff. I wasn’t prompted to install anything else either. The download was not quite 60MB and the application itself is responsive and fairly intuitive. I’ve read other reviewer’s comments about the toolbars being of the older Windows style (not a ribbon) but the application still works fine and most functions are easy to find and use.

Merging two (or more) documents is easy and I was surprised that by default the program allows me select other file types (as in not PDFs). I tried to join a .tiff to a PDF but this failed, understandably, with an appropriate error message that I was trying to merge a file that isn’t a PDF. I have tried merging other file types.

Reordering is semi-graphical: you can’t drag and drop pages to reorder them but you make a current selection and then reorder through the Document > Pages > Re-order menu. There is no shortcut noted for this operation and right-clicking on the current page itself or the thumbnail offers no option to reorder the page. In short, reordering multiple pages might get a bit painful but at least it’s quicker than the slow, web-based CutePDF Editor I’m used to.

I’ll be giving this product a thorough workout once I can get rid of the watermark but so far it looks like a pretty good bet.

Monday 5 January 2015

Root redirect to www

Something changed in relation to the root redirect I previously had in place and I only just realised (my domain host, Planetdomain, is now owned by Netregistry so I attributed it that change initially but I suspect Google may actually be at fault here). In any case, mediawhole.com was not redirecting automatically to www.mediawhole.com and was coming up with a 404 or something equally boring instead.

I thought I’d need to mess around with DNS records at Netregistry to fix this but in actuality it was a simple as typing “www” into a text box in the Domains section of the Google Apps admin console. Google refers to this as redirecting the naked domain and provide suitable instructions on the process. In my case I didn’t need to configure A records as they were already in place.

The root mediawhole.com domain redirects efficiently, automatically, and as you might expect.

Update: this simple fix stopped working (or perhaps never worked in the first place) and I recently noticed my bare domain was no longer redirecting. Back to Google admin and I followed the instructions to add new A records to the DNS config in Netregistry (specifically, I added four new A records—one for each IP address noted by Google).

The Netregistry UI is awful for this task: Google suggests using @ for the name value but using @ or “.” or anything else in Netregistry didn’t work for me; I ended up leaving the Name field blank and setting only the Host field as the IP address. This created a new record with a “Record name” of mediawhole.com.