ACF_Ajax_Check_Screen::get_page_parent_arg │ protected │ ACF 6.8.11

Returns a submitted page parent if it is none or another post of the same type, or null.

"(no parent)" is sent as an empty value.

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

Хуков нет.

Возвращает

integer|null.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_page_parent_arg( $post, $page_parent );
$post(WP_Post) (обязательный)
The post being edited.
$page_parent(разное) (обязательный)
The submitted page parent.

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

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

Код ACF_Ajax_Check_Screen::get_page_parent_arg() ACF 6.8.11

protected function get_page_parent_arg( $post, $page_parent ) {
	if ( '' === $page_parent ) {
		return 0;
	}

	if ( ! is_scalar( $page_parent ) || ! is_numeric( $page_parent ) ) {
		return null;
	}

	$page_parent = (int) $page_parent;

	if ( 0 === $page_parent || ( $page_parent !== $post->ID && get_post_type( $page_parent ) === $post->post_type ) ) {
		return $page_parent;
	}

	return null;
}