Support » Plugin: Share Buttons by AddThis » [Plugin: AddThis] How to Create a Shortcode

  • 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,

  • The topic ‘[Plugin: AddThis] How to Create a Shortcode’ is closed to new replies.