ACF_Location_Attachment::match
Matches the provided rule against the screen args returning a bool result.
Method of the class: ACF_Location_Attachment{}
No Hooks.
Returns
true|false.
Usage
$ACF_Location_Attachment = new ACF_Location_Attachment(); $ACF_Location_Attachment->match( $rule, $screen, $field_group );
- $rule(array) (required)
- The location rule.
- $screen(array) (required)
- The screen args.
- $field_group(array) (required)
- The field group settings.
Changelog
| Since 5.9.0 | Introduced. |
ACF_Location_Attachment::match() ACF Location Attachment::match code ACF 6.0.4
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 );
}