[wp-trac] [WordPress Trac] #24283: is_active_widget() incorrect logic

WordPress Trac noreply at wordpress.org
Tue Oct 29 06:42:47 UTC 2024


#24283: is_active_widget() incorrect logic
--------------------------+---------------------
 Reporter:  valllabh      |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:
Component:  Widgets       |     Version:
 Severity:  normal        |  Resolution:
 Keywords:  dev-feedback  |     Focuses:
--------------------------+---------------------

Comment (by camyilmaz):

 {{{#!php
 function is_active_widget_extended( $widget_id ) {
     global $wp_registered_widgets;

     foreach ( $wp_registered_widgets as $widget ) {
         if ( $widget_id == $widget['id'] && is_active_widget( false,
 false, $widget['id'], true ) ) {
             return true;
         }
     }

     ob_start();
     the_widget( $widget_id );
     $widget_output = ob_get_clean();

     if ( ! empty( $widget_output ) ) {
         return true;
     }

     return false;
 }


 }}}

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


More information about the wp-trac mailing list