Changeset 853
- Timestamp:
- 02/09/2004 11:58:49 AM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/functions.php
r848 r853 1178 1178 global $wp_filter; 1179 1179 if (isset($wp_filter['all'])) { 1180 $wp_filter['all'] = (is_string($wp_filter['all'])) ? array($wp_filter['all']) : $wp_filter['all']; 1181 if (isset($wp_filter[$tag])) 1182 $wp_filter[$tag] = array_merge($wp_filter['all'], $wp_filter[$tag]); 1183 else 1184 $wp_filter[$tag] = array_merge($wp_filter['all'], array()); 1185 $wp_filter[$tag] = array_unique($wp_filter[$tag]); 1186 } 1180 foreach ($wp_filter['all'] as $priority => $functions) { 1181 if (isset($wp_filter[$tag][$priority])) 1182 $wp_filter[$tag][$priority] = array_merge($wp_filter['all'][$priority], $wp_filter[$tag][$priority]); 1183 else 1184 $wp_filter[$tag][$priority] = array_merge($wp_filter['all'][$priority], array()); 1185 $wp_filter[$tag][$priority] = array_unique($wp_filter[$tag][$priority]); 1186 } 1187 1188 } 1189 1187 1190 if (isset($wp_filter[$tag])) { 1188 $wp_filter[$tag] = (is_string($wp_filter[$tag])) ? array($wp_filter[$tag]) : $wp_filter[$tag];1189 $functions = $wp_filter[$tag];1190 foreach($functions as $function) {1191 //error_log("apply_filters #1 applying filter $function");1192 $string = $function($string);1191 ksort($wp_filter[$tag]); 1192 foreach ($wp_filter[$tag] as $priority => $functions) { 1193 foreach($functions as $function) { 1194 $string = $function($string); 1195 } 1193 1196 } 1194 1197 } … … 1196 1199 } 1197 1200 1198 function add_filter($tag, $function_to_add ) {1201 function add_filter($tag, $function_to_add, $priority = 10) { 1199 1202 global $wp_filter; 1200 if (isset($wp_filter[$tag])) { 1201 $functions = $wp_filter[$tag]; 1202 if (is_array($functions)) { 1203 foreach($functions as $function) { 1204 $new_functions[] = $function; 1203 // So the format is wp_filter['tag']['array of priorities']['array of functions'] 1204 if (!@in_array($function_to_add, $wp_filter[$tag]["$priority"])) { 1205 $wp_filter[$tag]["$priority"][] = $function_to_add; 1206 } 1207 return true; 1208 } 1209 1210 function remove_filter($tag, $function_to_remove, $priority = 10) { 1211 global $wp_filter; 1212 if (@in_array($function_to_remove, $wp_filter[$tag]["$priority"])) { 1213 foreach ($wp_filter[$tag]["$priority"] as $function) { 1214 if ($function_to_remove != $function) { 1215 $new_function_list[] = $function; 1205 1216 } 1206 } elseif (is_string($functions)) { 1207 $new_functions[] = $functions; 1208 } 1209 /* this is commented out because it just makes PHP die silently 1210 for no apparent reason 1211 if (is_array($function_to_add)) { 1212 foreach($function_to_add as $function) { 1213 if (!in_array($function, $wp_filter[$tag])) { 1214 $new_functions[] = $function; 1215 } 1216 } 1217 } else */if (is_string($function_to_add)) { 1218 if (!@in_array($function_to_add, $wp_filter[$tag])) { 1219 $new_functions[] = $function_to_add; 1220 } 1221 } 1222 $wp_filter[$tag] = $new_functions; 1223 } else { 1224 $wp_filter[$tag] = array($function_to_add); 1225 } 1217 } 1218 $wp_filter[$tag]["$priority"] = $new_function_list; 1219 } 1220 //die(var_dump($wp_filter)); 1226 1221 return true; 1227 1222 }
Note: See TracChangeset
for help on using the changeset viewer.