<?php
/*
Plugin Name: TablePress Extension: Automatic URL conversion
Plugin URI: https://tablepress.org/extensions/automatic-url-conversion/
Description: Custom Extension for TablePress to automatically make URLs (www, ftp, and email) in table cells clickable
Version: 1.3
Author: Tobias Bäthge
Author URI: https://tobias.baethge.com/
*/
/*
 * Usage and possible parameters:
 *
Membership PackageIndustry Discount Membership CardIndustry ReferralsDiscounted Training ProgramsDiscounted Event TicketsBusiness Directory ListingQuarterly E-Magazine2 Hour Import/Export Advisory Session2 Hour
Freight & Logistics Advisory Session
2 Hour
Warehousing & Distribution Advisory Session
Discounted
Consultancy
Services
YEARLY PRICE
Student$ 55.00
Professional Individual$ 110.00
Small Business
(upto $20m T/O)

1 X 2 hour session

$ 550.00
Large Business
(over $20m T/O)
$ 1,650.00
 *
 * automatic_url_conversion: Whether URLs shall be made clickable.
 * automatic_url_conversion_new_window: Whether http(s) links shall open in a new window.
 * automatic_url_conversion_rel_nofollow: Whether http(s) links shall get the `nofollow` attribute.
 */
add_filter( ‘tablepress_table_output’, ‘tablepress_auto_url_conversion’, 10, 3 );
add_filter( ‘tablepress_shortcode_table_default_shortcode_atts’, ‘tablepress_add_shortcode_parameter_auto_url_conversion’ );
/**
 * Add Extension’s parameters as a valid parameters to the [table “” not found /]
Shortcode.
 */
function tablepress_add_shortcode_parameter_auto_url_conversion( $default_atts ) {
$default_atts[‘automatic_url_conversion’] = false;
$default_atts[‘automatic_url_conversion_new_window’] = false;
$default_atts[‘automatic_url_conversion_rel_nofollow’] = false;
return $default_atts;
}
/**
 * Convert URLs to links, if Shortcode parameter is set,
 * add the `target` attribute in http(s):// links,
 * or add the `rel` attribute, if the Shortcode parameter is set.
 */
function tablepress_auto_url_conversion ( $output, $table, $render_options ) {
if ( $render_options[‘automatic_url_conversion’] ) {
$output = make_clickable( $output );
}
if ( $render_options[‘automatic_url_conversion_new_window’] && $render_options[‘automatic_url_conversion_rel_nofollow’] ) {
$output = str_replace( ‘<a href=”http’, ‘<a target=”_blank” rel=”nofollow” href=”http’, $output );
} elseif ( $render_options[‘automatic_url_conversion_new_window’] ) {
$output = str_replace( ‘<a href=”http’, ‘<a target=”_blank” href=”http’, $output );
} elseif ( $render_options[‘automatic_url_conversion_rel_nofollow’] ) {
$output = str_replace( ‘<a href=”http’, ‘<a rel=”nofollow” href=”http’, $output );
}
return $output;
}
PHP Code Snippets Powered By : XYZScripts.com