Skip to:
Content

BuddyPress.org

Changeset 12699


Ignore:
Timestamp:
08/01/2020 02:08:12 AM (7 months ago)
Author:
imath
Message:

Make sure wp_parse_list() function is available for the BP REST API

Fixes #8341

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-wpabstraction.php

    r12683 r12699  
    473473}
    474474add_action( bp_delete_site_hook(), 'bp_delete_site', 10, 2 );
     475
     476if ( ! function_exists( 'wp_parse_list' ) ) {
     477    /**
     478     * Cleans up an array, comma- or space-separated list of scalar values.
     479     *
     480     * As BuddyPress supports older WordPress versions than 5.1 (4.9 & 5.0),
     481     * the BP REST API needs this function to be available.
     482     *
     483     * @since 7.0.0
     484     *
     485     * @param array|string $list List of values.
     486     * @return array Sanitized array of values.
     487     */
     488    function wp_parse_list( $list ) {
     489        if ( ! is_array( $list ) ) {
     490            return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY );
     491        }
     492
     493        return $list;
     494    }
     495}
Note: See TracChangeset for help on using the changeset viewer.