BP_REST_Activity_Endpoint::get_item_schema()
Get the plugin schema, conforming to JSON Schema.
Description Description
Return Return
(array)
Source Source
File: bp-activity/classes/class-bp-rest-activity-endpoint.php
public function get_item_schema() {
$schema = array(
'$schema' => 'http://json-schema.org/draft-04/schema#',
'title' => 'bp_activity',
'type' => 'object',
'properties' => array(
'id' => array(
'context' => array( 'view', 'edit' ),
'description' => __( 'A unique numeric ID for the activity.', 'buddypress' ),
'readonly' => true,
'type' => 'integer',
),
'primary_item_id' => array(
'context' => array( 'view', 'edit' ),
'description' => __( 'The ID of some other object primarily associated with this one.', 'buddypress' ),
'type' => 'integer',
),
'secondary_item_id' => array(
'context' => array( 'view', 'edit' ),
'description' => __( 'The ID of some other object also associated with this one.', 'buddypress' ),
'type' => 'integer',
),
'user_id' => array(
'context' => array( 'view', 'edit' ),
'description' => __( 'The ID for the author of the activity.', 'buddypress' ),
'type' => 'integer',
),
'link' => array(
'context' => array( 'view', 'edit' ),
'description' => __( 'The permalink to this activity on the site.', 'buddypress' ),
'format' => 'uri',
'type' => 'string',
),
'component' => array(
'context' => array( 'view', 'edit' ),
'description' => __( 'The active BuddyPress component the activity relates to.', 'buddypress' ),
'type' => 'string',
'enum' => array_keys( buddypress()->active_components ),
'arg_options' => array(
'sanitize_callback' => 'sanitize_key',
),
),
'type' => array(
'context' => array( 'view', 'edit' ),
'description' => __( 'The activity type of the activity.', 'buddypress' ),
'type' => 'string',
'enum' => array_keys( bp_activity_get_types() ),
'arg_options' => array(
'sanitize_callback' => 'sanitize_key',
),
),
'title' => array(
'context' => array( 'view', 'edit' ),
'description' => __( 'The description of the activity\'s type (eg: Username posted an update)', 'buddypress' ),
'type' => 'string',
'readonly' => true,
'arg_options' => array(
'sanitize_callback' => 'sanitize_text_field',
),
),
'content' => array(
'context' => array( 'view', 'edit' ),
'description' => __( 'Allowed HTML content for the activity.', 'buddypress' ),
'type' => 'object',
'arg_options' => array(
'sanitize_callback' => null, // Note: sanitization implemented in self::prepare_item_for_database().
'validate_callback' => null, // Note: validation implemented in self::prepare_item_for_database().
),
'properties' => array(
'raw' => array(
'description' => __( 'Content for the activity, as it exists in the database.', 'buddypress' ),
'type' => 'string',
'context' => array( 'edit' ),
),
'rendered' => array(
'description' => __( 'HTML content for the activity, transformed for display.', 'buddypress' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
),
),
'date' => array(
'context' => array( 'view', 'edit' ),
'description' => __( "The date the activity was published, in the site's timezone.", 'buddypress' ),
'type' => 'string',
'format' => 'date-time',
),
'status' => array(
'context' => array( 'view', 'edit' ),
'description' => __( 'Whether the activity has been marked as spam or not.', 'buddypress' ),
'type' => 'string',
'enum' => array( 'published', 'spam' ),
'readonly' => true,
'arg_options' => array(
'sanitize_callback' => 'sanitize_key',
),
),
'comments' => array(
'context' => array( 'view', 'edit' ),
'description' => __( 'A list of objects children of the activity object.', 'buddypress' ),
'type' => 'array',
'readonly' => true,
),
'comment_count' => array(
'context' => array( 'view', 'edit' ),
'description' => __( 'Total number of comments of the activity object.', 'buddypress' ),
'type' => 'integer',
'readonly' => true,
),
'hidden' => array(
'context' => array( 'edit' ),
'description' => __( 'Whether the activity object should be sitewide hidden or not.', 'buddypress' ),
'type' => 'boolean',
),
'favorited' => array(
'context' => array( 'view', 'edit' ),
'description' => __( 'Whether the activity object has been favorited by the current user.', 'buddypress' ),
'type' => 'boolean',
'readonly' => true,
),
),
);
// Avatars.
if ( true === buddypress()->avatar->show_avatars ) {
$avatar_properties = array();
$avatar_properties['full'] = array(
'context' => array( 'view', 'edit' ),
/* translators: Full image size for the member Avatar */
'description' => sprintf( __( 'Avatar URL with full image size (%1$d x %2$d pixels).', 'buddypress' ), number_format_i18n( bp_core_avatar_full_width() ), number_format_i18n( bp_core_avatar_full_height() ) ),
'type' => 'string',
'format' => 'uri',
);
$avatar_properties['thumb'] = array(
'context' => array( 'view', 'edit' ),
/* translators: Thumb imaze size for the member Avatar */
'description' => sprintf( __( 'Avatar URL with thumb image size (%1$d x %2$d pixels).', 'buddypress' ), number_format_i18n( bp_core_avatar_thumb_width() ), number_format_i18n( bp_core_avatar_thumb_height() ) ),
'type' => 'string',
'format' => 'uri',
);
$schema['properties']['user_avatar'] = array(
'context' => array( 'view', 'edit' ),
'description' => __( 'Avatar URLs for the author of the activity.', 'buddypress' ),
'type' => 'object',
'readonly' => true,
'properties' => $avatar_properties,
);
}
/**
* Filters the activity schema.
*
* @param string $schema The endpoint schema.
*/
return apply_filters( 'bp_rest_activity_schema', $this->add_additional_fields_schema( $schema ) );
}
Changelog Changelog
| Version | Description |
|---|---|
| 5.0.0 | Introduced. |