Skip to content

Instantly share code, notes, and snippets.

@dancameron
Last active December 3, 2019 15:58
Show Gist options
  • Save dancameron/2fdb29648415ea5b32be to your computer and use it in GitHub Desktop.
Save dancameron/2fdb29648415ea5b32be to your computer and use it in GitHub Desktop.
Adds a print button to the top of estimates and invoices.
/**
* Adds a print button to the top of estimates and invoices.
* @return type
*/
function si_print_button() {
// check to see if PDF view
if ( isset( $_GET['genpdf'] ) ) {
return;
}
?>
<a href="javascript:window.print()" id="print_button" class="button print_button"><?php _e( 'Print', 'sprout-invoices' ) ?></a>
<?php
}
add_action( 'si_doc_actions_pre', 'si_print_button' ); // original and slate themes
add_action( 'si_default_theme_pre_payment_button', 'si_print_button' ); //
<?php // don't add this line since it's already in your functions.php file
/**
* Adds a print button next to the pdf icon.
* @return type
*/
function si_print_button() {
if ( isset( $_GET['genpdf'] ) ) {
return;
}
?>
<a href="javascript:window.print()" id="print_button" style="height: 33px;width: 33px;float: right;margin: 8px 0 0 20px;"><svg aria-hidden="true" focusable="false" data-prefix="fal" data-icon="print" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="svg-inline--fa fa-print fa-w-16 fa-3x"><path fill="currentColor" d="M432 192h-16v-82.75c0-8.49-3.37-16.62-9.37-22.63L329.37 9.37c-6-6-14.14-9.37-22.63-9.37H126.48C109.64 0 96 14.33 96 32v160H80c-44.18 0-80 35.82-80 80v96c0 8.84 7.16 16 16 16h80v112c0 8.84 7.16 16 16 16h288c8.84 0 16-7.16 16-16V384h80c8.84 0 16-7.16 16-16v-96c0-44.18-35.82-80-80-80zM320 45.25L370.75 96H320V45.25zM128.12 32H288v64c0 17.67 14.33 32 32 32h64v64H128.02l.1-160zM384 480H128v-96h256v96zm96-128H32v-80c0-26.47 21.53-48 48-48h352c26.47 0 48 21.53 48 48v80zm-80-88c-13.25 0-24 10.74-24 24 0 13.25 10.75 24 24 24s24-10.75 24-24c0-13.26-10.75-24-24-24z" class=""></path></svg></a>
<?php
}
add_action( 'si_pdf_button', 'si_print_button', 100 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment