Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
Command::limit_item_to_fields( array $item, array $fields )
Reduce an item to specific fields.
Contents
Parameters Parameters
- $item
-
(array) (Required)
- $fields
-
(array) (Required)
Return Return
(array)
Source Source
File: libraries/lifterlms-cli/src/Commands/Restful/Command.php
655 656 657 658 659 660 661 662 663 664 665 666 667 668 | private static function limit_item_to_fields( $item , $fields ) { if ( empty ( $fields ) ) { return $item ; } if ( is_string ( $fields ) ) { $fields = explode ( ',' , $fields ); } foreach ( $item as $i => $field ) { if ( ! in_array( $i , $fields ) ) { unset( $item [ $i ] ); } } return $item ; } |
Expand full source code Collapse full source code View on GitHub