0

I have build a custom WordPress admin page. In it i'm extending the wp-list-table class like demonstrate here https://premium.wpmudev.org/blog/wordpress-admin-tables/.

I have a form that sets some arguments to filter the results that will be showed in the list.

It works great.

But I want to add a button to download the filtered data.

like to see here : enter image description here

The button is outputed in the extra_tablenav function.

public function extra_tablenav($which) {
        if ( $which == "top" ){

            $data = $this->generate_WP_Query();

            if( isset( $data ) ) {
                submit_button( 'Download the csv', 'primary', 'download_stock_csv' );

                global $plugin_page;

                if ( $plugin_page == 'dw-custom-stock-export' && isset( $_POST['download_stock_csv'] ) ) {
                    $this->generate_stock_report_csv();
                }
            }

         }
         if ( $which == "bottom" ){
            //The code that goes after the table is there
         }
    }

But I always get a empty query.

Anybody got an idea how to do this?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.