Ticket #36199: 36199-foreach.patch
File 36199-foreach.patch, 4.9 KB (added by , 9 years ago) |
---|
-
src/wp-includes/plugin.php
209 209 } 210 210 211 211 if ( !isset($wp_filter[$tag]) ) { 212 if ( isset($wp_filter['all']) ) 212 if ( isset($wp_filter['all']) ) { 213 213 array_pop($wp_current_filter); 214 } 214 215 return $value; 215 216 } 216 217 217 if ( !isset($wp_filter['all']) ) 218 if ( !isset($wp_filter['all']) ) { 218 219 $wp_current_filter[] = $tag; 220 } 219 221 220 222 // Sort. 221 223 if ( !isset( $merged_filters[ $tag ] ) ) { … … 223 225 $merged_filters[ $tag ] = true; 224 226 } 225 227 226 reset( $wp_filter[ $tag ] ); 227 228 if ( empty($args) ) 228 if ( empty($args) ) { 229 229 $args = func_get_args(); 230 } 230 231 231 do{232 foreach ( (array) current($wp_filter[$tag]) as $the_ )232 foreach ( $wp_filter[ $tag ] as $hooks ) { 233 foreach ( (array) $hooks as $the_ ) { 233 234 if ( !is_null($the_['function']) ){ 234 235 $args[1] = $value; 235 236 $value = call_user_func_array($the_['function'], array_slice($args, 1, (int) $the_['accepted_args'])); 236 237 } 238 } 239 } 237 240 238 } while ( next($wp_filter[$tag]) !== false );239 240 241 array_pop( $wp_current_filter ); 241 242 242 243 return $value; … … 269 270 } 270 271 271 272 if ( !isset($wp_filter[$tag]) ) { 272 if ( isset($wp_filter['all']) ) 273 if ( isset($wp_filter['all']) ) { 273 274 array_pop($wp_current_filter); 275 } 274 276 return $args[0]; 275 277 } 276 278 277 if ( !isset($wp_filter['all']) ) 279 if ( !isset($wp_filter['all']) ) { 278 280 $wp_current_filter[] = $tag; 281 } 279 282 280 283 // Sort 281 284 if ( !isset( $merged_filters[ $tag ] ) ) { … … 283 286 $merged_filters[ $tag ] = true; 284 287 } 285 288 286 reset( $wp_filter[ $tag ] ); 287 288 do { 289 foreach ( (array) current($wp_filter[$tag]) as $the_ ) 290 if ( !is_null($the_['function']) ) 289 foreach ( $wp_filter[ $tag ] as $hooks ) { 290 foreach ( (array) $hooks as $the_ ) { 291 if ( !is_null($the_['function']) ){ 291 292 $args[0] = call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args'])); 293 } 294 } 295 } 292 296 293 } while ( next($wp_filter[$tag]) !== false );294 295 297 array_pop( $wp_current_filter ); 296 298 297 299 return $args[0]; … … 482 484 function do_action($tag, $arg = '') { 483 485 global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter; 484 486 485 if ( ! isset($wp_actions[$tag]) ) 487 if ( ! isset($wp_actions[$tag]) ) { 486 488 $wp_actions[$tag] = 1; 487 else489 } else { 488 490 ++$wp_actions[$tag]; 491 } 489 492 490 493 // Do 'all' actions first 491 494 if ( isset($wp_filter['all']) ) { … … 495 498 } 496 499 497 500 if ( !isset($wp_filter[$tag]) ) { 498 if ( isset($wp_filter['all']) ) 501 if ( isset($wp_filter['all']) ) { 499 502 array_pop($wp_current_filter); 503 } 500 504 return; 501 505 } 502 506 503 if ( !isset($wp_filter['all']) ) 507 if ( !isset($wp_filter['all']) ) { 504 508 $wp_current_filter[] = $tag; 509 } 505 510 506 511 $args = array(); 507 if ( is_array($arg) && 1 == count($arg) && isset($arg[0]) && is_object($arg[0]) ) // array(&$this)512 if ( is_array($arg) && 1 == count($arg) && isset($arg[0]) && is_object($arg[0]) ) { // array(&$this) 508 513 $args[] =& $arg[0]; 509 else514 } else { 510 515 $args[] = $arg; 511 for ( $a = 2, $num = func_num_args(); $a < $num; $a++ ) 516 } 517 518 for ( $a = 2, $num = func_num_args(); $a < $num; $a++ ) { 512 519 $args[] = func_get_arg($a); 520 } 513 521 514 522 // Sort 515 523 if ( !isset( $merged_filters[ $tag ] ) ) { … … 517 525 $merged_filters[ $tag ] = true; 518 526 } 519 527 520 reset( $wp_filter[ $tag ] ); 521 522 do { 523 foreach ( (array) current($wp_filter[$tag]) as $the_ ) 524 if ( !is_null($the_['function']) ) 528 foreach ( $wp_filter[$tag] as $hooks ) { 529 foreach ( (array) $hooks as $the_ ) { 530 if ( !is_null($the_['function']) ) { 525 531 call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args'])); 532 } 533 } 534 } 526 535 527 } while ( next($wp_filter[$tag]) !== false );528 529 536 array_pop($wp_current_filter); 530 537 } 531 538 … … 566 573 function do_action_ref_array($tag, $args) { 567 574 global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter; 568 575 569 if ( ! isset($wp_actions[$tag]) ) 576 if ( ! isset($wp_actions[$tag]) ) { 570 577 $wp_actions[$tag] = 1; 571 else578 } else { 572 579 ++$wp_actions[$tag]; 580 } 573 581 574 582 // Do 'all' actions first 575 583 if ( isset($wp_filter['all']) ) { … … 579 587 } 580 588 581 589 if ( !isset($wp_filter[$tag]) ) { 582 if ( isset($wp_filter['all']) ) 590 if ( isset($wp_filter['all']) ) { 583 591 array_pop($wp_current_filter); 592 } 584 593 return; 585 594 } 586 595 587 if ( !isset($wp_filter['all']) ) 596 if ( !isset($wp_filter['all']) ) { 588 597 $wp_current_filter[] = $tag; 598 } 589 599 590 600 // Sort 591 601 if ( !isset( $merged_filters[ $tag ] ) ) { … … 593 603 $merged_filters[ $tag ] = true; 594 604 } 595 605 596 reset( $wp_filter[ $tag ] ); 597 598 do { 599 foreach ( (array) current($wp_filter[$tag]) as $the_ ) 600 if ( !is_null($the_['function']) ) 606 foreach ( $wp_filter[$tag] as $hooks ) { 607 foreach ( (array) $hooks as $the_ ) { 608 if ( !is_null($the_['function']) ) { 601 609 call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args'])); 610 } 611 } 612 } 602 613 603 } while ( next($wp_filter[$tag]) !== false );604 605 614 array_pop($wp_current_filter); 606 615 } 607 616