• Resolved audiowarrior

    (@zonwarrior)


    Hi Robin,

    Hope you are doing well.

    Quick question: I noticed that when an email is composed (after clicking the mail share icon on a mobile device), there is a single space in front of the subject title. Why does this happen and how can I fix this?

    View post on imgur.com

    Thank you

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

    (@littlerchicken)

    Based on the image, my guess is that your setting for the email subject is empty, and the plugin is not expecting that–its behavior is to set the subject as “setting post title”, and doesn’t know to account for a potentially empty string.

    I can mark this as something to fix in a future release. If it’s something you want fixed immediately, I would recommend using the dynamic scriptlesssocialsharing_email_query_args filter (you will want to modify the subject in the array of args).

    Thread Starter audiowarrior

    (@zonwarrior)

    Hi Robin,

    I’m a bit of a layman. Where do I add this code exactly?

    change this:
    ‘subject’ => $this->email_subject() . ‘ ‘ . $this->attributes[‘title’],

    to this?:
    ‘subject’ => $this->email_subject() . ‘ ‘ . $this->[‘title’],

    Thank you

    Plugin Author Robin Cornett

    (@littlerchicken)

    No, you will need to create an entire function to use the filter to change the subject. The new code can be added to your theme’s functions.php file, or wherever you add code snippets–just make sure you have things backed up before you start tinkering.

    This code is not tested, but should do what you want–you’ll want to test and verify:

    
    add_filter( 'scriptlesssocialsharing_email_query_args', 'prefix_scriptless_modify_subject', 10, 4 );
    /**
     * If no email subject is set in the plugin settings, this
     * returns just the post title as the email subject.
     *
     * @param array  $args
     * @param string $button_name
     * @param array  $attributes
     * @param array  $setting
     * @return array
     */
    function prefix_scriptless_modify_subject( $args, $button_name, $attributes, $setting ) {
    	if ( ! empty( $setting['email_subject'] ) ) {
    		return $args;
    	}
    	$args['subject'] = $attributes['title'];
    
    	return $args;
    }
    
    Thread Starter audiowarrior

    (@zonwarrior)

    yes, I can confirm this works! thank you Robin!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Why is there a single space in an email subject?’ is closed to new replies.