Index: plugin.php
===================================================================
--- plugin.php	(revision 6312)
+++ plugin.php	(working copy)
@@ -72,6 +72,10 @@
 function add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1) {
 	global $wp_filter, $merged_filters;
 
+	// If all tag was added by action, this won't match.
+	if($tag == 'all')
+		$tag = 'all_filter';
+
 	$idx = _wp_filter_build_unique_id($tag, $function_to_add, $priority);
 	$wp_filter[$tag][$priority][$idx] = array('function' => $function_to_add, 'accepted_args' => $accepted_args);
 	unset( $merged_filters[ $tag ] );
@@ -110,7 +114,7 @@
 	global $wp_filter, $merged_filters;
 
 	if ( !isset( $merged_filters[ $tag ] ) )
-		merge_filters($tag);
+		merge_filters($tag, 'filter');
 
 	if ( !isset($wp_filter[$tag]) )
 		return $value;
@@ -149,12 +153,14 @@
  * @global array $merge_filters Merges the filter hooks using this function.
  *
  * @param string $tag The filter hook of which the functions should be merged.
+ * @param string $caller Whether the caller is a 'filter' or 'action'
  */
-function merge_filters($tag) {
+function merge_filters($tag, $caller='filter') {
 	global $wp_filter, $merged_filters;
 
-	if ( isset($wp_filter['all']) && is_array($wp_filter['all']) )
-		$wp_filter[$tag] = array_merge($wp_filter['all'], (array) $wp_filter[$tag]);
+	$all = 'all_'.$caller;
+	if ( isset($wp_filter[$all]) && is_array($wp_filter[$all]) )
+		$wp_filter[$tag] = $wp_filter[$all] + (array) $wp_filter[$tag];
 
 	if ( isset($wp_filter[$tag]) ){
 		reset($wp_filter[$tag]);
@@ -185,11 +191,16 @@
  * @return boolean Whether the function existed before it was removed.
  */
 function remove_filter($tag, $function_to_remove, $priority = 10, $accepted_args = 1) {
+	if($tag == 'all')
+		$tag = 'all_filter';
+
 	$function_to_remove = _wp_filter_build_unique_id($tag, $function_to_remove, $priority);
 
 	$r = isset($GLOBALS['wp_filter'][$tag][$priority][$function_to_remove]);
 
+	$GLOBALS['wp_filter'][$tag][$priority][$function_to_remove] = array();
 	unset($GLOBALS['wp_filter'][$tag][$priority][$function_to_remove]);
+	$GLOBALS['merged_filters'][$tag] = array();
 	unset($GLOBALS['merged_filters'][$tag]);
 
 	return $r;
@@ -215,6 +226,9 @@
  * @param int $accepted_args optional. The number of arguments the function accept (default 1).
  */
 function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1) {
+	if($tag == 'all')
+		$tag = 'all_action';
+
 	add_filter($tag, $function_to_add, $priority, $accepted_args);
 }
 
@@ -256,7 +270,8 @@
 	for ( $a = 2; $a < func_num_args(); $a++ )
 		$args[] = func_get_arg($a);
 
-	merge_filters($tag);
+	if ( !isset( $merged_filters[ $tag ] ) )
+		merge_filters($tag, 'action');
 
 	if ( !isset($wp_filter[$tag]) )
 		return;
@@ -316,7 +331,8 @@
 	else
 		$wp_actions[] = $tag;
 
-	merge_filters($tag);
+	if ( !isset( $merged_filters[ $tag ] ) )
+		merge_filters($tag, 'action');
 
 	if ( !isset($wp_filter[$tag]) )
 		return;
@@ -350,6 +366,9 @@
  * @return boolean Whether the function is removed.
  */
 function remove_action($tag, $function_to_remove, $priority = 10, $accepted_args = 1) {
+	if($tag == 'all')
+		$tag = 'all_action';
+
 	return remove_filter($tag, $function_to_remove, $priority, $accepted_args);
 }
 
@@ -461,8 +480,7 @@
  * @param int $priority Used in counting how many hooks were applied
  * @return string Unique ID for usage as array key
  */
-function _wp_filter_build_unique_id($tag, $function, $priority = 10)
-{
+function _wp_filter_build_unique_id($tag, $function, $priority = 10) {
 	global $wp_filter;
 
 	// If function then just skip all of the tests and not overwrite the following.
@@ -472,7 +490,7 @@
 	else if(is_object($function[0]) )
 	{
 		$obj_idx = get_class($function[0]).$function[1];
-		if( is_null($function[0]->wp_filter_id) ) { // This should be instead of is_null() change to !isset() to fix notice
+		if( !isset($function[0]->wp_filter_id) ) {
 			$count = count((array)$wp_filter[$tag][$priority]);
 			$function[0]->wp_filter_id = $count;
 			$obj_idx .= $count;

