• Resolved Anders Carlén

    (@anderscarlen)


    Hi Robin,

    and thanks for this plugin! I saw it, and read your blog post, but almost decided on another solution because I didn’t think it included the Email option. So glad that I installed the plugin just to see how you included the icons.

    Anyway:
    I suspect there is a filter or something that we can use to localize the body text of the email?
    Would you mind showing me an example of how that could be added?

    Also, and possibly related: There seem to be two stray “+” signs showing up just before the link in both the email subject and the email body. It’s possible you wanted to add them before the actual link for some reason, but I am guessing that the function to replace spaces in the URL is a bit overzealous?

    https://www.ads-software.com/plugins/scriptless-social-sharing/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Robin Cornett

    (@littlerchicken)

    Yes, you can filter the body text of the email with scriptlesssocialsharing_email_body. So a super simple example would be something like:

    add_filter( 'scriptlesssocialsharing_email_body', 'prefix_change_email_body' );
    function prefix_change_email_body() {
    	return 'whatever you want to say here';
    }

    (Please practice safe coding, back up your files, etc. etc.)

    Adding data to email links is a little hairy, and different email programs seem to take the same data and do totally different things with it. I’m not seeing a stray + sign in my tests, but Google seems to handle email links more gracefully than some others. Can you share with me what email program you’re using, if you don’t mind? I see something I can try, at least, and see if it helps.

    Thread Starter Anders Carlén

    (@anderscarlen)

    Thanks for the filter example! Works great.

    for the + characters:
    I am using the native Mail app on Mac OS X.

    I did manage to get rid of the plus sign in the subject line, by altering this line

    $buttons['email']['url'] = sprintf( 'mailto:?body=%s+%s&subject=%s+%s', $attributes['email_body'], $attributes['permalink'], $attributes['email_subject'], $attributes['title'] );

    which is coming from includes/class-scriptlesssocialsharing-output.php` around line 135.
    Edit: Doh! Seeing the code in a different format allowed me to see the plus sign in the body part of the code above. I don’t know what other effects it will have if you remove them though….

    https://snag.gy/UjZawg.jpg

    Plugin Author Robin Cornett

    (@littlerchicken)

    I would try changing it to use empty spaces instead of the + signs, like this:

    $buttons['email']['url'] = sprintf( 'mailto:?body=%s %s&subject=%s %s', $attributes['email_body'], $attributes['permalink'], $attributes['email_subject'], $attributes['title'] );

    Since the mail app is correctly converting the other + signs, which are replacing spaces. If you try that and it works for you, would you be willing to report back? I can make sure to include it in the next release.

    Thread Starter Anders Carlén

    (@anderscarlen)

    Yes, it seems to be working fine on the native Mail App in Mac OSX at least. Haven’t tried any other setups though.

    Would you like to get a swedish translation file to include for the next release? I only translated the front end stuff, like the email string and the default subject and body stuff.

    Plugin Author Robin Cornett

    (@littlerchicken)

    Fantastic, thank you–I’ll make sure that change is in the next release, so you can update safely.

    I would love to have any and all translations, so yes please! I think the translations are all done on the repository now, so you can submit them here. Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Filter to customize email body?’ is closed to new replies.