BP_REST_Document_Endpoint::bbp_document_get_rest_field_callback( array $post, string $attribute )
The function to use to get documents of the topic/reply REST Field.
Description
Parameters
- $post
-
(Required) WP_Post object as array.
- $attribute
-
(Required) The REST Field key used into the REST response.
Return
(string) The value of the REST Field to include into the REST response.
Source
File: bp-document/classes/class-bp-rest-document-endpoint.php
protected function bbp_document_get_rest_field_callback( $post, $attribute ) {
$p_id = $post['id'];
if ( empty( $p_id ) ) {
return;
}
$document_ids = get_post_meta( $p_id, 'bp_document_ids', true );
$document_ids = trim( $document_ids );
$document_ids = explode( ',', $document_ids );
if ( empty( $document_ids ) ) {
return;
}
$documents = $this->assemble_response_data( array( 'document_ids' => $document_ids ) );
if ( empty( $documents['documents'] ) ) {
return;
}
$retval = array();
foreach ( $documents['documents'] as $document ) {
$retval[] = $this->document_get_prepare_response( $document, array( 'support' => 'forums' ) );
}
return $retval;
}
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.