Yoast_Notification_Center::sort_notifications()privateYoast 1.0

Sort on type then priority.

Метод класса: Yoast_Notification_Center{}

Хуков нет.

Возвращает

int. 1, 0 or -1 for sorting offset.

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

// private - только в коде основоного (родительского) класса
$result = $this->sort_notifications( $a, $b );
$a(Yoast_Notification) (обязательный)
Compare with B.
$b(Yoast_Notification) (обязательный)
Compare with A.

Код Yoast_Notification_Center::sort_notifications() Yoast 22.4

private function sort_notifications( Yoast_Notification $a, Yoast_Notification $b ) {

	$a_type = $a->get_type();
	$b_type = $b->get_type();

	if ( $a_type === $b_type ) {
		return WPSEO_Utils::calc( $b->get_priority(), 'compare', $a->get_priority() );
	}

	if ( $a_type === 'error' ) {
		return -1;
	}

	if ( $b_type === 'error' ) {
		return 1;
	}

	return 0;
}