Make WordPress Core


Ignore:
Timestamp:
10/13/2006 02:01:53 PM (20 years ago)
Author:
markjaquith
Message:

Code cleanup: wp-includes/plugin.php

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/plugin.php

    r4289 r4394  
    1313                        // uncomment if we want to match function AND accepted_args
    1414                        // if ( $filter == array($function, $accepted_args) ) {
    15                         if ( $filter['function'] == $function_to_add ) {
     15                        if ( $filter['function'] == $function_to_add )
    1616                                return true;
    17                         }
    1817                }
    1918        }
     
    3332        merge_filters($tag);
    3433
    35         if ( !isset($wp_filter[$tag]) ) {
     34        if ( !isset($wp_filter[$tag]) )
    3635                return $string;
    37         }
    38         foreach ($wp_filter[$tag] as $priority => $functions) {
     36
     37        foreach ( (array) $wp_filter[$tag] as $priority => $functions ) {
    3938                if ( !is_null($functions) ) {
    40                         foreach($functions as $function) {
    41 
     39                        foreach ( (array) $functions as $function ) {
    4240                                $function_name = $function['function'];
    4341                                $accepted_args = $function['accepted_args'];
    44 
    4542                                $the_args = $args;
    4643                                array_unshift($the_args, $string);
    4744                                if ( $accepted_args > 0 )
    4845                                        $the_args = array_slice($the_args, 0, $accepted_args);
    49                                 elseif ( $accepted_args == 0 )
     46                                elseif ( 0 == $accepted_args )
    5047                                        $the_args = NULL;
    51 
    5248                                $string = call_user_func_array($function_name, $the_args);
    5349                        }
     
    5753}
    5854
    59 
    6055function merge_filters($tag) {
    6156        global $wp_filter;
    6257        if ( isset($wp_filter['all']) ) {
    63                 foreach ($wp_filter['all'] as $priority => $functions) {
     58                foreach ( (array) $wp_filter['all'] as $priority => $functions ) {
    6459                        if ( isset($wp_filter[$tag][$priority]) )
    6560                                $wp_filter[$tag][$priority] = array_merge($wp_filter['all'][$priority], $wp_filter[$tag][$priority]);
     
    7469}
    7570
    76 
    77 
    7871function remove_filter($tag, $function_to_remove, $priority = 10, $accepted_args = 1) {
    7972        global $wp_filter;
     
    8275        if ( isset($wp_filter[$tag]["$priority"]) ) {
    8376                $new_function_list = array();
    84                 foreach($wp_filter[$tag]["$priority"] as $filter) {
    85                         if ( $filter['function'] != $function_to_remove ) {
     77                foreach ( (array) $wp_filter[$tag]["$priority"] as $filter ) {
     78                        if ( $filter['function'] != $function_to_remove )
    8679                                $new_function_list[] = $filter;
    87                         }
    8880                }
    8981                $wp_filter[$tag]["$priority"] = $new_function_list;
     
    115107                return;
    116108
    117         foreach ($wp_filter[$tag] as $priority => $functions) {
     109        foreach ( (array) $wp_filter[$tag] as $priority => $functions ) {
    118110                if ( !is_null($functions) ) {
    119                         foreach($functions as $function) {
    120 
     111                        foreach ( (array) $functions as $function ) {
    121112                                $function_name = $function['function'];
    122113                                $accepted_args = $function['accepted_args'];
     
    143134                return;
    144135
    145         foreach ($wp_filter[$tag] as $priority => $functions) {
     136        foreach ( (array) $wp_filter[$tag] as $priority => $functions ) {
    146137                if ( !is_null($functions) ) {
    147                         foreach($functions as $function) {
    148 
     138                        foreach( (array) $functions as $function ) {
    149139                                $function_name = $function['function'];
    150140                                $accepted_args = $function['accepted_args'];
    151 
    152141                                if ( $accepted_args > 0 )
    153142                                        $the_args = array_slice($args, 0, $accepted_args);
    154                                 elseif ( $accepted_args == 0 )
     143                                elseif ( 0 == $accepted_args )
    155144                                        $the_args = NULL;
    156145                                else
     
    179168function register_activation_hook($file, $function) {
    180169        $file = plugin_basename($file);
    181 
    182170        add_action('activate_' . $file, $function);
    183171}
     
    185173function register_deactivation_hook($file, $function) {
    186174        $file = plugin_basename($file);
    187 
    188175        add_action('deactivate_' . $file, $function);
    189176}
Note: See TracChangeset for help on using the changeset viewer.