[wp-trac] [WordPress Trac] #27156: add filter to manipulate $before_title and $after_title in widget

WordPress Trac noreply at wordpress.org
Wed Feb 19 07:55:26 UTC 2014


#27156: add filter to manipulate $before_title and $after_title in widget
-----------------------------+-----------------------------
 Reporter:  sireneweb        |      Owner:
     Type:  feature request  |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  Widgets          |    Version:  3.8.1
 Severity:  normal           |   Keywords:
  Focuses:                   |
-----------------------------+-----------------------------
 Hi,
 actually you can't manipulate correctly the params for before_title and
 after title, it would be great to add a filter to manipulate them and
 better if we can specify for which widget based on widget type & location
 more simplier.

 To know the widget_id, you need to print the request with var_dump

 Actually i use this :


 {{{
 add_filter ( 'dynamic_sidebar_params' , 'rename_widget_title'); //we use
 the default priority and 3 arguments in the callback function
 function rename_widget_title($params) {
        $widget_request_1 =
 array('nav_menu-6','nav_menu-2','"nav_menu-5','categories-2');
        $widget_request_2 = array('custom_post_widget-4');

         if (in_array($params[0]['widget_id'],$widget_request_1)){
                     $params[0]['before_title'] = '<span
 class="widgettitle">';
                     $params[0]['after_title'] = '</span>';
         }elseif(in_array($params[0]['widget_id'],$widget_request_2)){
                     $params[0]['before_title'] = '<span
 class="title_bloc_widget">';
                     $params[0]['after_title'] = '</span>';
         }
          return $params;
 }
 }}}

 Maybe we can display in back office in widget panel the widget id with
 hover when the mouse is on the title of widget.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/27156>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list