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

ACF_Location_Page_Type::match() public ACF 5.9.0

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

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

Хуков нет.

Возвращает

true/false.

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

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

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

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

Код ACF_Location_Page_Type::match() ACF 5.9.1

<?php
public function match( $rule, $screen, $field_group ) {
	
	// Check screen args.
	if( isset($screen['post_id']) ) {
		$post_id = $screen['post_id'];
	} else {
		return false;
	}
	
	// Get post.
	$post = get_post( $post_id );
	if ( !$post ) {
		return false;
	}
	
	// Compare.
	switch( $rule['value'] ) {
		case 'front_page':
			$front_page = (int) get_option('page_on_front');
			$result = ( $front_page === $post->ID );
			break;
			
		case 'posts_page':
			$posts_page = (int) get_option('page_for_posts');
			$result = ( $posts_page === $post->ID );
			break;
			
		case 'top_level':
			$page_parent = (int) ( isset($screen['page_parent']) ? $screen['page_parent'] : $post->post_parent );
			$result = ( $page_parent === 0 );
			break;
			
		case 'parent':
        	$children = get_posts(array(
        		'post_type' 		=> $post->post_type,
        		'post_parent' 		=> $post->ID,
        		'posts_per_page'	=> 1,
				'fields'			=> 'ids',
			));
			$result = !empty( $children );
			break;
			
		case 'child':
			$page_parent = (int) ( isset($screen['page_parent']) ? $screen['page_parent'] : $post->post_parent );
			$result = ( $page_parent !== 0 );
			break;
				
		default:
			return false;
	}
	
	// Reverse result for "!=" operator.
        if( $rule['operator'] === '!=' ) {
        	return !$result;
        }
	return $result;
}