montreyw / Theme-Redesign-and-SEO-Overhaul

Earmilk redesign project
2 stars 0 forks source link

AddThis Sharing action converts quotes into html entities (eg, " --> &quot or #8211) #49

Closed andrebu closed 8 years ago

andrebu commented 8 years ago

AddThis Sharing action converts quotes into html entities (eg, " --> &quot or #8211)

andrebu commented 8 years ago

It's in this file: sftp://earmilk//home/www-data/earmilk/public/wp-content/plugins/addthis-all/backend/AddThisSharingButtonsFeature.php

Line 188 needs to be commented out. It's like this: $title = htmlspecialchars($title); but needs to be changed to this: // $title = htmlspecialchars($title)

Until they come up with a solution, you'll prolly have to keep fixing this once the plugin updates.


This file here:

screen shot 2016-04-24 at 7 12 34 pm

This line at 188 needs to be commented out (line 189 was added by me):

screen shot 2016-04-24 at 7 12 27 pm

Result (don't know why ' instead of "):

screen shot 2016-04-24 at 7 12 14 pm
andrebu commented 8 years ago

Not knowing the exact problem (ie, where the encoding/decoding goes wrong) I provide some alternate solutions to try in case simply commenting out the plugin's line ends up unsatisfactory in some case.

Using one of these, either before or after $title = htmlspecialchars($title); (depending on the situation/bug) should resolve any new bugs with $title htmlencoding: $title = html_entity_decode($title, ENT_COMPAT, 'UTF-8'); OR $title = htmlspecialchars_decode($title);

IE:

            ...
            $title = $this->applyFilter($this->filterNamePrefix . 'title', $title, $track);
            $title = htmlspecialchars($title);
            $title = html_entity_decode($title, ENT_COMPAT, 'UTF-8');
            return $title;
            ...

OR

            ...
            $title = $this->applyFilter($this->filterNamePrefix . 'title', $title, $track);
            $title = htmlspecialchars($title);
            $title = htmlspecialchars_decode($title);
            return $title;
            ...

Current State after Andre-fix

            ...
            $title = $this->applyFilter($this->filterNamePrefix . 'title', $title, $track);
            //$title = htmlspecialchars($title);
            //$title = html_entity_decode($title, ENT_COMPAT, 'UTF-8');
            //$title = htmlspecialchars_decode($title);
            //$title = 'Hi Montrey, this plugin sucks :/';
            return $title;
            ...
andrebu commented 8 years ago

Wrote a filter to "permanently" solve this (by permanently, I mean that if the issue remains the same, you won't have to do any editing or fixing when the AddThis-All plugin is updated. If the issue changes or becomes exacerbated by an update or something else, this filter will prolly stop gettin the job done.):

// ---------------------------------------------------------------------------------------------------- 
// Decode htmlentities in AddThis Share titles back into their appropriate spcial characters -- Andre
// ---------------------------------------------------------------------------------------------------- 
function addthis_sharing_quotes_fix( $title ) {
    $title = htmlspecialchars_decode($title);
    return $title;
}
add_filter( 'addthis_sharing_buttons_title', 'addthis_sharing_quotes_fix', 10, 2 );