mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
Code is Poetry.
WordPress' code just... wasn't. This is now dealt with. Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS. Fixes #41057. git-svn-id: https://develop.svn.wordpress.org/trunk@42343 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -71,12 +71,12 @@ final class WP_Hook implements Iterator, ArrayAccess {
|
||||
* @param int $accepted_args The number of arguments the function accepts.
|
||||
*/
|
||||
public function add_filter( $tag, $function_to_add, $priority, $accepted_args ) {
|
||||
$idx = _wp_filter_build_unique_id( $tag, $function_to_add, $priority );
|
||||
$idx = _wp_filter_build_unique_id( $tag, $function_to_add, $priority );
|
||||
$priority_existed = isset( $this->callbacks[ $priority ] );
|
||||
|
||||
$this->callbacks[ $priority ][ $idx ] = array(
|
||||
'function' => $function_to_add,
|
||||
'accepted_args' => $accepted_args
|
||||
'function' => $function_to_add,
|
||||
'accepted_args' => $accepted_args,
|
||||
);
|
||||
|
||||
// if we're adding a new priority to the list, put them back in sorted order
|
||||
@@ -243,7 +243,7 @@ final class WP_Hook implements Iterator, ArrayAccess {
|
||||
|
||||
if ( false === $priority ) {
|
||||
$this->callbacks = array();
|
||||
} else if ( isset( $this->callbacks[ $priority ] ) ) {
|
||||
} elseif ( isset( $this->callbacks[ $priority ] ) ) {
|
||||
unset( $this->callbacks[ $priority ] );
|
||||
}
|
||||
|
||||
@@ -269,14 +269,14 @@ final class WP_Hook implements Iterator, ArrayAccess {
|
||||
$nesting_level = $this->nesting_level++;
|
||||
|
||||
$this->iterations[ $nesting_level ] = array_keys( $this->callbacks );
|
||||
$num_args = count( $args );
|
||||
$num_args = count( $args );
|
||||
|
||||
do {
|
||||
$this->current_priority[ $nesting_level ] = $priority = current( $this->iterations[ $nesting_level ] );
|
||||
|
||||
foreach ( $this->callbacks[ $priority ] as $the_ ) {
|
||||
if( ! $this->doing_action ) {
|
||||
$args[ 0 ] = $value;
|
||||
if ( ! $this->doing_action ) {
|
||||
$args[0] = $value;
|
||||
}
|
||||
|
||||
// Avoid the array_slice if possible.
|
||||
@@ -285,7 +285,7 @@ final class WP_Hook implements Iterator, ArrayAccess {
|
||||
} elseif ( $the_['accepted_args'] >= $num_args ) {
|
||||
$value = call_user_func_array( $the_['function'], $args );
|
||||
} else {
|
||||
$value = call_user_func_array( $the_['function'], array_slice( $args, 0, (int)$the_['accepted_args'] ) );
|
||||
$value = call_user_func_array( $the_['function'], array_slice( $args, 0, (int) $the_['accepted_args'] ) );
|
||||
}
|
||||
}
|
||||
} while ( false !== next( $this->iterations[ $nesting_level ] ) );
|
||||
@@ -323,7 +323,7 @@ final class WP_Hook implements Iterator, ArrayAccess {
|
||||
* @param array $args Arguments to pass to the hook callbacks. Passed by reference.
|
||||
*/
|
||||
public function do_all_hook( &$args ) {
|
||||
$nesting_level = $this->nesting_level++;
|
||||
$nesting_level = $this->nesting_level++;
|
||||
$this->iterations[ $nesting_level ] = array_keys( $this->callbacks );
|
||||
|
||||
do {
|
||||
|
||||
Reference in New Issue
Block a user