summaryrefslogtreecommitdiffstats
path: root/wp-includes/plugin.php
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-11-07 12:37:04 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-11-07 12:37:04 +0000
commitd510632e9f07cec9ac3de3b5dafc56bd58c81b8a (patch)
treeb4944ea6ceed3a73977f9edeae40f8174a4bab29 /wp-includes/plugin.php
parent74e848ef222ada441de10e1db012988d1904b3ca (diff)
downloadwordpress-mu-d510632e9f07cec9ac3de3b5dafc56bd58c81b8a.tar.gz
wordpress-mu-d510632e9f07cec9ac3de3b5dafc56bd58c81b8a.tar.xz
wordpress-mu-d510632e9f07cec9ac3de3b5dafc56bd58c81b8a.zip
WP Merge
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@804 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-includes/plugin.php')
-rw-r--r--wp-includes/plugin.php41
1 files changed, 14 insertions, 27 deletions
diff --git a/wp-includes/plugin.php b/wp-includes/plugin.php
index 7c58519..64ceb9a 100644
--- a/wp-includes/plugin.php
+++ b/wp-includes/plugin.php
@@ -12,9 +12,8 @@ function add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1)
foreach($wp_filter[$tag]["$priority"] as $filter) {
// uncomment if we want to match function AND accepted_args
// if ( $filter == array($function, $accepted_args) ) {
- if ( $filter['function'] == $function_to_add ) {
+ if ( $filter['function'] == $function_to_add )
return true;
- }
}
}
@@ -32,23 +31,20 @@ function apply_filters($tag, $string) {
merge_filters($tag);
- if ( !isset($wp_filter[$tag]) ) {
+ if ( !isset($wp_filter[$tag]) )
return $string;
- }
- foreach ($wp_filter[$tag] as $priority => $functions) {
- if ( !is_null($functions) ) {
- foreach($functions as $function) {
+ foreach ( (array) $wp_filter[$tag] as $priority => $functions ) {
+ if ( !is_null($functions) ) {
+ foreach ( (array) $functions as $function ) {
$function_name = $function['function'];
$accepted_args = $function['accepted_args'];
-
$the_args = $args;
array_unshift($the_args, $string);
if ( $accepted_args > 0 )
$the_args = array_slice($the_args, 0, $accepted_args);
- elseif ( $accepted_args == 0 )
+ elseif ( 0 == $accepted_args )
$the_args = NULL;
-
$string = call_user_func_array($function_name, $the_args);
}
}
@@ -56,11 +52,10 @@ function apply_filters($tag, $string) {
return $string;
}
-
function merge_filters($tag) {
global $wp_filter;
if ( isset($wp_filter['all']) ) {
- foreach ($wp_filter['all'] as $priority => $functions) {
+ foreach ( (array) $wp_filter['all'] as $priority => $functions ) {
if ( isset($wp_filter[$tag][$priority]) )
$wp_filter[$tag][$priority] = array_merge($wp_filter['all'][$priority], $wp_filter[$tag][$priority]);
else
@@ -73,18 +68,15 @@ function merge_filters($tag) {
uksort( $wp_filter[$tag], "strnatcasecmp" );
}
-
-
function remove_filter($tag, $function_to_remove, $priority = 10, $accepted_args = 1) {
global $wp_filter;
// rebuild the list of filters
if ( isset($wp_filter[$tag]["$priority"]) ) {
$new_function_list = array();
- foreach($wp_filter[$tag]["$priority"] as $filter) {
- if ( $filter['function'] != $function_to_remove ) {
+ foreach ( (array) $wp_filter[$tag]["$priority"] as $filter ) {
+ if ( $filter['function'] != $function_to_remove )
$new_function_list[] = $filter;
- }
}
$wp_filter[$tag]["$priority"] = $new_function_list;
}
@@ -115,10 +107,9 @@ function do_action($tag, $arg = '') {
if ( !isset($wp_filter[$tag]) )
return;
- foreach ($wp_filter[$tag] as $priority => $functions) {
+ foreach ( (array) $wp_filter[$tag] as $priority => $functions ) {
if ( !is_null($functions) ) {
- foreach($functions as $function) {
-
+ foreach ( (array) $functions as $function ) {
$function_name = $function['function'];
$accepted_args = $function['accepted_args'];
@@ -160,16 +151,14 @@ function do_action_ref_array($tag, $args) {
if ( !isset($wp_filter[$tag]) )
return;
- foreach ($wp_filter[$tag] as $priority => $functions) {
+ foreach ( (array) $wp_filter[$tag] as $priority => $functions ) {
if ( !is_null($functions) ) {
- foreach($functions as $function) {
-
+ foreach( (array) $functions as $function ) {
$function_name = $function['function'];
$accepted_args = $function['accepted_args'];
-
if ( $accepted_args > 0 )
$the_args = array_slice($args, 0, $accepted_args);
- elseif ( $accepted_args == 0 )
+ elseif ( 0 == $accepted_args )
$the_args = NULL;
else
$the_args = $args;
@@ -196,13 +185,11 @@ function plugin_basename($file) {
function register_activation_hook($file, $function) {
$file = plugin_basename($file);
-
add_action('activate_' . $file, $function);
}
function register_deactivation_hook($file, $function) {
$file = plugin_basename($file);
-
add_action('deactivate_' . $file, $function);
}