ACF_Location_Page_Template::match
Matches the provided rule against the screen args returning a bool result.
Method of the class: ACF_Location_Page_Template{}
No Hooks.
Returns
true|false.
Usage
$ACF_Location_Page_Template = new ACF_Location_Page_Template(); $ACF_Location_Page_Template->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_Page_Template::match() ACF Location Page Template::match code ACF 6.0.4
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;
}
// Page templates were extended in WordPress version 4.7 for all post types.
// Prevent this rule (which is scoped to the "page" post type) appearing on all post types without a template selected (default template).
if ( $rule['value'] === 'default' && $post_type !== 'page' ) {
return false;
}
// Match rule using Post Template logic.
return acf_get_location_type( 'post_template' )->match( $rule, $screen, $field_group );
}