wp_list_pluck() performance improvement. Props Otto42. fixes #18230

git-svn-id: https://develop.svn.wordpress.org/trunk@18602 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2011-08-25 18:22:17 +00:00
parent 51f1d1adf0
commit 2b4d72c471
1 changed files with 4 additions and 2 deletions

View File

@ -3220,8 +3220,10 @@ function wp_list_filter( $list, $args = array(), $operator = 'AND' ) {
*/
function wp_list_pluck( $list, $field ) {
foreach ( $list as $key => $value ) {
$value = (array) $value;
$list[ $key ] = $value[ $field ];
if ( is_object( $value ) )
$list[ $key ] = $value->$field;
else
$list[ $key ] = $value[ $field ];
}
return $list;