Category Archives: Development

Skimlinks is a great way to moneterise a blog. Once signed up and approved you simple need to add a line of JavaScript to your site and it will add moneterised links to your output. However, you may be adding sponsored posts or your own links and may not want Skimlinks to modify the entire, or portion of, the post. Simply open up your theme’s functions.php file and add the following lines…

function skim_suppress( $paras = '', $content = '' ) {
    return '<div class="noskim">'. do_shortcode( $content )  . '</div>';
}
add_shortcode( 'noskim', 'skim_suppress' );

Now simply use the new shortcode of noskim to suppress any post or page content.

For example…

[noskim]This is a line about an iPhone at Dixons. I don’t want any of the text to be linked to by Skimlinks[/noskim]

Skimlinks provide a WordPress plugin that adds the appropriate code to your site. However, you can do this yourself, and improve upon it, by a few further lines added to your functions.php file…

function add_skimlinks_script() {
    echo "<!-- Skimlinks script -->\n";
    echo "<script type=\"text/javascript\" src=\"http://s.skimresources.com/js/xxxx.skimlinks.js\"></script>\n";
    if ( ( !is_single() ) && ( !page() ) ) {
echo "<script>var noskim = 'true';</script>\n";
    }
}
add_action( 'wp_footer', 'add_skimlinks_script' );

This will add the Skimlinks script to your site’s footer – simply replace xxxx with your Skimlinks number. Additionally, this script is designed to only allow Skimlinks to be placed on single posts and pages – you can update this depending on your site’s requirements.

Lastly, you probably don’t want Skimlinks to appear on site parts of your site – e.g. the header, footer and sidebar. To suppress this you’ll need to have a bit more coding knowledge – identify the appropriate DIV that covers each area and add a class of “noskim” to it.

For example, say you have <div class="footer"> that covers the footer area of your site. If you change this to <div class="footer noskim"> then this will prevent any Skimlinks from appearing in the footer.

I’ve been hosting this site with Memset for some time. They’ve provided an excellent, quick and stable service throughout. With a change in emphasis towards providing servers rather than hosting, though, my recent time with them has not been without its strained relationship.

Some time ago my hosting package was done away with to new users and they continued to support existing customers. However, at each turn they’ve attempted to push me towards a virtual server option that I had no interest in. Bandwidth and disk space limitations have caused my costs to spiral yet Memset have put more pressure on me during support. For example, the other day I needed to housekeep some folders from the site that I couldn’t, for one reason or another, access. In the past they’ve been quite happy to do this for me – after all as I’m not in control of it I don’t always have the access I need. This time they warned me that in future they may charge me. Excuse me? They are hosting for me, I have no control over the PHP or Apache installation and the security restrictions. If these restrictions prevent me from removing some files, it’s hardly my problem.

Equally when I kept finding my MySQL database was done on repeated mornings, their solution was again to suggest that I move to a server package where I could control this.

The last straw was when I tried to downgrade my bandwidth requirements. Memset let you add on file size and bandwidth to your package for an additional monthly fee. After some recent caching issues my bandwidth went out of control so I bought some more to get me through one month. Now it’s under control I tried to downgrade to what I had. However, I was helpfully told that I couldn’t and had I thought about a Virtual Server package.

I’ve searched for new hosts in the past but not found any that truly stand out. I’ve tried moving a couple of times but pulled out after finding the new host didn’t offer all the features I wanted in the end. However, after a search yesterday I came across Tsohost. And it was astonishing – glowing reviews and superb value for money.

In the end I purchased their standard hosting package for £34.99 a year. I was paying £15 a month for Memset. This gives me more bandwidth and file space than I had at Memset and with better support – including a helpful customer forum (always useful for looking for problems before you sign up!). They appear knowledgeable and are regularly responding to issues on the forum (as well as writing up articles on how to resolve issues).

The transfer went ahead yesterday – I did it all manually and, yes, I cocked it up. After a stressful evening I got it working. The site is faster than it was at Memset (about 3 times quicker based on home page timings).

And I, for one, welcome our new hosting overlords. I for one expect this won’t be the last time they get a mention on the site – and hopefully always positive.

 Update 19th Jan:

Having some problems, but not the fault of tsohost. The move of my blog from one host to another appears to have unsettled one of the plugins that I’m using and it’s looping, constantly accessing this site and sending my bandwidth use through the roof. I disable the most likely candidates yesterday and that appears to have worked – now it’s a case of narrowing down the culprit. Thankfully (in a weird way) my personal blog is having the same issues so I can cross-check the plugins that I’ve disable here with those that I’m using on that one – it’s now down to 2.

So, I’m into day 11 of this month but my hosting bandwidth (which was only recently doubled) is now at 75% used. What’s going on?

Thankfully, Memset provide cPanel and a host of data analysis tools. As you can see from this graph it’s rocketed since mid-October.

I’d love to say it’s because visitors have gone up as much, but that’s not the case. Looking at the biggest bandwidth hogging files, it’s exactly as normal – in fact nothing in particular is causing it.

What did happen mid-October though is that I started looking and changing the site’s caching. I’d been using PHP Speedy with all options switched on (except for GZIP, which I had in my .htaccess file along with a few other tweaks) but was finding that was breaking Debug Bar and jQuery Lightbox For Native Galleries. You can exclude certain scripts from PHP Speedy but that didn’t seem to fix the problem.

I therefore decided to try an alternative method. After some testing I settled on WP Super Cache (to cache the pages – this improved speed but not bandwidth as the same size results are delivered) and WP Minify (this combines and minifies the scripts – something that PHP Speedy did, but I could get WP Minify to work with the aforementioned Debug Bar and Lightbox scripts). I also retained my .htaccess changes.

And that’s how it’s been since. The site’s very quick BUT it looks like the size of the pages being delivered are horrendous.

The cause? Right now, I have no idea and I’m still tinkering – expect to see some site problems over the next few days as I try and resolve it.

What I’ve immediately done is switch off WP Minify and put PHP Speedy back on. Oddly, it’s working with GZIP switched on – if the .htaccess changes are working, this shouldn’t work. I therefore need to check my .htaccess further. Maybe the changes made to this file by WP Super Cache have affected it.

Certainly something has to be done with some urgency and if I have to I’ll abort all changes and had back to PHP Speedy solely (and break those other scripts). My hunch – GZIP isn’t working. Testing tools indicate otherwise.

I’ll update this post, as it may be of use to other developers. And, of course, if you have any ideas please comment and let me know your thoughts.

Update, 16th November.

Sorted. Although online testing tools reported that GZIP was working, it wasn’t. Activating that has put my bandwidth back to normal…

Through some further testing I’ve settled on using WP Minify rather than PHP Speedy. I’m also using WP Super Cache but note that this doesn’t affect bandwidth, only speed.

This site previously used the font named Droid, which is the open source font used by Android. With last week’s introduction of Android 4, however, they’ve created the Roboto font – this has been designed for HD screens, so is perfect for websites.

You can learn more about the Roboto font from a Google+ post by Matias Duarte, the Director of the Android User Experience.

If you wish to use a non-standard font for your website then there are a number of ways to do this. However, I prefer to use the font-face CSS option. It’s not without its disadvantages, so read up on it before proceeding.

For each font that you wish to add simply add the following code to your CSS…

@font-face {
    font-family: 'DroidSansRegular';
    src: url('DroidSans-webfont.eot');
    src: url('DroidSans-webfont.eot?#iefix') format('embedded-opentype'),
         url('DroidSans-webfont.woff') format('woff'),
         url('DroidSans-webfont.ttf') format('truetype'),
         url('DroidSans-webfont.svg#DroidSansRegular') format('svg');
    font-weight: normal;
    font-style: normal;
}

You’ll need to change the font-family to the name that you wish to give the font. Then there are 5 references to the font files – 4 different types to cover different browser requirements. Again, these will need changing appropriately.

If you wish to use either Droid or Roboto I’ve bundled them up ready for font-face (i.e. with each of the 4 formats that are required).

  • Download Droid - There are 3 versions of the font – standard, bold and mono space.
  • Download Roboto - There are 2 versions of the font – standard and bold.

I was recently asked, as a commercial request, to create a WordPress plugin that would allow users to click a button and copy text the clipboard. It seemed an easy enough thing to do – 2 weeks later, though, and I’ve thrown in the towel.

Using JavaScript to capture contents is the easy bit – adding it to the clipboard is a lot more difficult. IE has a JavaScript command built in, other browsers vary. Unfortunately, other browsers (e.g. Firefox) also restrict this ability for security reasons. This is because the ability to write to the clipboard also comes with the ability to read from it as well – quite why this functionality can’t be detached and restrict just the reading I don’t know.

So, using JavaScript is problematic.

Thankfully I’m not the first to come across this problem and a third party script named ZeroClipboard is available. This uses Flash to update the clipboard, which doesn’t have the same security limitations. Of course if you’re viewing from a device that doesn’t support Flash (cough, splutter, iPad, iPhone, cough) then you’re still out of luck. None-the-less this seemed a perfect solution.

Unfortunately, my limited JavaScript skills failed me – I found the program to be over-complex for what I needed and failed to be able to get it to work.

At this point I found an alternative – ZClip uses ZeroClipboard but is controlled via JQuery (which is built into WordPress) and provide a much easier and friendly method of access.

I was now in a position where I had a working plugin. Until I used Admin Bar. That seemed to affect the positioning of the Flash overlay so you had to click slightly above the “Copy to clipboard” button to get it to work.

The customer, though, didn’t have an issue with this and I could only hope that they didn’t have anything else within their theme or plugins that could affect it in this way (I did try contacting the developer of Zclip but got no response).

What really ended it all though was the limited way of capturing text in zclip, which I hadn’t appreciated earlier on. ZClip can capture in 2 ways – from static fields (e.g. the text between a SPAN) or dynamic (e.g. from a field). The first doesn’t capture any formatting, even paragraph breaks – returning everything as one long line of text. The second did, but by capturing the HTML.

The customer wanted the customer to be able to copy to the clipboard long paragraphs of text – neither offered a neat solution to this.

Then I gave up. One day I may return to it – certainly ZeroClipboard will probably allow me to do what I need it to, but I’ll have to get my head around how to first.

Top
%d bloggers like this: