ACF_Location_Attachment::match
Matches the provided rule against the screen args returning a bool result.
Метод класса: ACF_Location_Attachment{}
Хуков нет.
Возвращает
true|false.
Использование
$ACF_Location_Attachment = new ACF_Location_Attachment(); $ACF_Location_Attachment->match( $rule, $screen, $field_group );
- $rule(массив) (обязательный)
- The location rule.
- $screen(массив) (обязательный)
- The screen args.
- $field_group(массив) (обязательный)
- The field group settings.
Список изменений
| С версии 5.9.0 | Введена. |
Код ACF_Location_Attachment::match() ACF Location Attachment::match ACF 6.4.2
public function match( $rule, $screen, $field_group ) {
// Check screen args.
if ( isset( $screen['attachment'] ) ) {
$attachment = $screen['attachment'];
} else {
return false;
}
// Get attachment mime type
$mime_type = get_post_mime_type( $attachment );
// Allow for unspecific mim_type matching such as "image" or "video".
if ( ! strpos( $rule['value'], '/' ) ) {
// Explode mime_type into bits ([0] => type, [1] => subtype) and match type.
$bits = explode( '/', $mime_type );
if ( $bits[0] === $rule['value'] ) {
$mime_type = $rule['value'];
}
}
return $this->compare_to_rule( $mime_type, $rule );
}