• Resolved rogerlos

    (@rogerlos)


    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 url and allow developers access to that value via the naked-social-share/post-permalink filter. This is great…except that you do not use $this->url when sending the sharing output to the browser.

    For all of the services, exactly the same function called when setting url in 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 urlencode the URL, something essential if the filtered URL contains _GET variables.

    In my use-case, I needed to be sure that some $_GET variables were added to the URL when sharing, and I had to modify this class to use $this->url at 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!

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Use class constant “url” in method ‘display_share_markup’’ is closed to new replies.