Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
BuddyPress example block: Put this two file into a `bp-example-block` folder before dropping it into `/wp-content/plugins/`
<?php
/**
* Plugin Name: BP Example Block
* Plugin URI: https://buddypress.org/
* Description: Example of BuddyPress block.
* Author: The BuddyPress Community
* Author URI: https://buddypress.org/
* Version: 1.0.0
* Text Domain: buddypress
* Domain Path: /languages/
* License: GPLv2 or later
*/
// Exit if accessed directly
defined( 'ABSPATH' ) || exit;
function bpeb_register_block() {
wp_register_script(
'bp-example-block',
plugins_url( 'bp-example-block.js', __FILE__ ),
array( 'wp-blocks', 'wp-element' )
);
register_block_type( 'bpeb/example-block', array(
'editor_script' => 'bp-example-block',
) );
}
add_action( 'init', 'bpeb_register_block' );
( function( blocks, element ) {
var el = element.createElement;
blocks.registerBlockType( 'bpeb/example-block', {
title: 'BuddyPress example block',
description: 'A BuddyPress example block to show how to be listed into the BuddyPress blocks category.',
icon: 'buddicons-groups',
category: 'buddypress',
edit: function() {
return el(
'p',
{},
'BuddyPress blocks are stored into the BuddyPress blocks category.'
);
},
save: function() {
return el(
'p',
{},
'BuddyPress blocks are stored into the BuddyPress blocks category.'
);
},
} );
}(
window.wp.blocks,
window.wp.element
) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.