Support

Home Forums Event Espresso Premium Invoice custom CSS appears at the bottom and crashes DOMPdf

Invoice custom CSS appears at the bottom and crashes DOMPdf

Posted: August 29, 2017 at 12:48 pm

Viewing 2 reply threads


sara.bosman

August 29, 2017 at 12:48 pm

I added custom CSS with this hook:

add_action( 'AHEE__EE_Pdf_messenger__enqueue_scripts_styles', function() {
  wp_enqueue_style( 'messages-css', get_template_directory_uri() . '/css/messages.css' );
});

However, when I view the invoice in HTML, the CSS link appears at the bottom, right after </body>:

...
</body>
<link rel='stylesheet' id='messages-css-css'  href='.../css/messages.css... />
</html>

This is not a huge problem in HTML, but when I try to download the PDF, DOMPdf generates an error and I’m thrown back to the home page. The problem disappears when I comment this line in class EE_Pdf_messenger, line 302:

301 protected function _deregister_wp_hooks() {
 302  // remove_all_actions('wp_head'); -> comment this
 303  ...

Any idea?

(using EE4 4.9.39)


Josh

  • Support Staff

August 29, 2017 at 1:52 pm

That particular hook isn’t well suited for overriding CSS. I can recommend using a filter hook instead where you can swap in your custom stylesheet instead of the default one. Example code follows:

function ee_modify_html_variation( 
  $variation_path, 
  $messenger, 
  $message_type, 
  $type, 
  $variation, 
  $file_extension, 
  $url, 
  EE_Messages_Template_Pack $template_pack 
) {
  if ( $messenger != 'html' ) {
    return $variation_path;
  }
  if ( $message_type != 'invoice' ) {
    return $variation_path;
  }
  if ( $type != 'main' ) {
    return $variation_path;
  }
  $new_url = get_stylesheet_directory_uri() . '/css/messages.css';
  return $new_url;
}
add_filter( 
  'FHEE__EE_Messages_Template_Pack__get_variation', 
  'ee_modify_html_variation', 
  10, 
  8 
);


sara.bosman

August 29, 2017 at 2:14 pm

Thanks, that works. The action hook sounded tempting though 😉

Viewing 2 reply threads

The support post ‘Invoice custom CSS appears at the bottom and crashes DOMPdf’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso