_wp_get_abilities_match_meta()
Checks whether an ability's meta array matches a set of required key/value conditions.
All conditions must match (AND logic). Supports nested arrays for structured meta, e.g. array('mcp'=> array('public'=> true ) ).
Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.
No Hooks.
Returns
bool. True if all conditions match, false otherwise.
Usage
_wp_get_abilities_match_meta( $meta, $conditions ): bool;
- $meta(array) (required)
- The ability's meta array.
- $conditions(array) (required)
- The required key/value conditions to match against.
Changelog
| Since 7.1.0 | Introduced. |
_wp_get_abilities_match_meta() wp get abilities match meta code WP 7.1
function _wp_get_abilities_match_meta( array $meta, array $conditions ): bool {
foreach ( $conditions as $key => $value ) {
if ( ! array_key_exists( $key, $meta ) ) {
return false;
}
if ( is_array( $value ) ) {
if ( ! is_array( $meta[ $key ] ) || ! _wp_get_abilities_match_meta( $meta[ $key ], $value ) ) {
return false;
}
} elseif ( $meta[ $key ] !== $value ) {
return false;
}
}
return true;
}