News

Force new windows on external links?

Don’t force your users to open new windows…. even on external links.

There are many reasons why it is a bad idea and not many reasons to do it.   There are maybe a few special cases where it is ok – but is it ever really necessary?  Personally I like to control the opening of tabs myself – I use the right click frequently at times – when I’m researching I open heaps of tabs, then work my way through them.  That doesn’t mean I want a website to forcibly open those links in new windows for me!   Unless of course it is my webmail or feedreader service – then it’s practically obligatory.

Let us assume we are intelligent enough to adhere to standards and take advice from the experts.  Let us assume we all want

And of course we’d like our plugin developers, wordpress developers, tinymce developers to help us in this mission.   This research was done for my own use to determine what my plugins should do.

Summary:

  • forcing new tabs or windows is bad for usability (seriously, studies have shown it is harmful)
  • it is not recommended for accessibility
  • the methods to do it can cause invalid html
  • some folks think it doesn’t help your analytics (although one site had some thoughts on that)
  • it is not necessary… so why do it?  maybe just indicate an external link? or allow for optional js.

Who says no?

Possible reasons to force a new window on external links?

But I want to keep the user on my site…..

“Marketers love it because it allows them to link to external content without taking the reader off the page.”

This is a reasonable fear for a client to have. The user leaving the site and not being able to get back….In every single usability test I’ve done, opening external content in a new window makes this problem worse – not better.

quoted from the Stack exchange usability forum

Special cases perhaps?

  • webmail,
  • feed readers,
  • long lists of external resources.

If we need to do it, what is best way to deal with external links?

Best ways to handle external links

Indicate the external link.

See how Wikipedia  does it.  It classes links as external with a css class.  That css class is then styled with a background image.  It provides a clear visual clue as suggested here.   The css is something like:

 a.external {    background: 
    url(http://upload.wikimedia.org/wikipedia/commons/4/44/Icon_External_Link.svg") 
    no-repeat scroll right center transparent;
    padding-right: 13px;}

OR

style the rel=”external”

a[rel=external]....

read more

Wp foreign characters, Php, Creating Tables

Question Mark
Question mark graffiti by bilal-kamoon

I knocked myself around trying to figure out why my plugin was not coping with ‘foreign’, multi byte, Greek, Japanese, Chinese characters.  Those damn questions marks ‘????’ – I had it all sorted before in another plugin – what was going on here ?   I had all the multi-byte functions happening.    Then I remembered – the database tables – of course!

Default Mysql

MySQL’s default database charset is usually latin1 and  thecollation is latin1_swedish_ci.  This can vary based on server configuration.  This is usually set before wordpress is installed.

Default wordpress

WordPress usually creates it’s table with charset utf8 and collation utf8_general_ci.    You can overwrite this in the config file.

See http://codex.wordpress.org/Editing_wp-config.php#Database_character_set.

Fix your wordpress database

You can Alter the database after the fact.  This will help the plugins who haven’t figured out that many of us (you?) haven’t set up our databases as well as they could be.

ALTER DATABASE yourdb CHARACTER SET utf8 COLLATE utf8_general_ci;

You may want to fix the individual tables and fields too – phpmyadmin has the tools to edit (or use the rename – it will let you change the collation).

Plugin authors

Make life easy on your self and others when creating custom tables.  Have a look at the wordpress db schema.  Note that there is a global $charset_collate.  Use it!

 global $wpdb, $charset_collate;
if (empty($charset_collate))
    $cachecollation = ' DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci ';
else
    $cachecollation = $charset_collate;

if ($wpdb->get_var("show tables like '$table_name'") != $table_name) {
 $sql = "CREATE TABLE " . $table_name . " (
 id bigint NOT NULL AUTO_INCREMENT,
 field1 text NOT NULL,
 field2 text NOT NULL,
 PRIMARY KEY (id) )
 ".$cachecollation. ";";

read more