bp_block_category( array $categories = array(), object $post = null )

Adds a BuddyPress category to house BuddyPress blocks.

Description

Parameters

$categories

(Optional) Array of block categories.

Default value: array()

$post

(Optional) Post being loaded.

Default value: null

Source

File: bp-core/admin/bp-core-admin-functions.php

2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
function bp_block_category( $categories = array(), $post = null ) {
    if ( ! ( $post instanceof WP_Post ) ) {
        return $categories;
    }
 
    /**
     * Filter here to add/remove the supported post types for the BuddyPress blocks category.
     *
     * @since 5.0.0
     *
     * @param array $value The list of supported post types. Defaults to WordPress built-in ones.
     */
    $post_types = apply_filters( 'bp_block_category_post_types', array( 'post', 'page' ) );
 
    if ( ! $post_types ) {
        return $categories;
    }
 
    // Get the post type of the current item.
    $post_type = get_post_type( $post );
 
    if ( ! in_array( $post_type, $post_types, true ) ) {
        return $categories;
    }
 
    return array_merge(
            $categories,
            array(
                    array(
                            'slug'  => 'buddyboss',
                            'title' => __( 'BuddyBoss', 'buddyboss' ),
                            'icon'  => '',
                    ),
            )
    );
}

Changelog

Changelog
Version Description
BuddyBoss 1.3.5 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.