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 | |
// As a prerequisite, there are stored each user ID to the "user_id" column (as numric type) in the "your_table_name" as target table. | |
// (対象テーブル「your_table_name」には「user_id」カラム(数値型)にユーザーIDが格納されているという前提) | |
function custom_filter_get_data_sql( $sql, $table_name, $sql_clauses ) { | |
if ( ! is_admin() && "your_table_name" === $table_name ) { | |
$_current_user_id = 0; // For guest user | |
if ( is_user_logged_in() ) { | |
$current_user = wp_get_current_user(); | |
$_current_user_id = $current_user->ID; |
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 | |
function table_layout_fixed( $component_options, $shortcode_name, $table ){ | |
if ( 'cdbt-view' === $shortcode_name && 'your_table_name' === $table ) { | |
$component_options['customAfterRender'] = <<<EJS | |
$('#'+options.tableId).css({tableLayout:'auto'}).parent('.panel-table-wrapper').kinetic('detach'); | |
EJS; | |
} | |
return $component_options; | |
} |
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 | |
function table_layout_fixed( $component_options, $shortcode_name, $table ){ | |
if ( 'cdbt-view' === $shortcode_name && 'your_table_name' === $table ) { | |
$component_options['customAfterRender'] = <<<EJS | |
$('#'+options.tableId).css({tableLayout:'auto'}).parent('.panel-table-wrapper').kinetic('detach'); | |
EJS; | |
} | |
return $component_options; | |
} |
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
/** | |
* Return as an object by parsing the query string of the current URL | |
*/ | |
$.QueryString = (function(queries) { | |
if ('' === queries) { return {}; } | |
var results = {}; | |
for (var i=0; i<queries.length; ++i) { | |
var param = queries[i].split('='); | |
if (param.length !== 2) { continue; } | |
results[param[0]] = decodeURIComponent(param[1].replace(/\+/g, ' ')); |
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'] ) { |
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 | |
// You should be optimize the variables of "$target_table" and "$target_column" in proportion to your table structure. | |
function cdbt_custom_datetime_format( $columns, $shortcode_name, $table ) { | |
$target_table = 'your_table_name'; | |
$target_column = 'datetime_column_name'; | |
if ( $target_table === $table ) { | |
foreach ( $columns as $_i => $_column ) { | |
if ( $target_column === $_column['property'] ) { | |
$_custom_column = sprintf( 'convert_datetime(rowData["%s"], ["%s"])', $target_column, 'F j, Y' ); |
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 | |
// In the variables of "$target_tables", "$narrow_column", "$narrow_keywords", you should be optimized by your environment and project. | |
function custom_filter_sql( $sql, $table_name, $sql_clauses ) { | |
$target_tables = [ 'your_table_name' ]; | |
$narrow_column = 'specific_column_name'; | |
$narrow_keywords = [ 'keyword1', 'keyword2', 'keyword3' ]; | |
if ( in_array( $table_name, $target_tables ) ) { | |
if ( is_array( $sql_clauses[1] ) ) { | |
// Narrowing is find_data() |
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 | |
// Note: this code will be enabled since the CDBT plugin version 2.1.33. | |
function add_filtered_column_sql( $sql, $table_name, $sql_clauses ) { | |
$target_tables = [ 'your_table_name' ]; | |
$filter_date_column = 'date_type_column'; // Column name that you want to filter by the filtering dropdown box | |
if ( in_array( $table_name, $target_tables ) && strpos( $sql_clauses[0], $filter_date_column ) !== false ) { | |
$select_clause = $sql_clauses[0] .',CAST(YEAR(`'. $filter_date_column .'`) AS CHAR) AS `year`'; // "year" is alias column for filtering | |
$_overwrite_sql = <<< SQL | |
SELECT %s |
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 | |
/** | |
* Function to aggregate the value of the enum type | |
* | |
* @param string $target_table [requied] | |
* @param string $userid_col [requied] | |
* @param string $enum_col [required] | |
* @param string $period [optional] It must be a target date string, ex."2016-06-23" | |
*/ | |
function enum_aggregate( $target_table, $userid_col, $enum_col, $period=null ) { |
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 | |
/** | |
* The markup content of frontend (as post content): | |
* --- | |
* <form method="get"> | |
* <input type="search" name="search_keyword" value=""> | |
* <button type="submit">Search</button> | |
* </form> | |
* [cdbt-view table="your_table_name" narrow_keyword="ID:0"] | |
* --- |
OlderNewer