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
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
| 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.