wp_parse_list

The timeline below displays how wordpress function wp_parse_list has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.2

/**
 * Converts a comma- or space-separated list of scalar values to an array.
 *
 * @since 5.1.0
 *
 * @param array|string $input_list List of values.
 * @return array Array of values.
 */
function wp_parse_list($input_list)
{
    if (!is_array($input_list)) {
        return preg_split('/[\s,]+/', $input_list, -1, PREG_SPLIT_NO_EMPTY);
    }
    // Validate all entries of the list are scalar.
    $input_list = array_filter($input_list, 'is_scalar');
    return $input_list;
}

WordPress Version: 6.1

/**
 * Converts a comma- or space-separated list of scalar values to an array.
 *
 * @since 5.1.0
 *
 * @param array|string $list List of values.
 * @return array Array of values.
 */
function wp_parse_list($list)
{
    if (!is_array($list)) {
        return preg_split('/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY);
    }
    // Validate all entries of the list are scalar.
    $list = array_filter($list, 'is_scalar');
    return $list;
}

WordPress Version: 5.7

/**
 * Converts a comma- or space-separated list of scalar values to an array.
 *
 * @since 5.1.0
 *
 * @param array|string $list List of values.
 * @return array Array of values.
 */
function wp_parse_list($list)
{
    if (!is_array($list)) {
        return preg_split('/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY);
    }
    return $list;
}

WordPress Version: 5.1

/**
 * Cleans up an array, comma- or space-separated list of scalar values.
 *
 * @since 5.1.0
 *
 * @param array|string $list List of values.
 * @return array Sanitized array of values.
 */
function wp_parse_list($list)
{
    if (!is_array($list)) {
        return preg_split('/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY);
    }
    return $list;
}