Windows Live Writer plugin to prevent internal pingbacks on WordPress.com
As I wrote about and posted a workaround for not too long ago, internal pingbacks really annoy me (when you link to a previous post of yours and it generates a pingback in the comments of the post to which you linked). In general I think pingbacks are excellent, but when they are from me, to me, I think that they look untidy and unprofessional, and they annoy me. What also bugs me is going back and manually removing them, especially when I don’t write my blog posts using the in-browser editor.
Plugin solution
So I decided to write a plugin for Windows Live Writer which automatically turns absolute links to posts on your own blog into relative ones, preventing a pingback being generated.
Note: RSS READERS DO NOT LIKE RELATIVE LINKS – if someone subscribes to your blog by RSS, if you have a relative link in your post, their RSS reader will not be able to handle the relative link (if they click on the link in the RSS reader they won’t be taken to the link destination). Source – thanks to Joe on the WLW dev team for pointing this out.
There are plugins for various blogging packages which prevent internal pingbacks, including WordPress, but as I host my blog for free on WordPress.com I can’t use plugins.
So I may well be the only person to ever use this.
How it works
What the plugin does is search through your blog post when you press Publish, and it it finds the string
<a href="<http://your blog.com>/<some blog post>
it changes it to
<a href="/<some blog post>"
(Actually it doesn’t include the “<a “ bit but I included that so that the Source Code Formatter plugin would get the colours right)
And that’s it.
To install, download the installer from codeplex (the source code is also available) and run it. Enable the plugin in Tools | Options | Plug-ins. The first time you Publish after enabling it you’ll be asked if you want to activate it for the particular blog, as it is a blog-specific (PublishNotificationHook) plugin – you can manually enable it per-blog by going to Blogs | Edit blog settings | Plug-ins.
Development and references
I originally coded this plugin as a ContentSource plugin which incorporated a form like Insert Hyperlink. However this seemed to me to be too fussy and annoying to have to remember to distinguish between links to your own posts and other links, so I re-created it as an inline “set and forget” plugin.
For the first version I found Scott’s guide very easy to read and helpful, and I also found Keyvan’s write-up useful.
For the second – final – version I did some more reading and found that Scott had already written a plugin which made all hyperlinks bold, which did almost exactly what I wanted. He wrote a very nifty WriterUtilities class (unsupported by him or the WLW team) which allows you to edit the contents of the blog post (by plugin) before it gets published. When I emailed him checking that it was ok to re-use his class he couldn’t have been nicer or more friendly.
I re-used Scott’s Bold Hyperlink Plugin almost in its entirety, so Scott, thanks for inventing this wheel!
When it came to building the installer I had a quick peek at Ben Hall’s post as I haven’t created an installer since I was coding in VB 6.0.
Codeplex project page: http://www.codeplex.com/RelativeInternalLink
Windows Live Writer, WordPress & Headings
I like to format anything I write, whether it be a letter, a report, a blog post etc
Formatting improves readability and , for me, structured presentation helps to promote structured and more comprehensive thinking/analysis.
Problem – My headings don’t work
Accordingly I’ve been frustrated by one aspect of the WordPress – Windows Live Writer integration, which is that when I use headings and subheadings in WLW my post looks great. However when I publish the post to WordPress, my nice headings disappear and my post loses much of its structure. Update: This only happens when using browsers other than Internet Explorer. My apologies to anyone (including the developers) who I mislead regarding this. Update #2: Apparently IE8 will fix this, as WLW renders the WYSIWYG editor and preview using Internet Explorer’s engine, and the IE8 beta is much closer to Firefox/Opera etc in its standards compliance.
See what I mean here.
It finally got to the point today that I had to find out why it was happening.
Cause
Looking at the Source View in Windows Live Writer I found out that the Heading (1-6) formatting is represented in HTML as the <h1>-<h6> tags, which is logical and as it should be. And looking at the WordPress posts a little more analytically I saw that it was just the <h1>-<h3> tags which didn’t seem to display as expected.
After a little bit of research, I found out that most WordPress themes already use the <h1>-<h3> tags in their themes, and have customised their attributes. Updating the theme in Windows Live Writer doesn’t seem to integrate this aspect of the theme’s CSS.
This is pretty basic stuff which anyone who puts a bit of time into WordPress/blogging would probably have caught from the start, and had I bothered to have a look at the CSS files being served with my blog page I’d have realised it too. For a casual blogger like myself though, or someone who knows nothing about HTML/CSS, it could be a source of frustration.
Solution
The workaround for this is to only use Heading styles 4-6 when writing posts in Windows Live Writer, or to modify your WordPress style CSS file. Bear in mind that modifying is going to change the look of the places where Headings 1-3 are already used, generally the blog title, post title and comments.
Anyone using blogging as a means of generating money should be aware of the implication Headings have for SEO.
Update:
The behaviour described above only occurs when using browsers other than Internet Explorer, such as Firefox and Opera (I haven’t tested Chrome). I should have checked those browsers before posting this. My apologies to anyone (including the developers) who I mislead regarding this.
Update #2:
Apparently IE8 will fix this, as WLW renders the WYSIWYG editor and preview using Internet Explorer’s engine, and the IE8 beta is much closer to Firefox/Opera etc in its standards compliance.