Friday, July 15, 2022
HomeWordPress Developmentplugin improvement - Downloading File by way of headers doesnt work

plugin improvement – Downloading File by way of headers doesnt work


public perform handle_bulk_action( $redirect_url, $motion, $post_ids ){
        $redirect_url = remove_query_arg( 'export', $redirect_url );
        if( $motion == 'export' ){
            $redirect_url = add_query_arg( 'export', $post_ids, $redirect_url ); 
            $str = "";
            foreach( $post_ids as $id ){
                $str .= get_post_string( $id );
            }
    //HERE
            add_action( 'plugins_loaded', perform () {
                header( 'Content material-Disposition: attachment; filename=file.txt' );
                header( 'Content material-type: utility/txt' );
                header( 'Pragma: no-cache' );
                header( 'Expires: 0' );
                echo $str;
                exit();
            });
        }
        return $redirect_url;
    }

Hi there – that is our code, which we’re desperately not attending to work. A file is to be downloaded by performing a bulk motion. At remark ‘//Right here‘ the content material of the variable $str is appropriate! We’re grateful for any assist – it ought to solely work in the long run and doesn’t essentially need to be a header answer 😀

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments