shortcode which is introduced into entry the blog, and appears in side bar

  1. At the end of your function return the output as described in the documentation.

    return ob_get_clean();

  2. Add the [myshorcode] shortcode to a text widget. By default, widgets are not rendered in text widgets so make sure you add this snippet to your plugin:

    add_filter(‘widget_text’, ‘do_shortcode’);