mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
General: Validate input of wp_list_pluck().
`wp_list_pluck()` is used by WordPress to pluck items from a list. Of course, this requires a list. This validates the input of `wp_list_pluck()` to ensure it is a list. This matches the behaviour of `wp_list_sort()` and `wp_filter_object_list()`. Props marv2, davidbaumwald, mkox, SergeyBiryukov, dd32. Fixes #54751. git-svn-id: https://develop.svn.wordpress.org/trunk@53045 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -5176,6 +5176,10 @@ function wp_list_filter( $list, $args = array(), $operator = 'AND' ) {
|
||||
* `$list` will be preserved in the results.
|
||||
*/
|
||||
function wp_list_pluck( $list, $field, $index_key = null ) {
|
||||
if ( ! is_array( $list ) ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$util = new WP_List_Util( $list );
|
||||
|
||||
return $util->pluck( $field, $index_key );
|
||||
|
||||
Reference in New Issue
Block a user