Extract top-level property

Using _fields, we can specify a sub-property like environment.version.
In that case, we need to extract the top-level property so we known
which function to run.
This commit is contained in:
Josh Betz 2022-05-02 11:17:36 -05:00
parent 30f41c96e8
commit b6b5b8f33b
1 changed files with 4 additions and 1 deletions

View File

@ -612,7 +612,10 @@ class WC_REST_System_Status_V2_Controller extends WC_REST_Controller {
$items = array();
foreach ( $fields as $field ) {
switch ( $field ) {
// If we're looking for a sub-property, like environment.version we need
// to extract the first-level property here so we know which function to run.
list( $prop ) = explode( '.', $field, 2 );
switch ( $prop ) {
case 'environment':
$items['environment'] = $this->get_environment_info_per_fields( $fields );
break;