AddThis Sharing Buttons
[Plugin: AddThis] How to Create a Shortcode (1 post)

  1. htmlfx
    Posted 3 years ago #

    Hello All,
    I wanted the output of this plugin to appear in a sidebar via a shortcode.

    So I added:
    add_shortcode( 'sharethis_button', 'sharethis_button' );

    Which allows you to use [sharethis_button] as a short code anywhere.

    This worked, but it caused an issue due to the fact that the function that creates the ShareThis content used "echo" vs "return". The issue was the code was being sent to the browser earlier then the the widget so the code was in the wrong place.

    I was unable to overwrite this function in the functions.php file so I modify the plugin (I know I am not supposed to do this). The change I made was in sharethis.php line 214.
    function sharethis_button() {
    return st_makeEntries(); //changed echo to return on this line

    My questions is two fold... am I breaking anything in the plugin with this change, and if not, you add this change to the next version so others can use this shortcode and not have to tweak the plugin to make it work.

    Let me know,


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • AddThis Sharing Buttons
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic