Source
File: wp-includes/class-wp-hook.php
private function resort_active_iterations( $new_priority = false, $priority_existed = false ) {
$new_priorities = array_keys( $this->callbacks );
if ( ! $new_priorities ) {
foreach ( $this->iterations as $index => $iteration ) {
$this->iterations[ $index ] = $new_priorities;
}
return;
}
$min = min( $new_priorities );
foreach ( $this->iterations as $index => &$iteration ) {
$current = current( $iteration );
if ( false === $current ) {
continue;
}
$iteration = $new_priorities;
if ( $current < $min ) {
array_unshift( $iteration, $current );
continue;
}
while ( current( $iteration ) < $current ) {
if ( false === next( $iteration ) ) {
break;
}
}
if ( $new_priority === $this->current_priority[ $index ] && ! $priority_existed ) {
if ( false === current( $iteration ) ) {
$prev = end( $iteration );
} else {
$prev = prev( $iteration );
}
if ( false === $prev ) {
reset( $iteration );
} elseif ( $new_priority !== $prev ) {
next( $iteration );
}
}
}
unset( $iteration );
}