From baa2feba90c7395a0099bac488d55071322ef9af Mon Sep 17 00:00:00 2001 From: John Watkins Date: Thu, 30 Jan 2020 16:59:32 -0600 Subject: [PATCH] Avoid get_the_title for tweet content because of special characters --- includes/utils.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/includes/utils.php b/includes/utils.php index 505debfe..c34ae53d 100644 --- a/includes/utils.php +++ b/includes/utils.php @@ -232,8 +232,10 @@ function already_published( $post_id ) { * @return string */ function get_tweet_body( $post_id ) { - - $body = sanitize_text_field( get_the_title( $post_id ) ); + // Use $post->post_title instead of get_the_title( $post_id ) because the latter may introduce texturized characters + // that Twitter won't decode. + $post = get_post( $post_id ); + $body = sanitize_text_field( $post->post_title ); // Only if. $text_override = get_autoshare_for_twitter_meta( $post_id, TWEET_BODY_KEY );