WordPress.org

Make WordPress Core

Ticket #7112: widget-icons.diff

File widget-icons.diff, 3.7 KB (added by scribblerguy, 6 years ago)
  • wp-admin/includes/widgets.php

     
    102102                <li id="widget-list-item-<?php echo attribute_escape( $widget['id'] ); ?>" class="widget-list-item"> 
    103103                        <h4 class="widget-title widget-draggable"> 
    104104 
    105                                 <span><?php echo $widget_title; ?></span> 
     105                                <span><img class="widget-icon-available" src="<?php echo widget_icon_url( $widget['classname'] ); ?>" height="16" width="16" /> 
     106                                <?php echo $widget_title; ?></span> 
    106107 
    107108                                <?php if ( 'add' == $action ) : ?> 
    108109 
     
    230231                echo $sidebar_args['before_widget']; 
    231232?> 
    232233                <div class="widget-top"> 
    233                 <h4 class="widget-title"><span><?php echo $widget_title ?></span> 
     234                <h4 class="widget-title"><span> 
     235                <img class="widget-icon-active" src="<?php echo widget_icon_url( $widget['classname'] ); ?>" height="16" width="16" /> 
     236                <?php echo $widget_title ?></span> 
    234237 
    235238                        <?php if ( $edit ) : ?> 
    236239 
     
    285288        $string = str_replace( '&nbsp;', ' ', $string ); 
    286289        return trim( wp_specialchars( strip_tags( $string ) ) ); 
    287290} 
     291 
     292/** 
     293 * returns the relative URL for a widget icon 
     294 *  
     295 * Used to display an icon beside the name of a widget in the Design > Widgets 
     296 * page of the Admin Panel. Only core widgets get a unique icon. All other widgets 
     297 * get a default widget. 
     298 * 
     299 * The $widget_type parameter is actually the CSS class name of the widget. This 
     300 * is checked against a list of core class names. If a match is found, that class 
     301 * name is used. Otherwise, a default name is used. 
     302 * 
     303 * If JavaScript is disabled and the user creates another instance of a multiple 
     304 * widget, the icon is displayed on the full screen edit control, but the class 
     305 * name is generated from the "base" value from the URL query string. 
     306 *  
     307 * @package WordPress 
     308 * @since  
     309 * 
     310 * @param string $widget_type the classname value for a widget 
     311 * @return string $icon_url the relative URL (e.g. "images/widget_name.gif") 
     312 * 
     313 */ 
     314 
     315 
     316function widget_icon_url( $widget_type = 'widget_default' ) { 
     317        if ( ($widget_type == 'widget_archive') || ($widget_type == 'widget_calendar') || ($widget_type == 'widget_categories') || ($widget_type == 'widget_links') || ($widget_type == 'widget_meta') || ($widget_type == 'widget_pages') || ($widget_type == 'widget_recent_comments') || ($widget_type == 'widget_recent_entries') || ($widget_type == 'widget_rss') || ($widget_type == 'widget_search') ||  ($widget_type == 'widget_tag_cloud') ||  ($widget_type == 'widget_text') ) { 
     318            $icon_url = 'images/' . $widget_type . '.gif'; 
  • wp-admin/css/widgets.css

    +        } else {
    +            $icon_url = 'images/widget_default.gif';    
    +        }
    +  	return $icon_url;
    +}
    \ No newline at end of file
     
    186186        width: auto; 
    187187        display: block; 
    188188} 
     189 
     190.widget-icon-available, .widget-icon-active { 
     191        vertical-align: text-top; 
     192} 
     193 No newline at end of file 
  • wp-admin/widgets.php

     
    136136                        <ul class="widget-control-list"> 
    137137                                <li class="widget-list-control-item"> 
    138138                                        <div class="widget-top"> 
    139                                         <h4 class="widget-title"><?php echo $control['name']; ?></h4> 
     139                                        <h4 class="widget-title"><img class="widget-icon-available" src="<?php echo widget_icon_url(  'widget_' . $_GET['base']  ); ?>" height="16" width="16" /> <?php echo $control['name']; ?></h4> 
    140140                                        </div> 
    141141                                        <div class="widget-control" style="display: block;"> 
    142142        <?php