ACF_Ajax_Check_Screen::get_screen_args │ protected │ ACF 6.8.11

Returns the location screen args to match field groups with for a post being edited.

The fields rendered here carry a field list signed for the post, which the post save accepts. So the post ID, post type and screen come from the post itself, and only the attributes the user can change in the editor are taken from the request, each checked against what they could actually set. Other args (users, options pages, other object types) are ignored. A signed list shows the fields were rendered; it doesn't authorise them.

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

Хуков нет.

Возвращает

array.

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

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

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

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

Код ACF_Ajax_Check_Screen::get_screen_args() ACF 6.8.11

protected function get_screen_args( $post, $request ) {
	$args = array(
		'screen'    => 'post',
		'post_id'   => $post->ID,
		'post_type' => $post->post_type,
		'ajax'      => true,
		'exists'    => acf_normalize_field_keys( $request['exists'] ?? array() ),
	);

	$page_type   = $request['page_type'] ?? null;
	$post_status = $request['post_status'] ?? null;
	$post_terms  = $request['post_terms'] ?? null;

	$editable = array(
		'page_template' => $this->get_page_template_arg( $post, $request['page_template'] ?? null ),
		'page_parent'   => $this->get_page_parent_arg( $post, $request['page_parent'] ?? null ),
		'page_type'     => in_array( $page_type, array( 'child', 'parent' ), true ) ? $page_type : null,
		'post_format'   => $this->get_post_format_arg( $post, $request['post_format'] ?? null ),
		'post_status'   => is_string( $post_status ) && $this->user_can_set_post_status( $post, $post_status ) ? $post_status : null,
		'post_terms'    => is_array( $post_terms ) ? $this->get_assignable_post_terms( $post, $post_terms ) : null,
	);

	// Args that weren't sent, or that the user couldn't set, are left to the post's saved values.
	foreach ( $editable as $name => $value ) {
		if ( null !== $value ) {
			$args[ $name ] = $value;
		}
	}

	return $args;
}