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

git-svn-id: http://svn.automattic.com/wordpress/trunk@18602 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2011-08-25 18:22:17 +00:00
parent c7e870877c
commit 8edc944b01
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;