From 065b0df0ef2729eced6c9201be676d5431219008 Mon Sep 17 00:00:00 2001 From: Glen Whitney Date: Mon, 8 Feb 2021 10:51:28 -0800 Subject: [PATCH] feat: add an export pods view just like normal one for now --- tablepress-pods.php | 4 +- view-exportpods.php | 192 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 194 insertions(+), 2 deletions(-) create mode 100644 view-exportpods.php diff --git a/tablepress-pods.php b/tablepress-pods.php index 2300d17..e7f8aa3 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.5 +Version: 0.2.6 Author: Glen Whitney Author URI: http ://studioinfinity.org/ */ @@ -59,7 +59,7 @@ add_filter( 'tablepress_shortcode_table_default_shortcode_atts', 'playground_add_shortcode_parameter_pods' ); 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'); +add_filter( 'tablepress_load_file_full_path', 'playground_exportpods_path', 10, 3); function playground_add_shortcode_parameter_pods( $default_atts ) { $default_atts['pod_name'] = ''; diff --git a/view-exportpods.php b/view-exportpods.php new file mode 100644 index 0000000..76b899a --- /dev/null +++ b/view-exportpods.php @@ -0,0 +1,192 @@ +process_action_messages( array( + 'error_export' => __( 'Error: The export failed.', 'tablepress' ), + 'error_load_table' => __( 'Error: This table could not be loaded!', 'tablepress' ), + 'error_table_corrupted' => __( 'Error: The internal data of this table is corrupted!', 'tablepress' ), + 'error_create_zip_file' => __( 'Error: The ZIP file could not be created.', 'tablepress' ), + ) ); + + $this->add_text_box( 'head', array( $this, 'textbox_head' ), 'normal' ); + if ( 0 === $data['tables_count'] ) { + $this->add_meta_box( 'no-tables', __( 'Export Tables', 'tablepress' ), array( $this, 'postbox_no_tables' ), 'normal' ); + } else { + $this->admin_page->enqueue_script( 'export', array( 'jquery' ) ); + $this->add_meta_box( 'export-form', __( 'Export Pods Tables', 'tablepress' ), array( $this, 'postbox_export_form' ), 'normal' ); + $this->data['submit_button_caption'] = _x( 'Download Pods Export File', 'button', 'tablepress' ); + $this->add_text_box( 'submit', array( $this, 'textbox_submit_button' ), 'submit' ); + } + } + + /** + * Print the screen head text. + * + * @since 1.0.0 + * + * @param array $data Data for this screen. + * @param array $box Information about the text box. + */ + public function textbox_head( array $data, array $box ) { + ?> +

+ + +

+

+ + +
+ + +

+ 'add' ) ); + $import_url = TablePress::url( array( 'action' => 'import' ) ); + ?> +

+

add or import a table to get started!', 'tablepress' ), $add_url, $import_url ); ?>

+ + + + + + + + + + + + + + + + + + + + +
+ +
'; + } + ?> +
+ + + + ' . __( 'You can select multiple tables by holding down the “Ctrl” key (Windows) or the “Command” key (Mac).', 'tablepress' ) . ''; + } + ?> +
+ +
+ +
: + + + + +
+