Blog

WordPress Widgets Hack: Show Title on Widget

wordpress widgets hack_ to show titleHaving a lot of RSS/Text or King Widgets brings up a Problem in the Admin Interface.

You have to klick on each Widget to see whats in there.

The Solution is to show the title of each Widget (if it has one) next to the widget name in the drag drop view. 

Code

I made a little change to the widget.php (the original widget plugin v.1.0).

 

Open widget.php and go to Line 607 -> in function widget_draggable($name)

Original Line 607
———– 

echo "<li class=’module’ id=’widgetprefix-$san_name’><span class=’handle’>$name$popper</span></li>"; 

———–
Replace the Line 607 with this:
———–

// start widget title enhancements by georg leciejewski
    if(!empty($registered_widgets[$name]['params'])){
        $number = $registered_widgets[$name]['params'][0];
        $options =get_option($registered_widgets[$name]['classname']);
        $widgettitle=$options[$number]['title'] ;
    }else{
        $options =get_option($registered_widgets[$name]['classname']);
        $widgettitle=$options['title'] ;
    }
    //show only if title is populated
    if(!empty($widgettitle)){
        $show_title= ‘<small>( ‘.$widgettitle.’ )</small>’;
    }
// end widget title enhancements by georg leciejewski
    echo "<li class=’module’ id=’widgetprefix-$san_name’><span class=’handle’>$name $show_title  $popper</span></li>";

———–

Now the Widget Title guides you the way through your widget jungle.

6 Comments to WordPress Widgets Hack: Show Title on Widget

  1. 21.06.2006 at 23:55

    Thanks. For those using a more recent version of widgets.php, the new insertion point is at line 621. Also note that the code sample above contains “smart quotes” – you’ll need to correct them all to plain quotes.

  2. 30.05.2006 at 21:19

    correction. that is the ones surrounding

  3. 30.05.2006 at 21:18

    $show_title= ‘( ‘.$widgettitle.’ )’;

    Need to change ‘ to “

  4. MichaelH's Gravatar MichaelH
    05.05.2006 at 20:56

    Great Hack. I’ve been thinking of suggesting this to the WordPress programmers. Please consider putting your code in as a case at the WordPress ‘bug’ site, http://trac.wordpress.org/

  1. By on 11.06.2006 at 10:50