get_dynamic_sidebar function needed or perhaps a hook? (4 posts)

  1. .sarah.
    Posted 5 years ago #

    Widgets are great to give the user control over what goes in a sidebar.

    However in the case of plugins sometimes we need to get the code and control how/when its echo'd out.

    Therefore it would be great to have get_dynamic_sidebar that returns the string.

    The alternative would be a hook that is called after the user leaves the loop (somehow). The idea is that the plugin can run without requiring the user to update their templates. The benefits are

    1. User can use widgets to control the options without creating more submenus in the Settings section
    2. User doesn't need to be familiar with editing templates
    3. User can change templates without worrying that they'll lose functionality, create work etc
  2. Rocio Valdivia
    Posted 5 years ago #

    Meanwhile it is developed in the core, I have found this one in the trunk, you can use it ;)

    function get_dynamic_sidebar($index = 1)
    $sidebar_contents = "";
    $sidebar_contents = ob_get_clean();
    return $sidebar_contents;

  3. ryanve
    Posted 4 years ago #

    @_DorsVenabili That worked for me =) Do you remember the link to where you found it? It definitely seems like it would be useful to have it as an official function.

  4. ryanve
    Posted 4 years ago #

    Ah found it, for anyone else looking, see: core.trac.wordpress.org/ticket/13169

Topic Closed

This topic has been closed to new replies.

About this Topic