From 30d8b4cd55d4e8503d64b98cddf215be7c498760 Mon Sep 17 00:00:00 2001 From: Glen Whitney Date: Mon, 8 Feb 2021 12:06:36 -0800 Subject: [PATCH] fix: add the data needed by the exportpods action --- tablepress-pods.php | 23 ++++++++++++++++++++++- view-exportpods.php | 4 ++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/tablepress-pods.php b/tablepress-pods.php index e7f8aa3..c7369d0 100644 --- a/tablepress-pods.php +++ b/tablepress-pods.php @@ -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.6 +Version: 0.2.7 Author: Glen Whitney Author URI: http ://studioinfinity.org/ */ @@ -60,6 +60,7 @@ add_filter( 'tablepress_shortcode_table_default_shortcode_atts', add_filter( 'tablepress_table_raw_render_data', 'playground_expand_pod', 10, 2 ); add_filter( 'tablepress_admin_view_actions', 'playground_add_export_pod_action'); add_filter( 'tablepress_load_file_full_path', 'playground_exportpods_path', 10, 3); +add_filter( 'tablepress_view_data', 'playground_exportpods_data', 10, 2); function playground_add_shortcode_parameter_pods( $default_atts ) { $default_atts['pod_name'] = ''; @@ -84,6 +85,26 @@ function playground_exportpods_path( $fullpath, $filename, $directory ) { return plugin_dir_path( __FILE__ ) . $filename; } +function playground_exportpods_data( $data, $act ) { + if ($action !== 'exportpods') return $data; + // Load all table IDs without priming the post meta cache, as table options/visibility are not needed. + $data['table_ids'] = TablePress::$model_table->load_all( false ); + $data['tables_count'] = TablePress::$model_table->count_tables(); + if ( ! empty( $_GET['table_id'] ) ) { + $data['export_ids'] = explode( ',', $_GET['table_id'] ); + } else { + // Just show empty export form. + $data['export_ids'] = array(); + } + $exporter = TablePress::load_class( 'TablePress_Export', 'class-export.php', 'classes' ); + $data['zip_support_available'] = $exporter->zip_support_available; + $data['export_formats'] = $exporter->export_formats; + $data['csv_delimiters'] = $exporter->csv_delimiters; + $data['export_format'] = ( ! empty( $_GET['export_format'] ) ) ? $_GET['export_format'] : false; + $data['csv_delimiter'] = ( ! empty( $_GET['csv_delimiter'] ) ) ? $_GET['csv_delimiter'] : _x( ',', 'Default CSV delimiter in the translated language (";", ",", or "tab")', 'tablepress' ); + return $data; +} + function playground_expand_pod( $table, $render_options) { if (empty($render_options['pod_name'])) return $table; $pod_params = array('limit'=>-1); diff --git a/view-exportpods.php b/view-exportpods.php index 76b899a..0672b6e 100644 --- a/view-exportpods.php +++ b/view-exportpods.php @@ -60,11 +60,11 @@ class TablePress_ExportPods_View extends TablePress_View { public function textbox_head( array $data, array $box ) { ?>

- +

- +