[wp-trac] Re: [WordPress Trac] #6970: Add_feed - bug and fix - Replacing callback function

WordPress Trac wp-trac at lists.automattic.com
Wed May 14 12:23:24 GMT 2008


#6970: Add_feed - bug and fix - Replacing callback function
------------------------------------+---------------------------------------
 Reporter:  programming.has.no.com  |        Owner:  anonymous
     Type:  defect                  |       Status:  new      
 Priority:  high                    |    Milestone:  2.6      
Component:  General                 |      Version:  2.5.1    
 Severity:  normal                  |   Resolution:           
 Keywords:  add_feed                |  
------------------------------------+---------------------------------------
Comment (by DD32):

 Code:
 {{{
  buggy version
  function add_feed($feedname, $function) {
          global $wp_rewrite;
          if (!in_array($feedname, $wp_rewrite->feeds)) { //override the
 file if it is
                  $wp_rewrite->feeds[] = $feedname;
          }
          $hook = 'do_feed_' . $feedname;
          remove_action($hook, $function, 10, 1);
          add_action($hook, $function, 10, 1);
          return $hook;
  }



  fixed version
  function add_feed($feedname, $function, $remove_function="") {
          global $wp_rewrite;
          if (!in_array($feedname, $wp_rewrite->feeds)) { //override the
 file if it is
                  $wp_rewrite->feeds[] = $feedname;
          }
          $hook = 'do_feed_' . $feedname;
          if($remove_function != "")
                  remove_action($hook, $remove_function, 10, 1);
          else
                  remove_action($hook, $function, 10, 1);
          add_action($hook, $function, 10, 1);
          return $hook;
  }
 }}}

-- 
Ticket URL: <http://trac.wordpress.org/ticket/6970#comment:1>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list