Skip to content

{ Category Archives } WordPress

WordPress is used to run this blog.

RegExp’s - just like Marmite

Regular expressions are not everyone’s cup of tea. I recently started using a plugin for WordPress called Download Counter Advanced, and it works great for my Battrick stuff. I wanted an easy way to add in the date so that I could put “…downloads since…” and have the date automatically insert, all marked up correctly.

I hacked the plugin code, and managed this, and out of courtesy, sent the code to Andy Staines, the author of the plugin, via his contact form. This was his reply (emphasis mine):

Ah… um… thanks!

The shocking truth is that I don’t read regexp’s! I read that chapter three times and quickly concluded that I would prefer to gently flay myself with an old dressing gown while standing naked in the snow than try to follow the rules.

My son helps me out here who is known as a RegExp king. So can you confirm what your random sequence of numbers and letters below actually does in detail as it always looks to me like it was typed by a monkey swaying gently under the influence of Prozac…

It doesn’t help that I have had only about four hours sleep only to be rudely awoken by a barking dog. So I am not thinking clearly yet. So - you pass in the data row of the download? And get back the start date?

Andy

Tagged , , ,

Review: hReview WordPress Plugin

In a previous post, I’d mentioned that I’d installed the hReview plugin, but then deactiviated it due to “problems”. A comment from the author of the plugin, Andrew Scott, asked what those problems might be, and I realised that I simply hadn’t given the plugin a fair go before dismissing it. Below is my review of hReview (marked up as a microformat *using* hReview, naturally), though my styling could do with a tweak.

hReview WordPress Plugin

product

hReview WordPress Plugin does the job well

The plugin installs fine, and activates without a problem. It appears on the Write Post page as either a star or the word “hReview” (depending on if you use the visual editor or not). Selecting the star/hReview brings up a dialogue box where details of the review can be entered in. Comparing it to the hReview specs, I can see that it does cover most of the items, although some of the optional bits are missed out.

Screenshot of using the plugin to write a review

When I first used it, I’d tried using the type option to specify a product. In the visual editor this just came up as a single word in a paragraph of it’s own. Now a word is not a paragraph, so perhaps this should be marked up as a span instead. Looking at the code view, I can now see that some inline styles had been applied so that the paragraph was set to display: none; anyway. Now I know I can hack the plugin, or my own CSS, but I would prefer this word to be in a span, capitalised, with a colon, before the item name - so in this review it would have said: Product: hReview WordPress Plugin. Other types would have the same effect. Simply having (optional) data included in the source for the sake of a microformat, yet not displaying it visually is kind of against the microformat principles.

Using the dialogue box, once the content of the review has been inserted into the post editor, adding more content means looking in the code view and working out which bit you want to edit. This is fine if you have any idea about HTML, but may be scary if you don’t. Clicking the star/hReview button again brings up a blank new review box, rather than being able to edit the first review. Perhaps clicking the star should bring up the existing review, but have a button on the dialogue box for a new review (a form reset button in effect).

Lastly, part of the spec mentions the use of dtreviewed, reviewer and license. These are optional data that can be included with an hReview. Sadly, the current plugin doesn’t cater for these, which, although they are optional, may be important to certain reviewers. Ideally, the dtreviewed could be added to the post date (the specs do suggest this), and the reviewer could be added to the author data, marked up as a hCard (the specs say parsers should look outside the hReview if a reviewer can’t be found inside the review). Of course this would mean adding it into the WordPress templates, which may or may not be possible via scripting the DOM. Alternatively, settings on the dialogue box would be better and solve the problems above, as the reviewer may not be the poster, and the review date may not be the posting date. A drop down list of common licenses should also be available - those who know what they are can use it, or it can be optionally left blank.

Overall, the plugin does the job it claims to, and I admit that my previous comments were unfair (I’ll go highlight it in that post shortly). It would be nice if the Operator / Tails Firefox addons offered support for hReview, and perhaps the author of hReview may wish to contribute to those as well.The Operator addon does offer hReview support, although this hReview wasn’t detected due to what I believe is a small bug in the plugin - see the comments. If you intend to carry out reviews of any sort, and use WordPress, then the hReview WordPress Plugin from Andrew Scott is for you.

My rating: 4.0 stars
****

Tagged , ,

Web Projects

I’ve got so many web projects on the go at the moment, it’s difficult to keep track of them!

  • This very blog - I’ve recently changed themes, and it needs updating to fit in with how I want it to look. In fact I eventually want to turn this whole garyjones.co.uk site into something that’s run completely with WordPress.
  • MNNC.net has recently had WordPress added to it, so that as part of the re-design, I can use WP as a CMS. I’m supposedly using Basecamp from 37 Signals to keep track of the project.
  • For the Battrick game I play, I’ve developed some resources that have become popular within the BT community. I eventually want to integrate it more into the rest of this blog site with WP, as well as still develop the resources that exist.
  • The Battrick site itself could do with some front-end code updating, so instead of moaning about it, I decided to do some investigations and tests to offer comprehensive examples and feedback on how the site could be improved.
  • My Development section is another section I want to add to integrate into WordPress. Lots of template customisation needed, along with some CSS, so I can keep my code examples.
  • Leovanna.co.uk is my Dad’s site that I built, but we now want WordPress to run the whole site, but only look like it’s running the news section. Some templates and static pages will help with that, once I’ve worked out exactly what I’m doing with the MNNC.net site. I’ll also need to find some suitable plugins too.
  • I had an “epiphany” this morning, as Katie called it, and thought of a new tool that I would find useful for myself. I often review websites to give constructive criticism on how they can be improved, and this webReviewer tool (I haven’t got the cheek to call it webReviewr in Web 2.0 style) would allow an easier way of writing it up, as well as giving reminders of areas to check. I’ve drawn out some ideas, but not produced anything yet.

If I can get all these done by the time we head back to the UK, I’ll be pleased, but I don’t want to spend all my time here doing them, however much I enjoy it all!

Tagged , ,

Fixing the blog, Part 2

I really liked the Hope theme that I had for a while as I thought it looked great. There were a few minor problems with it, but I’d emailed the designer and she said she’d try to look into it. Apart from not being widget-ready, some of the latest themes have got microformats embedded into them, and this is something I wanted.

Designed for humans first and machines second, microformats are a set of simple, open data formats built upon existing and widely adopted standards” - Microformats.org

In short, they add certain class names to HTML elements. Sandbox is the first known theme to have hCard and hAtom microformats, and the Barthelme theme, which this site is heavily based on, is a follow on from that. I’ve also added an hResume plugin and a hReview plugin (plugin removed, as it wasn’t working well) (see my review of this plugin) to really offer some good data to the world. Following on from my previous problems, I still couldn’t display the thumbnail-linked images on their own page. I could in the default theme, so the problem had to be with the Barthelme files. This time attachment.php was the starting point, and after comparing it to the default attachment.php I could see that there were two important lines of code missing from lines 7 and 8:

<?php $attachment_link = get_the_attachment_link($post->ID, true, array(450, 800)); ?>
<?php $_post = &get_post($post->ID); $classname = ($_post->iconsize[0] <= 128 ? ’small’ : ”) . ‘attachment’; ?>

Without those lines, $attachment_link and $classname are not defined, and so the image doesn’t show. Well it now works, and so the only thing left to do is to tweak the theme even more to my own liking and add some more posts!

Tagged

Fixing the blog, Part 1

For a while now, whenever I’ve tried to link a thumbnail image to a Page, rather than a File (WordPress users will know what I mean), the link wouldn’t work. I thought that perhaps the updated WordPress had broken it, or something in unused tables had caused it not to work. I could see via FTP that the image file itself was there, but somehow WP couldn’t find it when it needed to stick it on a page.

I was convinced it was an upload.php problem, or how it was stored in the wp_post or wp_postmeta tables in the database. I manually scanned these, having to learn quickly how these tables were constructed to see if I could spot anything that wasn’t right. I tried using the default theme in case the files with the theme were playing up, but even with re-uploading the picture (Elisabeth became a test post for a while), there was still no joy.

Although there were a few bugs raised in WordPress Trac, of those that I could fine, none of them quite fitted my problem, or couldn’t suggest a solution if they did. I even managed to rope in Ian Knight from 34SP.com to offer suggestions, after originally asking him about something else entirely. With his suggestions, it was tracked down that the custom permalink was causing the problem. With that knowledge I could find a support post and a bug raised on it, though both could offer nothing more than to say “don’t use /category/ in the permalink”.

Now this is a less than ideal solution, as permalinks are supposed to be, as the name might imply, permanent links, which shouldn’t change, but if I wanted my thumbnail links to pages to work, that is exactly what I had to do. By the time you read this, I’ll have converted all the old style post links to the working version, and re-uploaded all the pictures so that they work as intended to.

However, this wasn’t the end of my problems.

Tagged