Support

Home Forums Event Espresso Premium Edit CSS of email messages

Edit CSS of email messages

Posted: March 20, 2015 at 5:55 am


adasch

March 20, 2015 at 5:55 am

Hi,
I try to modify the styling of email messages a bit. I found this posting from Dean: https://eventespresso.com/topic/custom-styles-to-email-message-and-invoice/#post-99565

I think the file names and locations have changed a bit, so my code which I added to my functions.php looks like this:

//assuming you have the files located in wp-content/uploads/
function ee_inline_css_swap( $url, $type ) {
  $upload_dir = wp_upload_dir();
      switch ( $type ) {
    case 'preview' :
      $url =  $upload_dir['baseurl'] . '/email_preview_default.css';
      break;
 
    case 'wpeditor' :
      $url =  $upload_dir['baseurl'] . '/email_wpeditor_default.css';
      break;
 
    default :
      $url =  $upload_dir['baseurl'] . '/email_main_default.css';
      break;
  }
 
  return $url;
}
add_filter( 'FHEE__EE_Email_Messenger__get_inline_css_template__css_url', 'ee_inline_css_swap', 10, 2 );

I copied three files to wp-content/uploads/
email_main_default.css
email_preview_default.css
email_wpeditor_default.css

I made some changes in all three files (like .content {max-width:900px}) and it works fine with the preview! However the email to the reistrant has standard values – it ignores my changes within email_main_default.css.

Does anyone know why this is?


adasch

March 23, 2015 at 1:16 pm

any ideas?


Lorenzo Orlando Caum

  • Support Staff

March 24, 2015 at 9:17 am

Hi, could you try this updated function?

http://developer.eventespresso.com/hooks/fhee__ee_messages_template_pack__get_variation/

The one that you are using was deprecated:

http://developer.eventespresso.com/hooks/fhee__ee_email_messenger__get_inline_css_template__css_url/


Lorenzo


adasch

March 24, 2015 at 2:07 pm

Thanks Lorenzo,
so I put this code in my functions.php, right? Where am I supposed to put the mofified CSS files?

There is a line $new_url = get_stylesheet_directory_uri() . '/new_html_variation.css'; so where is my stylesheet_directory?
I’m using a child theme if this is relevant but there is no extra css folder in it!

thanks again!


Lorenzo Orlando Caum

  • Support Staff

March 24, 2015 at 2:40 pm

Hi, you can update it to use your uploads folder or another location of your choice.

I was trying to point out that the existing filter was deprecated so you would need to use the newer one:

FHEE__EE_Email_Messenger__get_inline_css_template__css_url –> FHEE__EE_Messages_Template_Pack__get_variation


Lorenzo


adasch

March 24, 2015 at 3:36 pm

Hi again.
Sorry, I just don’t understand you right ๐Ÿ™

I understood, that the function I was using is old and I should replace it to a new one. In you last posting it seems that I just have to replace the last line of the function in my first posting. Is that right? When I do that, I get lots of errors. So I guess I have to replace the whole function with the one found in here:
http://developer.eventespresso.com/hooks/fhee__ee_messages_template_pack__get_variation/

So I put the following code in my functions.php

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;
	}

	//for this example we'll just filter the wpeditor for this variation
	if ( $type != 'wpeditor' ) {
		return $variation_path;
	}

	$new_url = get_stylesheet_directory_uri() . '/new_html_variation.css';
	return $new_url;
}
add_filter( 'FHEE__EE_Messages_Template_Pack__get_variation', 'ee_modify_html_variation', 10, 8 );

What next? Where should I put my css files?

I’m sorry for bothering you again :-/


Josh

  • Support Staff

March 25, 2015 at 5:28 pm

You put your css file (in this case new_html_variation.css) directly into your child theme.

get_stylesheet_directory_uri() returns the URI for the current theme or if active, the child theme.


adasch

March 27, 2015 at 4:11 am

Hi Josh,
unfortunately this is not working for me. Both, the preview and the actual email ignore my custom css file completely ๐Ÿ™


Josh

  • Support Staff

March 27, 2015 at 11:04 am

Hi there,

Your code will only affect the editor because you have this check:

//for this example we'll just filter the wpeditor for this variation
if ( $type != 'wpeditor' ) {
 return $variation_path;
}


adasch

March 27, 2015 at 11:35 am

well, I thought that means if $type is anything BUT "wpeditor"
and not if $type IS wpeditor

??


Josh

  • Support Staff

March 27, 2015 at 1:20 pm

You’re correct, it does mean that. Which means you’re returning the $variation_path instead of $new_url in every condition except when it’s the wpeditor.

I think you want to return the $new_url, right?

The support post ‘Edit CSS of email messages’ 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