BP_REST_Blogs_Endpoint::get_item_schema()

Get the blogs schema, conforming to JSON Schema.


Return Return

(array)


Source Source

File: bp-blogs/classes/class-bp-rest-blogs-endpoint.php

	public function get_item_schema() {
		if ( is_null( $this->schema ) ) {
			$schema = array(
				'$schema'    => 'http://json-schema.org/draft-04/schema#',
				'title'      => 'bp_blogs',
				'type'       => 'object',
				'properties' => array(
					'id'            => array(
						'context'     => array( 'view', 'edit', 'embed' ),
						'description' => __( 'A unique numeric ID for the blog.', 'buddypress' ),
						'readonly'    => true,
						'type'        => 'integer',
					),
					'user_id'       => array(
						'context'     => array( 'view', 'edit', 'embed' ),
						'description' => __( 'A unique numeric ID for the blog admin.', 'buddypress' ),
						'readonly'    => true,
						'type'        => 'integer',
					),
					'name'          => array(
						'context'     => array( 'view', 'edit', 'embed' ),
						'description' => __( 'The name of the blog.', 'buddypress' ),
						'readonly'    => true,
						'type'        => 'string',
						'arg_options' => array(
							'sanitize_callback' => 'sanitize_text_field',
						),
					),
					'permalink'     => array(
						'context'     => array( 'view', 'edit', 'embed' ),
						'description' => __( 'The permalink of the blog.', 'buddypress' ),
						'readonly'    => true,
						'type'        => 'string',
						'format'      => 'uri',
					),
					'description'   => array(
						'context'     => array( 'view', 'edit', 'embed' ),
						'description' => __( 'The description of the blog.', 'buddypress' ),
						'readonly'    => true,
						'type'        => 'string',
					),
					'path'          => array(
						'context'     => array( 'view', 'edit', 'embed' ),
						'description' => __( 'The path of the blog.', 'buddypress' ),
						'readonly'    => true,
						'type'        => 'string',
					),
					'domain'        => array(
						'context'     => array( 'view', 'edit', 'embed' ),
						'description' => __( 'the domain of the blog.', 'buddypress' ),
						'readonly'    => true,
						'type'        => 'string',
					),
					'last_activity' => array(
						'context'     => array( 'view', 'edit', 'embed' ),
						'description' => __( "The last activity date from the blog, in the site's timezone.", 'buddypress' ),
						'type'        => 'string',
						'format'      => 'date-time',
					),
				),
			);

			if ( true === buddypress()->avatar->show_avatars ) {
				$avatar_properties = array();

				$avatar_properties['full'] = array(
					/* 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).', 'buddypress' ), number_format_i18n( bp_core_avatar_full_width() ), number_format_i18n( bp_core_avatar_full_height() ) ),
					'type'        => 'string',
					'format'      => 'uri',
					'context'     => array( 'view', 'edit', 'embed' ),
				);

				$avatar_properties['thumb'] = array(
					/* 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).', 'buddypress' ), number_format_i18n( bp_core_avatar_thumb_width() ), number_format_i18n( bp_core_avatar_thumb_height() ) ),
					'type'        => 'string',
					'format'      => 'uri',
					'context'     => array( 'view', 'edit', 'embed' ),
				);

				$schema['properties']['avatar_urls'] = array(
					'description' => __( 'Avatar URLs for the blog.', 'buddypress' ),
					'type'        => 'object',
					'context'     => array( 'view', 'edit', 'embed' ),
					'readonly'    => true,
					'properties'  => $avatar_properties,
				);
			}

			// Cache current schema here.
			$this->schema = $schema;
		}

		/**
		 * Filter the blogs schema.
		 *
		 * @since 6.0.0
		 *
		 * @param array $schema The endpoint schema.
		 */
		return apply_filters( 'bp_rest_blogs_schema', $this->add_additional_fields_schema( $this->schema ) );
	}


Top ↑

Changelog Changelog

Changelog
Version Description
6.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.