Use class constant “url” in method ‘display_share_markup’
-
I don’t know if this plugin is still being maintained, but if so, I hope you can make a couple of small changes to allow filtering of the output URL. Everything else is pretty well thought-through, so this may just have been an oversight?
These changes are in
class-naked-social-share-buttons.php.On line 112 (in the constructor), you set the class constant
urland allow developers access to that value via thenaked-social-share/post-permalinkfilter. This is great…except that you do not use$this->urlwhen sending the sharing output to the browser.For all of the services, exactly the same function called when setting
urlin the constructor is called without allowing it to be filtered, when the value is already there in the constant, lovely and filterable.This happens at lines 446, 460, 488, 502, and 516. For example, at line 502:
<?php echo get_permalink( $this->post ); ?>Should be:
<?php echo $this->url; ?>Or better:
?php echo urlencode( $this->url ); ?>Since you do not consistently
urlencodethe URL, something essential if the filtered URL contains_GETvariables.In my use-case, I needed to be sure that some
$_GETvariables were added to the URL when sharing, and I had to modify this class to use$this->urlat the lines above in order to gain access to the aforementioned filter.This plugin works well otherwise–thanks for your efforts in putting it together!
The topic ‘Use class constant “url” in method ‘display_share_markup’’ is closed to new replies.