Created
July 31, 2019 05:16
-
-
Save imath/6a9191f1f676d5660a79aec3aa2c9b16 to your computer and use it in GitHub Desktop.
BuddyPress example block: Put this two file into a `bp-example-block` folder before dropping it into `/wp-content/plugins/`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
( 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