Just recently I introduced WP-Table Reloaded Extensions, small code snippets that add further functions to the plugin by using the provided “Plugin Actions” and “Plugin Filters”.
The first such Extension that I’m going to present here, is an Automatic Converter for URLs to Links.
In general, you’ll need to manually enter the HTML for a link (something like <a href="http://www.example.com">My Link</a>) into a cell or use the included Wizard that will ask you for the URL and the link text and then generates the HTML for you. This is my recommended way and for most needs it works fine. It also allows for the most flexibility, because you have all freedom to alter or extend that HTML code as you like, e.g. by adding further attributes or a different link text.
Unfortunately it an be a real hassle and a lot of work, if all you want to achieve is, to make URLs you enter “clickable”, i.e. to make them valid HTML links. That can for example be the case when you import a table from a file, because in most cases URLs are not exported as HTML links by a program but simply as the plain URL in text form.
And this is were this Extension kicks in. When a table is shown in a post or page (by using the corresponding Shortcode in it), the extension will basically loop through all cells of that table and check if there’s an URL (for www, ftp or an email address) somewhere. And if it finds one, it will replace the URL with a complete HTML link to that URL that can be clicked by the visitor. The good thing: If there already was a complete HTML link it will be left intact.
Example:
A cell with the content “http://www.example.com” will automatically be converted to a clickable link: “http://www.example.com“.
And here is the code:
/** * Converts URLs (www, ftp, and email) in table cells to full HTML links * @author Tobias Baethge * @see http://tobias.baethge.com/2009/12/extension-1-url-to-link-conversion/ */ function wp_table_reloaded_url_link_converter( $cell_content ) { return make_clickable( $cell_content ); } add_filter( 'wp_table_reloaded_cell_content', 'wp_table_reloaded_url_link_converter' );
This code just needs to be copied into the file “wp-table-reloaded-extensions.php”, which needs to be created according to these instructions (after the Plugin Header comment, but before the closing PHP bracket ?>). That’s it! :-)
If you like this series of Extensions, I’m happy about any feedback, and especially about further suggestions!


Hi Tobias,
I hope you would consider publishing a complete list of the filters available in WP-Table Reloaded with short descriptions. This could be a post in th Extension series and/or also included in plugin’s documentation.
Best,
Lembit
Hi Lembit,
yes, I will publish such a list in the documentation, when version 1.6 is released. The Filters are already in the list, just the descriptions will take some time :-)
Regards,
Tobias
Nice plugin! I made this extension work, but it will not make links open in a new window. Is the option “open links in new window” in the “Plugin Options” only applicable for original links?
Can it be done for this extension?
Hi,
thanks for your comment!
You are right, that checkbox is only applicable to links created with the little wizard on the “Edit” screen. It does not influence the automatic conversion from this Extension.
I checked the WP source code again, unfortunately there’s no easy way to have the necessary code inserted there by an Extension.
But all in all, I actually recommend to not make links open in a new window by default. This should be the choice of your site visitors, who can easily open the link in a new window/tab in their browsers, if they want to. If they don’t want to, you should not force them.
Best wishes,
Tobias
This is fantastic Tobias.
I am still trying to get my head around them though.
I am hoping to be able to get a plugin that will allow me to create a link to Google Maps, taking data from several table rows.
I currently have:
id, firstname, lastname, address1, address2, city, postcode, state, country, email, websiteimported from csv.
In my own custom coded PHP, I simply do:
(I hope this copies through when I save).
Is there a way to be able to wrap this sort of output, similar to finding a href in the tables?
Any response is appreciated…
Hi Ryan,
thanks for your comment.
Your desired feature is not integrated in the plugin natively, but you could write your own extension to achieve something like this.
It sounds as if you want to use a WP-Table Reloaded table as the data source for that idea, instead of a mySQL table or something similar.
I recommend taking a look at the code in this comment. There, I present a way to load a table, and pick a single cell from it. You would just need to modify that could a little, and instead of picking a single cell, you would loop through the
$tablearray and can perform your echo there.Hope this helps!
Best wishes,
Tobias
Thanks Tobias, that is fantastic.
I am reviewing your discussion on that page, hopefully I’ll be able to get it to work. If not, this is still awesome.
Thanks again!