[wp-trac] [WordPress Trac] #10276: Cannot inherit from WP_Widget_RSS

WordPress Trac wp-trac at lists.automattic.com
Thu Jun 25 22:30:22 GMT 2009


#10276: Cannot inherit from WP_Widget_RSS
--------------------------+-------------------------------------------------
 Reporter:  jonknight73   |       Owner:  azaozz    
     Type:  defect (bug)  |      Status:  new       
 Priority:  normal        |   Milestone:  Unassigned
Component:  Widgets       |     Version:  2.8       
 Severity:  normal        |    Keywords:            
--------------------------+-------------------------------------------------
 I attempted to use the following code in a plugin, with the eventual aim
 of contextually modifying the URL.

 {{{
 require_once( ABSPATH . WPINC . '/default-widgets.php' );

 class Example_Widget extends WP_Widget_RSS {

 function  Example_Widget() {
         $widget_ops = array( 'description' => __('Example Widget') );
         $control_ops = array( 'width' => 400, 'height' => 200 );
     $this->WP_Widget( 'example-widget', 'Example Widget', $widget_ops,
 $control_ops );
 }

 function widget($args, $instance)
 {
      $newinstance = $instance;
          WP_Widget_RSS::widget($args, $newinstance);
 }
 }}}


 I was attempting to customise the default WordPress RSS plugin using
 inheritance. It works, but you cannot set the settings in the control
 panel, you need to hack the url setting into play via SQL.

 In wp-include/default-widgets.php the form and update methods of
 WP_Widget_RSS reference static functions that hard codes it's base id.

 The function wp_widget_rss_form sets the id on the form as follows:
 {{{
 <input class="widefat" id="rss-url-<?php echo $number; ?>" name="widget-
 rss[<?php echo $number; ?>][url]" type="text" value="<?php echo $url; ?>"
 /></p>
 }}}

 Should this code really be in the class, and the id and name set using the
 functions get_field_id and get_field_name. This will then allow
 inheritance to work properly.

 wp-admin/includes/dashboard.php also references the function
 wp_widget_rss_form.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/10276>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list