WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WP_Hook::resort_active_iterations() private WP 4.7.0

Handles resetting callback priority keys mid-iteration.

Это метод класса: WP_Hook{}

Хуков нет.

Возвращает

Null. Ничего.

Использование

// private - только в коде основоного (родительского) класса
$result = $this->resort_active_iterations( $new_priority, $priority_existed );
$new_priority(true/false/число)
The priority of the new filter being added.
По умолчанию: false, for no priority being added
$priority_existed(true/false)
Flag for whether the priority already existed before the new filter was added.
По умолчанию: false

Список изменений

С версии 4.7.0 Введена.

Код WP_Hook::resort_active_iterations() WP 5.5.1

wp-includes/class-wp-hook.php
<?php
private function resort_active_iterations( $new_priority = false, $priority_existed = false ) {
	$new_priorities = array_keys( $this->callbacks );

	// If there are no remaining hooks, clear out all running iterations.
	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 we're already at the end of this iteration, just leave the array pointer where it is.
		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 we have a new priority that didn't exist, but ::apply_filters() or ::do_action() thinks it's the current priority...
		if ( $new_priority === $this->current_priority[ $index ] && ! $priority_existed ) {
			/*
			 * ...and the new priority is the same as what $this->iterations thinks is the previous
			 * priority, we need to move back to it.
			 */

			if ( false === current( $iteration ) ) {
				// If we've already moved off the end of the array, go back to the last element.
				$prev = end( $iteration );
			} else {
				// Otherwise, just go back to the previous element.
				$prev = prev( $iteration );
			}
			if ( false === $prev ) {
				// Start of the array. Reset, and go about our day.
				reset( $iteration );
			} elseif ( $new_priority !== $prev ) {
				// Previous wasn't the same. Move forward again.
				next( $iteration );
			}
		}
	}
	unset( $iteration );
}