bp_block_category( array $categories = array(),  $editor_name_or_post = null )

Adds a BuddyPress category to house BuddyPress blocks.


Description Description


Parameters Parameters

$categories

(Optional) Array of block categories.

Default value: array()

$post

(Required) Post being loaded.


Top ↑

Source 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'  => 'buddypress',
			'title' => __( 'BuddyPress', 'buddypress' ),
			'icon'  => 'buddicons-buddypress-logo',
		),
	) );
}

Top ↑

Changelog Changelog

Changelog
Version Description
8.0.0 The bp_block_category_post_types filter has been deprecated.
5.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.