BP_REST_Activity_Endpoint::get_item_schema()
Get the plugin schema, conforming to JSON Schema.
Description
Return
(array)
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( 'embed', 'view', 'edit' ),
'description' => __( 'A unique numeric ID for the activity.', 'buddyboss' ),
'readonly' => true,
'type' => 'integer',
),
'primary_item_id' => array(
'context' => array( 'embed', 'view', 'edit' ),
'description' => __( 'The ID of some other object primarily associated with this one.', 'buddyboss' ),
'type' => 'integer',
),
'secondary_item_id' => array(
'context' => array( 'embed', 'view', 'edit' ),
'description' => __( 'The ID of some other object also associated with this one.', 'buddyboss' ),
'type' => 'integer',
),
'user_id' => array(
'context' => array( 'embed', 'view', 'edit' ),
'description' => __( 'The ID for the author of the activity.', 'buddyboss' ),
'type' => 'integer',
),
'name' => array(
'context' => array( 'embed', 'view', 'edit' ),
'description' => __( 'User\'s display name for the activity.', 'buddyboss' ),
'type' => 'string',
),
'link' => array(
'context' => array( 'embed', 'view', 'edit' ),
'description' => __( 'The permalink to this activity on the site.', 'buddyboss' ),
'format' => 'uri',
'type' => 'string',
),
'component' => array(
'context' => array( 'embed', 'view', 'edit' ),
'description' => __( 'The active BuddyPress component the activity relates to.', 'buddyboss' ),
'type' => 'string',
'enum' => array_keys( buddypress()->active_components ),
'arg_options' => array(
'sanitize_callback' => 'sanitize_key',
),
),
'type' => array(
'context' => array( 'embed', 'view', 'edit' ),
'description' => __( 'The activity type of the activity.', 'buddyboss' ),
'type' => 'string',
'enum' => array_keys( bp_activity_get_types() ),
'arg_options' => array(
'sanitize_callback' => 'sanitize_key',
),
),
'title' => array(
'context' => array( 'embed', 'view', 'edit' ),
'description' => __( 'The description of the activity\'s type (eg: Username posted an update)', 'buddyboss' ),
'type' => 'string',
'readonly' => true,
'arg_options' => array(
'sanitize_callback' => 'sanitize_text_field',
),
),
'content' => array(
'context' => array( 'embed', 'view', 'edit' ),
'description' => __( 'Allowed HTML content for the activity.', 'buddyboss' ),
'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.', 'buddyboss' ),
'type' => 'string',
'context' => array( 'embed', 'edit' ),
),
'rendered' => array(
'description' => __( 'HTML content for the activity, transformed for display.', 'buddyboss' ),
'type' => 'string',
'context' => array( 'embed', 'view', 'edit' ),
'readonly' => true,
),
),
),
'date' => array(
'context' => array( 'embed', 'view', 'edit' ),
'description' => __( "The date the activity was published, in the site's timezone.", 'buddyboss' ),
'type' => 'string',
'format' => 'date-time',
),
'status' => array(
'context' => array( 'embed', 'view', 'edit' ),
'description' => __( 'Whether the activity has been marked as spam or not.', 'buddyboss' ),
'type' => 'string',
'enum' => array( 'published', 'spam' ),
'readonly' => true,
'arg_options' => array(
'sanitize_callback' => 'sanitize_key',
),
),
'comments' => array(
'context' => array( 'embed', 'view', 'edit' ),
'description' => __( 'A list of objects children of the activity object.', 'buddyboss' ),
'type' => 'array',
'readonly' => true,
),
'comment_count' => array(
'context' => array( 'embed', 'view', 'edit' ),
'description' => __( 'Total number of comments of the activity object.', 'buddyboss' ),
'type' => 'integer',
'readonly' => true,
),
'hidden' => array(
'context' => array( 'edit' ),
'description' => __( 'Whether the activity object should be sitewide hidden or not.', 'buddyboss' ),
'type' => 'boolean',
),
'favorited' => array(
'context' => array( 'embed', 'view', 'edit' ),
'description' => __( 'Whether the activity object has been favorited by the current user.', 'buddyboss' ),
'type' => 'boolean',
'readonly' => true,
),
'can_favorite' => array(
'context' => array( 'embed', 'view', 'edit' ),
'description' => __( 'Whether or not user have the favorite access for the activity object.', 'buddyboss' ),
'type' => 'boolean',
'readonly' => true,
),
'favorite_count' => array(
'context' => array( 'embed', 'view', 'edit' ),
'description' => __( 'Favorite count for the activity object.', 'buddyboss' ),
'type' => 'boolean',
'readonly' => true,
),
'can_comment' => array(
'context' => array( 'embed', 'view', 'edit' ),
'description' => __( 'Whether or not user have the comment access for the activity object.', 'buddyboss' ),
'type' => 'boolean',
'readonly' => true,
),
'comment_count' => array(
'context' => array( 'embed', 'view', 'edit' ),
'description' => __( 'Comment count for the activity object.', 'buddyboss' ),
'type' => 'boolean',
'readonly' => true,
),
'can_delete' => array(
'context' => array( 'embed', 'view', 'edit' ),
'description' => __( 'Whether or not user have the delete access for the activity object.', 'buddyboss' ),
'type' => 'boolean',
'readonly' => true,
),
'content_stripped' => array(
'context' => array( 'embed', 'view', 'edit' ),
'description' => __( 'Content for the activity without HTML tags.', 'buddyboss' ),
'type' => 'string',
'readonly' => true,
),
'privacy' => array(
'context' => array( 'embed', 'view', 'edit' ),
'description' => __( 'Privacy of the activity.', 'buddyboss' ),
'type' => 'string',
'enum' => array( 'public', 'loggedin', 'onlyme', 'friends', 'media' ),
),
),
);
// Avatars.
if ( true === buddypress()->avatar->show_avatars ) {
$avatar_properties = array();
$avatar_properties['full'] = array(
'context' => array( 'embed', 'view', 'edit' ),
/* translators: 1: Full avatar width in pixels. 2: Full avatar height in pixels */
'description' => sprintf( __( 'Avatar URL with full image size (%1$d x %2$d pixels).', 'buddyboss' ), 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( 'embed', 'view', 'edit' ),
/* translators: 1: Thumb avatar width in pixels. 2: Thumb avatar height in pixels */
'description' => sprintf( __( 'Avatar URL with thumb image size (%1$d x %2$d pixels).', 'buddyboss' ), 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( 'embed', 'view', 'edit' ),
'description' => __( 'Avatar URLs for the author of the activity.', 'buddyboss' ),
'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
| Version | Description |
|---|---|
| 0.1.0 | Introduced. |
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.