Last active
May 31, 2023 16:06
-
-
Save geekontheroad/0b5b1638d88ecdfb393850c2ac5f5f50 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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