Created
October 22, 2024 07:44
-
-
Save santanup789/acce5be7b8f6e4b10ba02bdb7ad1656f to your computer and use it in GitHub Desktop.
From Tablepress wordpress plugin get the time of the latest modified table
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
//With the help of this existing code block inside the plugin https://github.com/TablePress/TablePress/blob/ea2ecc02d3b69925b7322dd195f1a32898b59c38/classes/class-import.php#L375-L382 | |
<?php | |
function column_table_last_modified() { | |
$existing_tables = array(); | |
// Load all table IDs and names for a comparison with the file name. | |
$table_ids = TablePress::$model_table->load_all( false ); | |
foreach ( $table_ids as $table_id ) { | |
// Load table, without table data, options, and visibility settings. | |
$table = TablePress::$model_table->load( $table_id, false, false ); | |
if ( ! is_wp_error( $table ) ) { | |
$existing_tables[ $table['name'] ] = $table['id']; // Attention: The table name is not unique! | |
$lates_modified_table[] = strtotime(do_shortcode('[table-info id='.$table['id'].' field=last_modified /]')); | |
} | |
} | |
rsort($lates_modified_table); | |
echo '<pre>'; print_r($lates_modified_table[0]); echo '</pre>'; | |
echo date('d M Y H:i:s',$lates_modified_table[0]); | |
} | |
add_shortcode('tablepress_query', 'column_table_last_modified'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment