WC_REST_System_Status_V2_Controller::check_if_field_item_exists() private WC 3.9.0
Check if field item exists.
{} It's a method of the class: WC_REST_System_Status_V2_Controller{}
No Hooks.
Return
true/false.
Usage
// private - for code of main (parent) class only $result = $this->check_if_field_item_exists( $section, $items, $fields );
- $section(string) (required)
- Fields section.
- $items(array) (required)
- List of items to check for.
- $fields(array) (required)
- List of fields to be included on the response.
Changelog
Since 3.9.0 | Introduced. |
Code of WC_REST_System_Status_V2_Controller::check_if_field_item_exists() WC REST System Status V2 Controller::check if field item exists WC 5.0.0
private function check_if_field_item_exists( $section, $items, $fields ) {
if ( ! in_array( $section, $fields, true ) ) {
return false;
}
$exclude = array();
foreach ( $fields as $field ) {
$values = explode( '.', $field );
if ( $section !== $values[0] || empty( $values[1] ) ) {
continue;
}
$exclude[] = $values[1];
}
return 0 <= count( array_intersect( $items, $exclude ) );
}