ACF_Location_Post_Template::match()publicACF 5.9.0

Matches the provided rule against the screen args returning a bool result.

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

Хуков нет.

Возвращает

true|false.

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

$ACF_Location_Post_Template = new ACF_Location_Post_Template();
$ACF_Location_Post_Template->match( $rule, $screen, $field_group );
$rule(массив) (обязательный)
The location rule.
$screen(массив) (обязательный)
The screen args.
$field_group(массив) (обязательный)
The field group settings.

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

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

Код ACF_Location_Post_Template::match() ACF 5.10.2

public function match( $rule, $screen, $field_group ) {

	// Check screen args.
	if ( isset( $screen['post_type'] ) ) {
		$post_type = $screen['post_type'];
	} elseif ( isset( $screen['post_id'] ) ) {
		$post_type = get_post_type( $screen['post_id'] );
	} else {
		return false;
	}

	// Check if this post type has templates.
	$post_templates = acf_get_post_templates();
	if ( ! isset( $post_templates[ $post_type ] ) ) {
		return false;
	}

	// Get page template allowing for screen or database value.
	if ( isset( $screen['page_template'] ) ) {
		$page_template = $screen['page_template'];
	} elseif ( isset( $screen['post_id'] ) ) {
		$page_template = get_post_meta( $screen['post_id'], '_wp_page_template', true );
	} else {
		$page_template = '';
	}

	// Treat empty value as default template.
	if ( $page_template === '' ) {
		$page_template = 'default';
	}

	// Compare rule against $page_template.
	return $this->compare_to_rule( $page_template, $rule );
}