Skip to content

Instantly share code, notes, and snippets.

View renatonascalves's full-sized avatar
🇧🇷

Renato Alves renatonascalves

🇧🇷
View GitHub Profile
@imath
imath / bp-custom.php
Created July 12, 2019 14:17
Registering REST Fields for the BP REST API
<?php
// Registers a REST field for the Activity Endpoints.
function example_register_activity_rest_field() {
bp_rest_register_field(
'activity', // Id of the BuddyPress component the REST field is about
'example_field', // Used into the REST response/request
array(
'get_callback' => 'example_get_rest_field_callback', // The function to use to get the value of the REST Field
'update_callback' => 'example_update_rest_field_callback', // The function to use to update the value of the REST Field
@imath
imath / bp-example-block.php
Created July 31, 2019 05:16
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/