Skip to content

Instantly share code, notes, and snippets.

@soderlind
Last active August 29, 2015 14:10
Show Gist options
  • Save soderlind/1423bb72bc5ec85b6d8a to your computer and use it in GitHub Desktop.
Save soderlind/1423bb72bc5ec85b6d8a to your computer and use it in GitHub Desktop.
<?php
$tables = array();
$m = TablePress::load_model( 'table' );
$ids = $m->load_all( true, false );
foreach ($ids as $id) {
$table = $m->load( $id );
$tables[$table['id']] = $table['name'];
}
@TobiasBg
Copy link

Here's a simpler and more robust version:

$tables = array();
$table_ids = TablePress::model_table->load_all( true, false );
foreach ( $table_ids as $table_id ) {
    $table = TablePress::model_table->load( $table_id, false, false );
    // Skip tables that could not be loaded properly.
    if ( ! is_wp_error( $table ) ) {
        $tables[ $table_id ] = $table['name'];
    }
}

@soderlind
Copy link
Author

Isn't working Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment