| 1 |
Index: plugin.php |
|---|
| 2 |
=================================================================== |
|---|
| 3 |
--- plugin.php (revision 5875) |
|---|
| 4 |
+++ plugin.php (working copy) |
|---|
| 5 |
@@ -19,7 +19,9 @@ |
|---|
| 6 |
global $wp_filter, $merged_filters; |
|---|
| 7 |
|
|---|
| 8 |
// So the format is wp_filter['tag']['array of priorities']['array of functions serialized']['array of ['array (functions, accepted_args)]'] |
|---|
| 9 |
- $wp_filter[$tag][$priority][serialize($function_to_add)] = array('function' => $function_to_add, 'accepted_args' => $accepted_args); |
|---|
| 10 |
+ $idx = _wp_filter_build_unique_id($tag, $function_to_add, $priority); |
|---|
| 11 |
+ $wp_filter[$tag][$priority][$idx] = array('function' => $function_to_add, 'accepted_args' => $accepted_args); |
|---|
| 12 |
+ //$wp_filter[$tag][$priority][serialize($function_to_add)] = array('function' => $function_to_add, 'accepted_args' => $accepted_args); |
|---|
| 13 |
unset( $merged_filters[ $tag ] ); |
|---|
| 14 |
return true; |
|---|
| 15 |
} |
|---|
| 16 |
@@ -97,7 +99,7 @@ |
|---|
| 17 |
* @return boolean Whether the function is removed. |
|---|
| 18 |
*/ |
|---|
| 19 |
function remove_filter($tag, $function_to_remove, $priority = 10, $accepted_args = 1) { |
|---|
| 20 |
- $function_to_remove = serialize($function_to_remove); |
|---|
| 21 |
+ $function_to_remove = _wp_filter_build_unique_id($tag, $function_to_remove, $priority); |
|---|
| 22 |
|
|---|
| 23 |
$r = isset($GLOBALS['wp_filter'][$tag][$priority][$function_to_remove]); |
|---|
| 24 |
|
|---|
| 25 |
@@ -280,4 +282,29 @@ |
|---|
| 26 |
add_action('deactivate_' . $file, $function); |
|---|
| 27 |
} |
|---|
| 28 |
|
|---|
| 29 |
+function _wp_filter_build_unique_id($tag, $function, $priority = 10) |
|---|
| 30 |
+{ |
|---|
| 31 |
+ global $wp_filter; |
|---|
| 32 |
+ |
|---|
| 33 |
+ // If function then just skip all of the tests and not overwrite the following. |
|---|
| 34 |
+ // Static Calling |
|---|
| 35 |
+ if( is_string($function) ) |
|---|
| 36 |
+ return $function; |
|---|
| 37 |
+ // Object Class Calling |
|---|
| 38 |
+ else if(is_object($function[0]) ) |
|---|
| 39 |
+ { |
|---|
| 40 |
+ $obj_idx = get_class($function[0]).$function[1]; |
|---|
| 41 |
+ if( is_null($function[0]->wp_filter_id) ) { |
|---|
| 42 |
+ $count = count((array)$wp_filter[$tag][$priority]); |
|---|
| 43 |
+ $function[0]->wp_filter_id = $count; |
|---|
| 44 |
+ $obj_idx .= $count; |
|---|
| 45 |
+ unset($count); |
|---|
| 46 |
+ } else |
|---|
| 47 |
+ $obj_idx .= $function[0]->wp_filter_id; |
|---|
| 48 |
+ return $obj_idx; |
|---|
| 49 |
+ } |
|---|
| 50 |
+ else if( is_string($function[0]) ) |
|---|
| 51 |
+ return $function[0].$function[1]; |
|---|
| 52 |
+} |
|---|
| 53 |
+ |
|---|
| 54 |
?> |
|---|
| 55 |
|
|---|