Log in

< back | 0 - 10 |  

Google Take Down Requests - Tip

24th June 2013 (08:11)

A couple of years back, someone on blogspot decided to copy a 300 of my posts from Workshopshed to an alternative blog called "Works Hopshed", I spotted this thanks to Lorrelle on Wordpress and a tool called copyscape.


I initially posted a request on the blog via a comment asking them to remove the copied pages, after a period of time with no response I decided to take action.

Given both blogs are on Blogger, I lookedthrough the help pages and found their take down request form. This form allows you to list the pages that are infringing and the source pages that they came from along with your details and a brief description.

So the good news is that, this process does work, Google have taken down all of the pages that I've requested.

The bad news is that their form requires you to list each individual url. I initially tried listing just 3 examples and then detailing the problem in the description box. This resulted in those 3 URLs being removed. So that's 3 down only 297 to go. I've collected the rest of the URLs and submitted all of the 2008 posts, so that's another 74 gone leaving just 223 to go.

Migration from Blogger to Wordpress

5th April 2013 (09:44)

As you might be aware from a post a couple of years back, I've a plan to move my Workshopshed blog from blogger to Wordpress. I've created the new site, content, functionality and put in place security and backup systems. I've sourced and redesigned/tested a suitable theme and written some plugins to provide functionality not otherwise available.

I've pretty much done all that is needed to move but there's a last few of things to do before go live:

I've spend a lot of time re-writing the blogger importer. There were some little issues with the importer when I found it back in late 2010 and some people had already done work to fix these so it was intially a case of merging those together. However as I worked with it I found other issues and also wanted to add the feature of image importing, because this is a complex tool and I've only been working on it part time it's taken a long time to complete. It is now in it's final stages with it functionally complete and down to the last few issues. There are a few people helping out with testing this. Bigger blogs are a key problem and there seem to be a couple of cases were images don't get procesed correctly. I also need to re-check my own blog to ensure that all the images get moved. One key thing with this importer is that I want to get it to a point where it's stable and I can hand it over to others to maintain. However I do need to determine if the import is "good enough" for my purposes and if necessary move further development off my critical path.

The announcements are important but I'm not that worried about writing them, it's more of a case of something I need to dedicate some time to. Firstly I'll have a look at some other announcementsand see if I can find some tips online. Then write some stuff about why and what the change is all about.

Currently the site is developed online, this is fine whilst it's not live as it does not matter if I break it. However an independant testing site would be better and I think a VM is the best place to keep that. Again it's just a case of putting the time in to set that up.

Although I've written my checklist for go-live I've not run through it end to end. It would be good to know how long it's going to take to run and also ensure that all of the steps work as intended.

Hopefully there will be something soon telling you about the site move but I've been saying that for the last 6 months....

Wordpress Widget RSS Link Checker

23rd July 2012 (09:56)

The widget that I mentioned in my last post is now a fully fledged plugin.

It works with the links which have RSS feeds associated with them and checks to see if they have got new entries which it then displays in a widget.


Simple wordpress plugin for updating link date

3rd June 2011 (18:09)

As part of another plugin I'm developping I created this test.

The plugin adds a new Meta box on the right of the links form to display the date the field was last modified. There's some code to capture the date that a link is modified. The field already exists in the table so the code ended up very simple.

Suggested changes if you wanted to use this.

1) Wrap the 3 functions into a class
2) Add a function that populates initialise all the data values that are blank when the plugin is activated

Plugin Name: Andys Link Last Edited Meta Box
Plugin URI: #
Description: Updates links to current data/time when edited and then displays that on the edit link admin screen
Version: 0.2
Author: AGC based on the work of Ozh and
Author URI:
// This function tells WP to add a new "meta box"
// N.B. There is no options screens for this plugin

//See http://www.code-styling.de/english/how-to-use-wordpress-metaboxes-at-own-plugins
//    http://planetozh.com/blog/2008/02/wordpress-snippet-add_meta_box/
//    http://wordpress.org/extend/plugins/link-updated/
//    http://codex.wordpress.org/Function_Reference/add_meta_box

function LinksAGC_edit_update($link_ID) {
    global $wpdb;
    $sql = "update wp_links set link_updated = NOW() where link_id = " . $link_ID . ";";

function LinksAGC_add_LastMod_box() {
        'linkmodifieddiv', // id of the <div> we'll add
        'Last Modified', //title
        'LinksAGC_add_last_modfied', // callback function that will echo the box content
        'link', // where to add the box: on "post", "page", or "link" page
        'side'  // location, 'normal', 'advanced', or 'side'

// This function echoes the content of our meta box
function LinksAGC_add_last_modfied($link) {
     if (! empty($link->link_id))
    echo "Last Modified Date: ";
    echo $link->link_updated;
    { echo "New Link";}
// Hook things in, late enough so that add_meta_box() is defined
if (is_admin())
    add_action('admin_head', 'LinksAGC_add_LastMod_box');
    add_action('edit_link', 'LinksAGC_edit_update');
    add_action('add_link', 'LinksAGC_edit_update');

Twitter Widget

31st May 2011 (19:11)

One of the things I liked about blogger is the twitter widget that it provided so people can see my latest tweet and if desired follow.

I looked at various plugins for wordpress but non of them appeared to do what I needed.

Initially I tried to simply copy and paste the code from blogger into the page in "text" widgets. This did not work too well as my different templates had different zones in them and the code I had in the footer errored on a couple of pages.

So I decided to write my own widget to get this to work, it took me a couple of itterations to get something that I liked.

Here's what I ended up with, the first section is the header. All plugins need this to tell wordpress what they are.


Plugin Name: Twitter Badge Widget
Plugin URI: N/A
Description: Show a simple twitter badge with the latest tweet on a web page
Author: Andy Clark
Author URI: http://workshopshed.com/
Version: 0.2
Stable tag: 0.2
License: GPL v2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html

Based on the twitter code from blogger.
Ref: http://justintadlock.com/archives/2009/05/26/the-complete-guide-to-creating-widgets-in-wordpress-28


The next is to create a php class that implements the necessary methods to act as a widget. This has changed in Wordpress 2.8 and later but is much simpler than how you previously did things and makes the code nicer.

class TwitterBadgeWidget extends WP_Widget {

The constructor of the class does all of the setup, defining the name and description of the widget and then registering this so that wordpress knows about them.

   function TwitterBadgeWidget() {
   $widget_ops = array('classname' => 'TwitterBadgeWidget', 'description' => 'A widget to show twitter badge and latest tweet' );
   $this->WP_Widget('TwitterBadgeWidget', 'Twitter Badge Widget', $widget_ops);

The widget needs some files to run, it's using jquery libraries some custom java script to display the tweet and time message and also a style sheet. We can use the queing functions to ensure that the scripts are only loaded once at the top of the file and are only loaded if the widget is actually used on the site and we are not running the admin dashboard pages.

   if ( is_active_widget( false, false, $this->id_base ) && !is_admin() ) {
        wp_enqueue_script("TwitterBadgeScript",plugins_url('/TwitterBadgeScript.js', __FILE__));
        wp_enqueue_style("TwitterBadgeStyle",plugins_url('/TwitterBadge.css', __FILE__));

The Widget method is called when the widget needs to be displayed. This has to extract the settings and arguments for the widget. We use the arguments to determine the unique ID for the widget, this is how we get multiple instances to work later in the javascript.

   function widget($args, $instance) {
    // prints the widget to the user
   extract($args, EXTR_SKIP);
   echo $before_widget;
   $Twitter_ID = empty($instance['Twitter_ID']) ? ' ' : apply_filters('widget_Twitter_ID', $instance['Twitter_ID']);
   $Count = empty($instance['Count']) ? 1 : $instance['Count'];
   $title = apply_filters('widget_title', $instance['title']);
   if ( !empty( $title ) ) {
    echo $before_title . $title . $after_title;
   $widget_id = $args['widget_id'];
   $div_id = 'twitter_status_'.$widget_id;

We then render some div sections with the details of the tweets. I've used styles here which are referenced in the css file.  The variable $div_id is the unique ID for the widget.

   echo '<div class="TB_Block">';
   echo '<div class="TB_Picture"><a href="http://www.twitter.com/'.$Twitter_ID.'"><img src="'.plugins_url('/twitter-a.png', __FILE__).'" alt="Follow '.$Twitter_ID.' on Twitter" /></a></div>';
   echo '<div class="TB_Status"><ul id="'.$div_id.'">loading...</ul></div>';
   echo '<div class="TB_Follow"><a href="http://twitter.com/'.$Twitter_ID.'">follow '.$Twitter_ID.' on Twitter</a></div>';
   echo '</div>';
We now render out some dynamic javascript that uses jQuery to call out to the twitter API to get the status of the user. You will note that we dont use the typical $ but write out "jQuery" in full. This is because other libraries might be loaded such as "prototype" that define $ differently. There are alternative techniques but as the code is so short there did not seem a need for this. The jQuery defineds a simple call back function that updates the content of the DIV to be the results of the function TB_twitterformat.

The twitter API will bring back upto 20 entries, we then filter them back down using the count variable. I noticed that the API does not appear to like us using small values as the count parameter.

   echo '<script type="text/javascript">';   
   echo 'jQuery(document).ready(function() {';
   echo '   jQuery.getJSON("http://twitter.com/status/user_timeline/'.$Twitter_ID.'.json?callback=?", function(data) {';
   echo '   jQuery("#'.$div_id.'").html(TB_twitterformat(data,'.$Count.'));';
   echo '     });';
   echo ' });';
   echo '</script>';
   echo $after_widget;

The next function deals with the saving of the values when a user types into the widget

   function update($new_instance, $old_instance) {
    //save the widget
   $instance = $old_instance;
   $instance['title'] = strip_tags($new_instance['title']);
   $instance['Twitter_ID'] = strip_tags($new_instance['Twitter_ID']);
   $instance['Count'] = strip_tags($new_instance['Count']);   
   return $instance;

Our last function handles the form that is displayed to the admin configuring the widget.

   function form($instance) {
    //widgetform in backend
   $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'Twitter_ID' => '' ) );
   $title = strip_tags($instance['title']);
   $Twitter_ID = strip_tags($instance['Twitter_ID']);
   $Count = $instance['Count'];

   <p><label for="<?php echo $this->get_field_id('title'); ?>">Title: <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape($title); ?>" /></label></p>
   <p><label for="<?php echo $this->get_field_id('Twitter_ID'); ?>">Twitter User ID: <input class="widefat" id="<?php echo $this->get_field_id('Twitter_ID'); ?>" name="<?php echo $this->get_field_name('Twitter_ID'); ?>" type="text" value="<?php echo attribute_escape($Twitter_ID); ?>" /></label></p>
   <p><label for="<?php echo $this->get_field_id('Count'); ?>">Number of tweets to display (default = 1): <input class="widefat" id="<?php echo $this->get_field_id('Count'); ?>" name="<?php echo $this->get_field_name('Count'); ?>" type="text" value="<?php echo attribute_escape($Count); ?>" /></label></p>  

The last thing for the code to do is the add an action to register our widget.

add_action( 'widgets_init', create_function('', 'return register_widget("TwitterBadgeWidget");') );  


Over in the Javascript we've got some stuff to parse the response from the API and display it in a nice format.

function TB_twitterformat(twitters,maxtwits) {
  var statusHTML = [];
  for (var i=0; i<twitters.length & i<maxtwits; i++){
    var username = twitters[i].user.screen_name;
    var status = twitters[i].text.replace(/((https?|s?ftp|ssh)\:\/\/[^"\s\<\>]*[^.,;'">\:\s\<\>\)\]\!])/g, function(url) {
      return '<a href="'+url+'">'+url+'</a>';
    }).replace(/\B@([_a-z0-9]+)/ig, function(reply) {
      return  reply.charAt(0)+'<a href="http://twitter.com/'+reply.substring(1)+'">'+reply.substring(1)+'</a>';
    statusHTML.push('<li><span class="TB_Status">'+status+'</span> <span class="TB_Time"><a style="font-size:85%" href="http://twitter.com/'+username+'/statuses/'+twitters[i].id_str+'">'+TB_relative_time(twitters[i].created_at)+'</span></a></li>');
  return (statusHTML.join(''));

function TB_relative_time(time_value) {
  var values = time_value.split(" ");
  time_value = values[1] + " " + values[2] + ", " + values[5] + " " + values[3];
  var parsed_date = Date.parse(time_value);
  var relative_to = (arguments.length > 1) ? arguments[1] : new Date();
  var delta = parseInt((relative_to.getTime() - parsed_date) / 1000);
  delta = delta + (relative_to.getTimezoneOffset() * 60);

  if (delta < 60) {
    return 'less than a minute ago';
  } else if(delta < 120) {
    return 'about a minute ago';
  } else if(delta < (60*60)) {
    return (parseInt(delta / 60)).toString() + ' minutes ago';
  } else if(delta < (120*60)) {
    return 'about an hour ago';
  } else if(delta < (24*60*60)) {
    return 'about ' + (parseInt(delta / 3600)).toString() + ' hours ago';
  } else if(delta < (48*60*60)) {
    return '1 day ago';
  } else {
    return (parseInt(delta / 86400)).toString() + ' days ago';


WP Engineer Build a Widget
Is Active Widget
JQuery in wordpress

Redirection of Blogger syntax to Wordpress Syntax

6th May 2011 (09:35)

Moving from Blogger to Wordpress has been rather more effort than I would have liked, one of the issues was the permalinks. Here's my comments on the solution I've come up with to ensure than my model engineering blog does not break when I move it across.

When a blog has been running for some time there will be people who have deep linked your various posts and pages. The search engines will have done the same. When you move to Wordpress you don’t want all these links to stop working and for you to disappear out of the search engines.

To fix this you will need to redirect the other URLs from the old syntax across to the new syntax.

A good tool to help with problem page redirects is the following:

This needs to be configured to handle the different types of page:
  • Search
  • Categories
  • Posts
  • Archives

The following configuration is based on are based on the following initial work of Voyagerfan5761.

I created a group called “Blogger” so I can see my links separately from any others I might setup. I did this as a wordpress redirect but I don’t see any reason why it could not be done as an apache redirection using the .HTAccess

Setup these links below before importing the links at the bottom.

I’m not sure what the last one does but I’ve seen it in the logs so I’ve redirected it to the home page so people don’t get a 404 error.

The final thing is to redirect those links where the blogger permalink is different from the wordpress link. Luckily when you use the blogger importer it stores the blogger permalink in the wp_postmeta table so we can extract this information to make some new redirections. This can be done with some help from phpmyadmin.

For these pages we are going to script a series of redirects similar to this

Login to PHPMyAdmin and select your wordpress database. Run the following SQL.

SELECT CONCAT('/([0-9]{4})/([0-9]{1,2})/',Replace(Right(meta_value,INSTR(Reverse(meta_value),'/')-1),'.html',''),'\.html(\?.+)?$') AS Source,Concat('/$1/$2/',p.Post_Name,'/$3') as Dest
FROM wp_postmeta AS m
INNER JOIN wp_posts AS p ON m.post_id = p.id
WHERE meta_key = 'blogger_permalink'
AND meta_value <> '' and post_status = 'publish'
and Replace(Right(meta_value,INSTR(Reverse(meta_value),'/')-1),'.html','') <> p.post_name

This will produce results with two columns which can be exported as a CSV file. You then import this file into redirection to handle all of those links. The import screen can be found on the “Options” page of the redirection plugin.

My site was on a custom domain so I don’t need to configure the blogspot URLs to redirect across to the new site. However if you do have a blogspot url then you can follow these instructions to configure blogger for redirection.


Google Adsense Dos and Don'ts

31st March 2011 (12:32)

Google has just published it's latest guidelines on increasing cost per click

The dos and donts to increase cost per click - Inside AdSense

Upon reading this I realised that I disagreed with several of the points, but in fact I actually disagree with the whole premise.

I'm not actually interested in increasing cost per click, I'm interested in increasing revenue which is clicks x cpc. The issue in focusing in increasing cpc is that it assumes that at least one person is clicking on the adverts. I'm also interested in keeping my readers.

"Enable all of your ad units to show both text and image/rich media ads. By increasing the number of advertisers competing for your ad units, the ad auction will make sure that the highest paying ad will be shown"

My blogs are focused, one is about animation, one is about flea circuses and one is about model engineering. For example if someone like Sony, Nike or Cocacola are doing a massive promtion then they will pay lots for adverts regardless of where they are. So their cost per click will be high. However the people on my sites are not there to buy shoes, they are there to read about animation so they might not click on the adverts, even if they later go out and buy shoes from a shoe shop. If however I had an advert about animation software, microscopes or machine tools then they'd happily click on the adverts and hopefully also end up buying a product that they were interested in.

"Keep your filter list small so you don’t lower your revenue potential by blocking the highest-paying ads"

So if the highest bidder is say a pharmacutical company selling blue triangular pills then I'd have those on my site. One reader might click on the advert and I might get loads for that click. However all of the other 300 or so readers who are not interested in blue triangles might be put off and stop reading the blog all together. This is not a problem for google or for the advertisers as there are plenty of other sites that have their adverts on, it is a problem for me as I've just lost a load of readers. I've actually got the complete opposite, I've a very restrictive list, I looked at the percentage ad impressions and the % earlings. For example at the moment "health" has a 0.9% impressions and 0.0% earnings, so that's nearly 1% adverts effectively wasted. "Gardening" on the other hand has 11.8% of impressions and 13.6% of earnings so if I blocked those health adverts then my revenue could potentially increase by just over 1%.

"Increase the number of ads competing for your site by setting up your custom channels for placement targeting"

This I do agree with, you should clearly describe your custom channel, mine are currently

"Reports about the animation industry and animated films, including stop motion, cgi and traditional techniques."

"A look into the microscopic world of educated, industrious and trained fleas. Covering history, current performances, anything minature and cultural references to flea circuses. Also includes general news on fleas such as National Flea Week"

"Setting up and using a small shed as a model engineering workshop. Projects covered include metal work, machining (with lathe tools), casting and DIY."

With these I hope to target relavent advertisers who will enhance my blog with their adverts and hence keep themselves and my readers happy. In return I expect more clicks and hence more advertising revenue rather than just high CPC.

Hobby or Business?

9th February 2011 (10:11)

I've been wondering if I need to tell the government about any advertising revenue from my workshopshed website?

It turns out the issue is answered (if a little cryptically) in the HMRC "badges of trade" article.

In summary, the HMRC does not want to see you making losses and claiming back the tax for a hobby. The problems occur if you are on that boundary point where you are breaking even or making a small profit.

In BIM20090 HMRC suggests that you should seriously check that you are not a hobby if you intend to claim a loss and to check if a single year's profit might have been a fluke occurrence. What this means is that you are going to need to know what your costs are of your hobby as if that hobby was a business. Allowable expenses "must be 'wholly and exclusively' for carrying on and earning the profits of your business. This means that your sole purpose for the expenditure must be a business purpose", which is a little contradictory if you are looking at a hobby and also leads onto the next point.

Obviously for a hobby, enjoyment is a key factor and this would affect the HMRC decision. BIM20245 describes how an asset might have value more than it's monetary one. For example for a blog you might enjoy the writing process and be using it as personal development, relaxation or to interact with other people with similar interests. You might also purchase and review a book, because you wanted to read it.

BIM20080 describes the process that they will take if you are investigated and any documentation needed.

My action plan is:

Write a definition of what I think my hobby is, kind of like a not for profit business plan
Start recording my expenditure and reciepts (rather than just simply stuffing the reciepts on a box)
Analyse the expenses and receipts to see how much the hobby is costing

Then if anyone asks I'll be able to give a clear answer that my activities are a hobby not a business.


Incase you'd not realised, I'm not an accountant or tax advisor so any conclusions you draw from this article are at your own risk. Links correct at the time of writing

Moving from Blogger to WordPress

9th December 2010 (10:05)

I've been thinking about moving the Workshopshed blog from it's current home on blogger across to a Wordpress engine.

I've used wordpress before on other projects so I like what it can do. My main gripe with previous versions was the posting of graphics which has significantly improved since I last used wordpress. I've download a LAMP VM which I'm going to try a test migration on to learn some of the issues. I don't really use many gadgets in blogger, just the HTML, Posts and Link lists.

Apart from the issue of installing wordpress and setting up a database I can see the following issues.

Move posts (both historical and scheduled)

These can be imported into Wordpress (what about images and pages?)
Move pages (could be done manually there's only a few)
Images do these need to move, ?
Links - I've a lot of these on the existing site in link gadgets.
Blog Roll

Similar coulum layout and colours to existing
Custom Styles for adverts and twitter?
Improve display for wide screens
Sidebars (over 20 in existing layout)
Improve GeoIP functionality for adverts etc
Improve Meta data information on pages
Meta tags for verifying site
Meta tags for location
Link Redirection - Plugin to help?
Hierarchical blog archive (see link redirection)
Tracking code / Analytics
Amazon code for popups and link enhancement
DNS stuff for ISP to handle
RSS feeds / feedburner
Twitter / twitterfeed
Upcoming posts plugin could be good?

Google Analytics tracking

7th December 2010 (16:15)

current mood: accomplished

I put some event tracking code onto the Workshopshed.com website some months back to track which of my Amazon adverts were being displayed. It initially was not showing anything but when I checked it again today I see that it's producing metrics.

The event tracking can be used for things like interacting with external clicks, javascript or flash and the counts don't appear in your page views so you don't get multiple counts.

The way I do this is that in the PHP code that determines which adverts to show, I also run the following javascript which is also run with different tracking IDs e.g. "AmazonUK.Carosel"

try { var pageTracker = _gat._getTracker("MyGoogleID");
                        } catch(err) {};

Here's the google documentation on the tracking functions.

< back | 0 - 10 |