sciolism

Playing around with technology

Get the Flattr WordPress plugin ready for HTML5

If you are using the Flattr WordPress plugin you can choose between three different modes of button presentation:

If you choose one of the static variants everything is fine using HTML5 markup. Now, if you choose the Dynamic javascript version this will result in an non-valid source code. The reason for that is that the rel attribute is no longer supported in HTML5, what is also said on the Flattr website. However, the fix for that issue is quite simple. Just replace the function getButtonCode (line 644) in the flattr.php in the plugins directory. Note that I don’t check for empty values for the category and the tags field anymore, as my workflow does not include empty categories or tags.

protected function getButtonCode($params) {
  return '
  (!empty($params['title']) ? ' title=" ' . esc_attr($params['title']) . '"' : '') .
  ' data-flattr-uid="' . $params['user_id'] . '"' .
  ' data-flattr-category="' . $params['category'] . '"' .
  ' data-flattr-tags="' . htmlspecialchars($params['tags']) . '"' .
  '>' .
  esc_html(empty($params['description']) ? '' : $params['description']) .
  '</a>';
}

Now your markup should be valid.

Article info