[wp-trac] [WordPress Trac] #13169: Return Dynamic Sidebars with get_dynamic_sidebar

WordPress Trac noreply at wordpress.org
Mon May 4 16:31:27 UTC 2015


#13169: Return Dynamic Sidebars with get_dynamic_sidebar
-------------------------+------------------------------
 Reporter:  w3prodigy    |       Owner:
     Type:  enhancement  |      Status:  reopened
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Widgets      |     Version:
 Severity:  normal       |  Resolution:
 Keywords:               |     Focuses:
-------------------------+------------------------------

Comment (by westonruter):

 Replying to [comment:6 MadtownLems]:
 > For what it's worth, I was hoping get_dynamic_sidebar existed so that I
 could easily cache the html output of my sidebars.

 You can already do this, right? For instance:

 {{{#!php
 <?php
 function my_get_dynamic_sidebar( $sidebar_id ) {
         if ( ! is_user_logged_in() ) {
                 $content = wp_cache_get( $sidebar_id, 'cached-sidebar' );
                 if ( false !== $content ) {
                         return $content;
                 }
         }
         ob_start();
         dynamic_sidebar( $sidebar_id );
         $content = ob_get_clean();
         if ( ! is_user_logged_in() ) {
                 wp_cache_set( $sidebar_id, $content, 'cached-sidebar', 5 *
 MINUTE_IN_SECONDS );
         }
         return $content;
 }
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/13169#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list