BP Dev Chat Summary: July 10, 2019

BP REST API focus

REST fields (~= BuddyPress Components metadata)

PRs #189, #193, & #194 have been merged into the BP REST API by @espellcaste : they brought these REST fields for the Activity, Groups, Members, Messages, Notifications, and xProfile (field/group/data) endpoints.

If you are a BuddyPress plugin developer, here’s how you can use this feature to create/update and get your custom REST Fields.

// 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
			'schema'          => array(                                // The example_field REST schema.
				'description' => 'Example of Activity Meta Field',
				'type'        => 'string',
				'context'     => array( 'view', 'edit' ),
			),
		)
	);
}
add_action( 'bp_rest_api_init', 'example_register_activity_rest_field' );

/**
 * The function to use to get the value of the REST Field.
 *
 * @param  array  $array     The list of properties of the BuddyPress component's object.
 * @param  string $attribute The REST Field key used into the REST response.
 * @return string            The value of the REST Field to include into the REST response.
 */
function example_get_rest_field_callback( $array, $attribute ) {
	// The key of the metadata can be different from the REST Field key.
	$metadata_key = '_example_metadata_key';
	
	return bp_activity_get_meta( $array['id'], $metadata_key );
}

/**
 * The function to use to update the value of the REST Field.
 *
 * @param  object $object    The BuddyPress component's object that was just created/updated during the request.
 *                           (in this case the BP_Activity_Activity object).
 * @return string $value     The value of the REST Field to save.
 * @param  string $attribute The REST Field key used into the REST response.
 */
function example_update_rest_field_callback( $object, $value, $attribute ) {
	// The key of the metadata can be different from the REST Field key.
	$metadata_key = '_example_metadata_key';
	
	bp_activity_update_meta( $object->id, $metadata_key, $value );
}

View the code on Gist.GitHub.com

REST links

The Message endpoint got its filterable links (See the prepare_links() method of its endpoint).

@espellcaste and I are agreeing the other components should also include a filter to let plugin developers eventually add custom links. #Needs-PR 😉

Documentation site about the BP REST API

We’ve discussed about the post where I suggest possible roads for a while with @espellcaste. In particular, I’ve shared my 2 concerns about the Restsplain plugin generated documentation :

  • I think we should use it to write a more “human understandable” documentation. For instance, use “Create an activity” instead of POST
  • It would be better to use our bp.apiRequest function in code examples instead of the fetch() one.

NB: After the Dev Chat, @johnjamesjacoby advised to keep docs and support on BuddyPress.org to avoid fragmentation, and to maintain user trust. I agreed it was best and opened a ticket on the Meta Trac (See #4601) to move forward.

Updates about the Tickets into the 5.0.0 milestone

It would be great to have the patches attached to the following list of tickets tested during the next 2 weeks:

Next dev-chat

It will happen on July 24th at 19:00 UTC in #BuddyPress slack channel. In the meantime: have fun contributing to BuddyPress 👩🏻‍💻, we have 1 month left before 5.0.0 first beta 🗓

#5-0

BP Dev Chat Agenda: July 10, 2019

This is the agenda for our next Dev Chat which will happen on July 10th at 19:00 UTC:

  • Updates about the latest BP REST API improvements.
  • BP REST API documentation site (please take a look at this post about a possible road if you haven’t already done it so far).
  • Updates about 5.0.0 tickets.

This meeting is held in the #BuddyPress channel of the Making WordPress Slack.

If you have anything you wish to add to this agenda or specific items related to those listed above, please leave a comment below.

#5-0

BP Dev-Chat Agenda

Hi everyone !

Let’s meet at 19:00 UTC on next Wednesday (12th of June) in #BuddyPress to talk about the 5.0.0 release. Here are the topics I’d like we discuss about during this meeting.

BP Rest API

To follow up with our last summary : it will be our main focus/feature for this release and we need to decide about:

  • Endpoints coverage.
  • The tool to use to generate the endpoints documentation.
  • BP Core API Usage : see 8045
  • Build process: as the BP Rest API will carry on be maintained from our GitHub repository, we need to update our build process to include needed files in the BuddyPress plugin’s package.

Tickets on the 5.0.0 roadmap

9 tickets are in the queue, let’s decide the ones we’ll fix/close before completing our milestone.

If you need/want to discuss about other topics, don’t hesitate to add them in comments 👍

#5-0

BuddyPress 4.3.0, a security and…

BuddyPress 4.3.0, a security and maintenance release, is now available. https://buddypress.org/2019/04/buddypress-4-3-0-security-and-maintenance-release/

BuddyPress 4.2.0, a security and…

BuddyPress 4.2.0, a security and maintenance release, is now available. https://buddypress.org/2019/02/buddypress-4-2-0-maintenance-and-security-release/

BuddyPress 4.1.0 is ready for…

BuddyPress 4.1.0 is ready for download: https://buddypress.org/2018/12/buddypress-4-1-0-maintenance-release/

BuddyPress 4.0.0 “Pequod”: https://buddypress.org/2018/11/buddypress-4-0-0-pequod/

BuddyPress 4.0.0 “Pequod”: https://buddypress.org/2018/11/buddypress-4-0-0-pequod/