Add an "Export Pods Table" action to the TablePress menu #6
@ -3,7 +3,7 @@
|
||||
Plugin Name: TablePress Extension: Pods tables
|
||||
Plugin URI: https://code.studioinfinity.org/glen/tablepress-pods
|
||||
Description: Custom Extension for TablePress to incorporate Pods information in tables
|
||||
Version: 0.2.14
|
||||
Version: 0.2.15
|
||||
Author: Glen Whitney
|
||||
Author URI: http://studioinfinity.org/
|
||||
*/
|
||||
@ -194,15 +194,23 @@ function playground_handle_exportpods () {
|
||||
if ( ! current_user_can( 'tablepress_export_tables' ) ) {
|
||||
wp_die( __( 'Sorry, you are not allowed to access this page.', 'default' ), 403 );
|
||||
}
|
||||
if ( empty( $_POST['export'] ) || ! is_array( $_POST['export'] ) ) {
|
||||
TablePress::redirect( array( 'action' => 'export', 'message' => 'error_export' ) );
|
||||
} else {
|
||||
$export = wp_unslash( $_POST['export'] );
|
||||
}
|
||||
|
||||
/* Reset the nonce for forwarding the action */
|
||||
$_REQUEST['_wpnonce'] = wp_create_nonce( TablePress::nonce( 'export' ) );
|
||||
|
||||
/* Temporarily set a filter on exporting */
|
||||
add_filter( 'tablepress_export_data', 'playground_expand_export_pod', 10, 4);
|
||||
do_action( 'admin_post_tablepress_export' );
|
||||
remove_filter( 'tablepress_export_data', 'playground_expand_export_pod', 10 );
|
||||
/* Set up the filter using the pod params */
|
||||
$pod_name = $export['pod_name']
|
||||
$filter = function( $data, $tab, $fmt, $delim ) use ($pod_name) {
|
||||
return $data . "\nExpanded by " . $pod_name;
|
||||
}
|
||||
|
||||
function playground_expand_export_pod ( $data, $tab, $fmt, $delim ) {
|
||||
return $data . "\nKilroy was here\n";
|
||||
/* Temporarily set a filter on exporting */
|
||||
add_filter( 'tablepress_export_data', $filter, 10, 4);
|
||||
do_action( 'admin_post_tablepress_export' );
|
||||
remove_filter( 'tablepress_export_data', $filter, 10 );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user