[wp-hackers] pre_ping hook placement

Mark Jaquith mark.wordpress at txfx.net
Mon Jan 9 10:55:21 GMT 2006


pre_ping is a new hook for WordPress 2.0

Its placement seems very bizarre to me.  Observe:

> 	foreach($post_links_temp[0] as $link_test) :
> 		if ( !in_array($link_test, $pung) && (url_to_postid($link_test) ! 
> = $post_ID) // If we haven't pung it already and it isn't a link to  
> itself
> 				&& !is_local_attachment($link_test) ) : // Also, let's never  
> ping local attachments.
> 			$test = parse_url($link_test);
> 			if (isset($test['query']))
> 				$post_links[] = $link_test;
> 			elseif(($test['path'] != '/') && ($test['path'] != ''))
> 				$post_links[] = $link_test;
> 			do_action('pre_ping',  array(&$post_links, &$pung));
> 		endif;
> 	endforeach;

The do_action() is inside of the foreach loop, which means that it  
gets run multiple times.  But it passes a reference to the entire  
array of $post_links and $pung URIs each time it is run.

So if an entry has these three links: http://site1 http://site2 and  
http://site3 ... something using that hook would first get http:// 
site1, then get http://site1 and http://site2, and then get all three  
links.

Is there a reason it was placed here?  Seems to me that the place  
place to put it would be AFTER the foreach loop.  It makes sense to  
me in that context.

It's very likely that no one is using this hook, as WordPress 2.0 has  
only been out a few days.  Any objections to moving it?

--
Mark Jaquith
http://txfx.net/




More information about the wp-hackers mailing list