Created
June 7, 2016 03:33
-
-
Save ka215/42d7ea0ac94cdd893091c1545b0dc00f to your computer and use it in GitHub Desktop.
You should use this filter hook code for the Custom DataBase Tables if you want to be able to click the specific column value that stored the strings of url at the time of using shortcode. Also this filter is enable since plugin version 2.x.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Please insert this code to as like your theme's "functions.php". | |
// Note: you should be modified variable of "$target_table" and "$url_column" in this code. | |
function cdbt_custom_clickable_url( $columns, $shortcode_name, $table ) { | |
$target_table = 'string'; // Your table name that you want to filter. | |
$url_column = 'varchar'; // This column name should be stored the url strings, and column type is "varchar". | |
if ( $target_table === $table ) { | |
foreach ( $columns as $_i => $_column ) { | |
if ( $url_column === $_column['property'] ) { | |
$_custom_column = sprintf( 'rowData.%1$s != "" ? $("<a/>").attr("href",_.unescape(rowData.%1$s)).attr("target","_blank").text(_.unescape(rowData.%1$s)) : rowData.%1$s', $url_column ); | |
$columns[$_i]['customColumnRenderer'] = $_custom_column; | |
} | |
} | |
} | |
return $columns; | |
} | |
add_filter( 'cdbt_shortcode_custom_columns', 'cdbt_custom_clickable_url', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment