Here's my problem I'm developing a plugin with the use of plugin boilerplate.

I need to add a functionality that allows users to create a PDF from the data they're currently viewing.

I've created a shared class for this purpose in the boilerplate with the functions.

public function generate_reservation($id){

    $result = R::load('cmentary',$id);
    // not yet finished
    $dompdf = new DOMPDF();
    $dompdf->load_html($chain, 'UTF-8');
    $dompdf->set_paper('a4', 'portrait'); 


  public function generate (){


I'm using external tables for the purpose of this plugin with the RedBean class.

The PDF file is created from the data located in those external tables.

In the front end and back end i would like to create and address that would allow to access this generate_reservation method and print out the PDF

so lets assume the addresses

http://host/print_pdf?id=3 or http://host/?action=print_pdf&id=12

I'm sorry if this has been covered but I could not find a solution (maybe wrong question asked?)


OK. So the solution for now is to add an action to the admin_post method in the boilerplate

$this->loader->add_action( 'admin_post_generate_reservation', $plugin_shared, 'generate_reservation_file' );

and then in the shared class

  public function generate_reservation_file(){
    //code here


the link in the front and backend

<a href="<?php echo esc_url( admin_url('admin-post.php') ); ?>?action=generate_reservation&id=<?php echo $_GET['profil'] ?>" target="_blank"><strong>text</strong></a>

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.