Wordpress – Graeme's https://pietersz.co.uk Meandering analysis Fri, 12 Dec 2014 12:15:17 +0000 en-US hourly 1 https://wordpress.org/?v=6.4.3 Why you should not use WordPress https://pietersz.co.uk/2014/10/dont-use-wordpress Mon, 06 Oct 2014 12:24:01 +0000 http://pietersz.co.uk/?p=746 The appeal of WordPress is obvious: cheap and easy, and lots of “developers” know it. The biggest problem with WordPress is that something originally designed as a blog platform, has evolved general CMS features, and is widely used a development platform. The problems are that it has security issues, and is neither flexible nor productive when used a a development platform and cheap developers are not good developers.WordPress is a very easy way to get a site up and running, and I do use it myself for small sites – even this blog still runs WordPress (although it may change). So what is wrong with WordPress?

Security

WordPress has a terrible track record, and WordPress sites are the most frequently targeted by attackers. There have been massive automated attacks mounted on millions of WordPress sites simultaneously. WordPress sites are easy for attacking web crawlers to identify without human intervention so the cost of attack is very low on a per site basis.

WordPress advocates will point to improvements in WordPress itself, and claim it is a lot more secure than it used to be. However, it still suffers from bad design, and a poor attitude – for example, WordPress developers actually encourage letting WordPress alter its own files because they is how their update mechanism works.

Even if WordPress is now adequately secure, even its defenders will usually concede that there are many insecure themes an plugins. As the attraction of WordPress is its wide range of themes and plugins this leaves you with limited choices:

  1. Use WordPress only with bundled themes and plugins. This leaves little reason to use WordPress at all.
  2. Security audit the themes and plugins you use: suddenly its not so cheap or fast to set up a WordPress site.
  3. Develop all themes and plugin especially for your site: this makes WordPress an expensive solution if your site requires any real customisation.
  4. Only use WordPress if you are sure it will do what you want with minimal customisation and only themes and plugins you are sure are secure.
  5. Risk it!

Even being this careful, you still have to deal with the fact that a WordPress site is far more likely to be attacked. Even an unsuccessful attack can cause problems (slower site performance, bandwidth consumption from repeated attacks etc.). Certainly, you can (doing a bit more work) solve these problems, but even then any security hole in WordPress is more likely to lead lead to a breach because it is a popular target for automated attacks.

It is not a framework

People use WordPress for all kinds of websites, and even something that are better described as web apps. They have a bad case of “when all you have is a hammer, everything looks like nail”. Anyone who has used a proper framework will tell you that developing a custom site using WordPress is a far longer and less productive process than using framework like Django, Ruby on Rails, or Symfony. If you are a developers, compare this to this, or even better, this.

Similarly frameworks provide productive ways of generating forms that match database tables, or creating a custom admin interface. The work required to deliver the same custom functionality is dramatically lower.

A (good) framework also takes care of a lot of security issues for you — Django, my favourite framework, generates properly escaped database queries by default, and requires CSRF protection on forms by default, etc.

It uses PHP

PHP is a horrible language, and PHP code is harder to maintain. A developer should remember that there are always a minimum of two developers working on any project — you, and you a few months later, and the other one is an idiot. Hard to read and understand PHP code will create more work later. This is just one of PHP’s many, many faults, which are brilliantly covered in depth in A Fractal of Bad Design.

Again, the end result is to make development slower and maintenance more expensive.

PHP advocates like to point to the many large sites like Facebook that use PHP. PHP has worked so well for Facebook that they have resorted to forking it to address some of its more egregious flaws, but they are still constrained by the need for compatibility so it is still far from being a good language. Facebook also uses many other languages: they have released open source components in Ocaml, Java, C++. D, Haskell and more so they presumably use all those somewhere.

Lots of developers, does not mean lots of good developers

A lot of people like the fact that there are more WordPress developers than those working on any other web platform, many working at cheap rates. The reason for this is that it has a lower barrier to entry: it is easy to learn enough to install WordPress and some plugins, perhaps learn a bit of PHP for simple customisation… now you are a developer!

Of course there are plenty of good PHP developers, but I very much doubt there are more good PHP developers than Python or Ruby web developers. On top of that, good PHP developers are unlikely to be pitching for WordPress work and are probably focusing on more skilled stuff using frameworks. If you want cheap, WordPress is for you, but remember who works for peanuts.

What WordPress is good for

I still run my blog on WordPress, and I have used it for some small sites. It is a very capable blog platform, and is acceptable for small brochure type sites. If you are sure that is all your need, and all you are are likely to need, and have a limited budget, then maybe WordPress is a good option, but:

  1. Ensure you install is security hardened: there is a lot you can do to make it harder for automated attacks to identify your site as WordPress based and make sure it is regularly updated. I will be blogging about that soon.
  2. Use a host that gives you ssh access so that you can use wp-cli to run updates: otherwise you will either have to use the horribly insecure built in update mechanism, or update manually.
  3. You have confidence in the security of any plugins and themes you use.
  4. Pay for a decent developer. No one with real skills is going to work for £5/hour, even in a low cost country.

If it is so bad, why is it popular?

It is not a case of it being popular despite it being bad, but it being bad because it is popular. As long as WordPress was used for what it is best at (a blogging platform) it was fine (apart from some security issues). Even extending its usage to personal and small websites was fine. The problems are:

  1. It is being used for things it was nor originally intended for,
  2. It is so hugely popular that it is by far the most popular target for automated attacks.

The first of these causes a productivity problem: it is better to use the right tool for the job. The second means that security problems are far more likely to be found (by the bad guys) and exploited. I am talking here about automated attacks that attack thousands, or even hundreds of millions, of sites, in the hope of finding some that have a particular weakness. From the point of view of someone running one of those attacks, WordPress is probably the most attractive single target because it is popular,

I am not dead set against WordPress, but I am looking for alternatives, especially for small non-blog sites (perhaps for blogs as well) so please look out blog posts on how that goes.

]]>
WordPress plugin: Slug Trimmer https://pietersz.co.uk/2006/07/wordpress-slug-trimmer https://pietersz.co.uk/2006/07/wordpress-slug-trimmer#comments Sat, 15 Jul 2006 09:10:26 +0000 http://pietersz.co.uk/2006/07/wordpress-slug-trimmer I have got sick of URLs that end in really long post slugs that look-something-like-this-and-are-far-too-long so I wrote a little plugin that shortens post slugs more intelligently than simply truncating them.

It works in two phases. It first removes short words (because words like “a” and “the” are rarely significant), shortest first.

If the slug is still too long, it is then truncated. However slugs will never be truncated mid-word.

The size of words removed the the first phase and both the minimum and maximum lengths of the slug resulting can be configured. Truncation can be turned off. The point at which the slug is truncated is set separately from the maximum for the purposes of phase one (word removal).

The slug is generated on saving a post (so you get a chance to look at it before publishing), or on publish. It will not overwrite an existing slug, even one generated by itself. You can force the generation of a new slug by deleting the existing one.

Installation and configuration is simple. Download Slug Trimmer here. If you want to change the configuration, the options will appear as a sub-panel of “Options” in your WP Admin.

If you find this plug useful and feel inclined to do me a favour: I would really appreciate links to any of my money-making sites. I most need links to internal pages of Moneyterms, or to either the front page or the books section of PTZ.com.

]]>
https://pietersz.co.uk/2006/07/wordpress-slug-trimmer/feed 11
WordPress theme: Red Drop https://pietersz.co.uk/2006/02/wordpress-theme-red-drop https://pietersz.co.uk/2006/02/wordpress-theme-red-drop#comments Tue, 14 Feb 2006 11:30:00 +0000 http://pietersz.co.uk/2006/02/wordpress-theme-red-drop Red Drop is a red (surprisingly!) WordPress theme with drop down menus.

Red Drop screenshotThe screen space saved by using drop downs is used to provide a right navigation bar that varies with the page being viewed. For example when viewing a post the left nav bar shows the (titles only) of recent posts in the same category (or categories).

It is slicker than my previous themes. Doing themes is definitely fun and I will be doing more when I have the time.

You can select this theme (and my other themes) from the theme switcher drop down.

You can download Red Drop from here.

]]>
https://pietersz.co.uk/2006/02/wordpress-theme-red-drop/feed 2
WordPress theme: Dent https://pietersz.co.uk/2006/01/wordpress-theme-dent https://pietersz.co.uk/2006/01/wordpress-theme-dent#comments Mon, 30 Jan 2006 08:26:33 +0000 http://pietersz.co.uk/2006/01/wordpress-theme-dent This is a simple theme based on earth colours. Dent theme screenshotIt is named Dent because it is it is more Human than Beeblebrox. I know its a bad joke, but at least it gave me a snappy name. Although I started wanting to do a theme with the search bar at the top left and the title at the top right (i.e. like Beeblebrox) but in the colours used for Human. In fact my theme is not all that similar to Beeblebrox (apart from the position of the search box), and the colours are actually adjusted from a palette taken from Turner’s The Fighting Temeraire.

You can download it from here

]]>
https://pietersz.co.uk/2006/01/wordpress-theme-dent/feed 2
WordPress theme: Esthwaite https://pietersz.co.uk/2006/01/wordpress-theme-esthwaite Mon, 30 Jan 2006 08:25:24 +0000 http://pietersz.co.uk/2006/01/wordpress-theme-esthwaite My first completely original WordPress themes. You can preview it by using the theme browser (you may have to reload the page to get the theme to change). 

Esthwaite theme screenshot

This theme is based on photos taken in the Lake District. For those unfamiliar with Britain, the lake district is a part of England which has lots of …. lakes. You can download the theme from here.

]]>
WordPress plugin: Frameable https://pietersz.co.uk/2005/08/wordpress-plugin-frameable Thu, 04 Aug 2005 15:31:58 +0000 http://pietersz.co.uk/?p=23 This plugin is designed to make individual pages of a site frameable. This can be used to enable cut and paste quoting of individual posts or cut and paste (X)HTML only syndication of a blog or blog category.

Edit:I no longer use this plugin, and it is now far better to do this using RSS, so do not use this plugin unless you particularly want to use a frame or an iframe (there are good reasons for doing that).

You can download the plugin and a frameable theme from:
http://pietersz.co.uk/downloads/frameable.zip

Functionality and basic usage

The plugin works by switching themes if a particular query string is appended to the URI (this is the same functionality as Ryan Boren’s theme switcher). By default it uses a theme called Frameable (included in the download). It also adds target=”_top” to links from the post content, so links lead back to the unframed site in the top level window. Adding target=”_top” in the post title needs to be done in the theme (see included Frameable theme for example).

It also provides a function to use on the pages you wish to make frameable. link_to_frameable(link text, ‘inline|external’) Typical usage would be:

echo link_to_frameable(‘Click here for frameable version’, ‘inline’);

This will return a link directly to the frameable version of the page.

Advanced usage

More elaborate usage is possible by setting up a special page (in the WordPress static page sense of the word) on which the (X)HTML to cut and paste is given. For examples of this take a look at this site and click on “clip this” or this site and click on “quote this”. This is how the examples above were generated.

In order to do this you need:

  1. call link_to_frameable with the second a parameter ‘external’. In fact you could simply omit it as this is the default behaviour.
  2. Create a page that uses the functions described below to generate the HTML you want. You will need to use a special page template or a PHP execution plugin.
  3. The page you use for this must either be a top level (no parent page) with the page slug “frameable”, or you need to edit the plugin to to give it the page URL

The two functions provided for this are:

  • frameable_return_uri(); has a single parameter. Its value can be ‘framed’ (the default) which returns the URL of the framed version of the frameable page or ‘original’ which returns the URL of the standard version.
  • frameable_return_title(); no parameters, returns the title of the page you are framing.

Both these functions should be used only on the page which generates the (X)HTML. This page should never be linked to directly as link_to_frameable(‘external’) will link to it with a query string containing the URI of the page you want to frame.

An example of the usage, taken from the link generation page on the Money Terms site.

<iframe src=”<?php echo frameable_return_uri()?>” style=”width:100%”><a href=”<?php echo frameable_return_uri(‘original’);?>”><?php echo(frameable_return_title());?></a></iframe></textarea>

This creates the HTML needed to call show the framed page in an inline frame, and to degrade gracefully to a link to the page instead in a browser that does not understand inline frames.

]]> Simple Sparklines WordPress plugin, version 0.2 https://pietersz.co.uk/2005/07/simple-sparklines-02 https://pietersz.co.uk/2005/07/simple-sparklines-02#comments Wed, 20 Jul 2005 10:44:15 +0000 http://pietersz.co.uk/?p=22 I have updated my Simple Sparklines WordPress plugin. My thanks to David Chait and Mark Wubben for anwsering my questions on the WordPress support forum. The hardwork was done for me by James Byers’ Sparkline PHP Graphing Library.

Basic use is the same as in version 0.1. The main new feature is that the graph height can be set to ‘auto’, rather than a set number of pixels. This will (in browsers with Javascript enabled) set the height of the graph to match the text. If Javascript is disabled the height will default to 15 pixels . The aspect ratio can be specified in order to allow the width to also adjust in line with the height. As with the size parameter, the aspect ratio of a bar graph refers to a single bar, not the whole graph.

This [spark] [type line] [size auto,30] [aspect 1.5] [series 66,64,62,60,58,56,54,52,50,40,30,20,10,0][dot 7,50,5,green][/spark] and this [spark] [type bar] [size auto,4] [series -24.6,3.1,27.1,43.6,39.1][/spark] are the examples used in my original post on the plugin, but with height set to auto. If you change your text size and reload you will see the change.

I have added a [line-width number] parameter that does exactly what it says for line graphs. The line-width, like the [dot] radius is a size on the graph before re-sampling, so the actual width in pixels will be much less. Any value other than 1 (the default) tends to make non-horizontal or vertical straight lines in text sized graphs look awful. It is primarily useful for large graphs (i.e. not true sparklines), which look much better.

I have cleaned the code a bit, and there is now a function:

sparkline_insert(line | bar, height pixels | auto, width, aspect ratio, comma separated data series, [optional] feature point, line width, default height)

that can usefully be called by other plugins or from templates. The feature point parameter is a string containing a comma separated list of parameters in the same format as inserting in a post, ditto the data series. everything else apart from the chart type (line or bar) is a number (unless height is auto).

I have not done anything about implementing caching or multiple data series yet.

I would be very grateful for any feed back, both from those who use the plugin and those who see it here. In particular I need to know whether auto height works OK in IE (all versions from 5.0 upwards) and Safari. So far I know this works on Firefox, Opera and Konqueror.

To install the plugin download this, unzip and copy to your WordPress plugins directory, then activate as usual.

As a good few bloggers are likely to look at this page, I think this is a good place to mention my main sites, Investment Ideas and Money Terms in the hope that some of the users of the plugin might feel inclined to link to them. The latter may well be pretty useful to link to, for anyone writing about finance or investment. The plugin was actually developed for the latter.

]]>
https://pietersz.co.uk/2005/07/simple-sparklines-02/feed 18
WordPress plugin: Simple Sparklines https://pietersz.co.uk/2005/06/wordpress-plugin-simple-sparklines https://pietersz.co.uk/2005/06/wordpress-plugin-simple-sparklines#comments Mon, 20 Jun 2005 08:51:43 +0000 http://pietersz.co.uk/2005/06/wordpress-plugin-simple-sparklines Updated version available.

This is a very simple WordPress plugin that allows the creation of simple sparklines (small graphs that fit in the flow of text). It uses James Byers’ Sparkline PHP Graphing Library.

The aim of this plugin is simplicity, it therefore does not use the full range of features of the PHP sparkline library, let alone the full potential of sparklines per se. However it is very easy to use. For example this graph [spark] [type line] [size 20,30] [series 66,64,62,60,56,54,52,50,40,30,20,10,0][dot 7,50,5,green][/spark] illustrates the kinked demand curve faced by a firm in a oligopolistic market. The EBITDA of telecoms company Thus over the last five years is shown by [spark] [type bar] [size 20, 4] [series -24.6,3.1,27.1,43.6,39.1][/spark].

The markup to generate these is fairly simple: [spark] [type line] [size 20,30] [series 66,64,62,60,56,54,52,50,40,30,20,10,0][dot 7,50,5,green][/spark] for the demand curve and [spark] [type bar] [size 20, 4] [series -24.6,3.1,27.1,43.6,39.1][/spark] for the EBITDA graph.

The plugin processes whatever is between [spark] and [/spark]. The types can be line or bar, the series consists of values the are sequentially plotted on the graph – i.e. these are y values, the corresponding x values are assumed to start from zero and increase by one each time. The points plotted above are (0,66), (1,64), (2, 62) etc. The dot instruction adds a green dot at (7, 50) with a diameter of 5. Size controls the size in pixels of the graph, height then width – so the graph above is 20 pixels high and 30 side.

Bar graphs can not have the dot highlights (so the [dot 7,50,5,green] would be ignored and width is taken to be the width of an individual bar rather than the whole graph. Bar graphs also show positive values in black and negative in red.

At the moment the plugin can handle only a single data series, and (in the case of line graphs) a single [dot] highlight. There is no control over colours. I plan to:

  1. Add multiple data series and dots
  2. Improve colour choices, especially for multiple series
  3. Improve input validation

Other suggestions are very welcome. I would like to know if anyone else finds this plugin useful.

I would also like to find away of automatically scaling the height to the current text size, however I can not figure out how to pick it up (JavaScript perhaps?). Anyone with any ideas please let me know.

If anyone if familiar with wp-cache: will it cache the output of this plugin? specifically the image generated by the sparkline/image.php

This is my first WordPress plugin and the first PHP code I have written other than the odd lines in WordPress templates. If any better coders use this plugin please have a look at the code for any flaws you can spot. The plugin and the underlying library are both beta, but given the plugin’s simplicity I am reasonably confident that it is unlikely to fail in a way that will leave a user with a worse result than a missing or incorrect graph. One limitation is that it can not handle large series of data because all the data is encoded in the URL, which has a limit of about 2,000 characters.

To install the plugin download the current version, unzip and copy to your WordPress plugins directory, then activate as usual.

]]>
https://pietersz.co.uk/2005/06/wordpress-plugin-simple-sparklines/feed 3