Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save geekontheroad/0b5b1638d88ecdfb393850c2ac5f5f50 to your computer and use it in GitHub Desktop.
Save geekontheroad/0b5b1638d88ecdfb393850c2ac5f5f50 to your computer and use it in GitHub Desktop.
<?php
/**
* Simple function to add a download PDF button to the Projectopia invoice overview
*
* @author Johan dhollander
* @link https://geekontheroad.com
* **/
function gotr_add_download_pdf_link_to_row_actions($actions, $post) {
if ($post->post_type === 'cqpim_invoice') {
//build invoice url
$href = esc_url(get_admin_url() . "post.php?post=".$post->ID ."&action=edit&download_pdf=1");
//full html
$download_link = sprintf('<a href="%s" download target="_blank">%s</a>', $href, esc_html__("Download PDF", "projectopia"));
//add to actions
$actions["download-pdf"] = $download_link;
}
return $actions;
}
add_filter('post_row_actions', 'gotr_add_download_pdf_link_to_row_actions', 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment