BP_REST_XProfile_Fields_Endpoint::get_item_schema()

Get the XProfile field schema, conforming to JSON Schema.


Return Return

(array)


Source Source

File: bp-xprofile/classes/class-bp-rest-xprofile-fields-endpoint.php

	public function get_item_schema() {
		if ( is_null( $this->schema ) ) {
			$this->schema = array(
				'$schema'    => 'http://json-schema.org/draft-04/schema#',
				'title'      => 'bp_xprofile_field',
				'type'       => 'object',
				'properties' => array(
					'id'                => array(
						'context'     => array( 'view', 'edit' ),
						'description' => __( 'A unique numeric ID for the profile field.', 'buddypress' ),
						'readonly'    => true,
						'type'        => 'integer',
					),
					'group_id'          => array(
						'context'     => array( 'view', 'edit' ),
						'description' => __( 'The ID of the group the field is part of.', 'buddypress' ),
						'type'        => 'integer',
					),
					'parent_id'         => array(
						'context'     => array( 'view', 'edit' ),
						'description' => __( 'The ID of the parent field.', 'buddypress' ),
						'type'        => 'integer',
					),
					'type'              => array(
						'context'     => array( 'view', 'edit' ),
						'description' => __( 'The type for the profile field.', 'buddypress' ),
						'type'        => 'string',
						'enum'        => buddypress()->profile->field_types,
						'arg_options' => array(
							'sanitize_callback' => 'sanitize_key',
						),
					),
					'name'              => array(
						'context'     => array( 'view', 'edit' ),
						'description' => __( 'The name of the profile field.', 'buddypress' ),
						'type'        => 'string',
						'arg_options' => array(
							'sanitize_callback' => 'sanitize_text_field',
						),
					),
					'description'       => array(
						'context'     => array( 'view', 'edit' ),
						'description' => __( 'The description of the profile field.', '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 profile field, as it exists in the database.', 'buddypress' ),
								'type'        => 'string',
								'context'     => array( 'edit' ),
							),
							'rendered' => array(
								'description' => __( 'HTML content for the profile field, transformed for display.', 'buddypress' ),
								'type'        => 'string',
								'context'     => array( 'view', 'edit' ),
								'readonly'    => true,
							),
						),
					),
					'is_required'       => array(
						'context'     => array( 'view', 'edit' ),
						'description' => __( 'Whether the profile field must have a value.', 'buddypress' ),
						'type'        => 'boolean',
					),
					'can_delete'        => array(
						'context'     => array( 'view', 'edit' ),
						'description' => __( 'Whether the profile field can be deleted or not.', 'buddypress' ),
						'default'     => true,
						'type'        => 'boolean',
					),
					'field_order'       => array(
						'context'     => array( 'view', 'edit' ),
						'description' => __( 'The order of the profile field into the group of fields.', 'buddypress' ),
						'type'        => 'integer',
					),
					'option_order'      => array(
						'context'     => array( 'view', 'edit' ),
						'description' => __( 'The order of the option into the profile field list of options', 'buddypress' ),
						'type'        => 'integer',
					),
					'order_by'          => array(
						'context'     => array( 'view', 'edit' ),
						'description' => __( 'The way profile field\'s options are ordered.', 'buddypress' ),
						'default'     => 'asc',
						'type'        => 'string',
						'enum'        => array( 'asc', 'desc' ),
					),
					'is_default_option' => array(
						'context'     => array( 'view', 'edit' ),
						'description' => __( 'Whether the option is the default one for the profile field.', 'buddypress' ),
						'type'        => 'boolean',
					),
					'visibility_level'  => array(
						'context'     => array( 'view', 'edit' ),
						'description' => __( 'Who may see the saved value for this profile field.', 'buddypress' ),
						'default'     => 'public',
						'type'        => 'string',
						'enum'        => array_keys( bp_xprofile_get_visibility_levels() ),
					),
					'options'  => array(
						'context'     => array( 'view', 'edit' ),
						'description' => __( 'Options of the profile field.', 'buddypress' ),
						'type'        => 'array',
						'readonly'    => true,
					),
					'data'              => array(
						'context'     => array( 'view', 'edit' ),
						'description' => __( 'The saved value for this profile field.', 'buddypress' ),
						'type'        => 'object',
						'readonly'    => true,
						'properties'  => array(
							'raw'          => array(
								'description' => __( 'Value for the field, as it exists in the database.', 'buddypress' ),
								'type'        => 'string',
								'context'     => array( 'view', 'edit' ),
							),
							'unserialized' => array(
								'description' => __( 'Unserialized value for the field, regular string will be casted as array.', 'buddypress' ),
								'type'        => 'array',
								'context'     => array( 'view', 'edit' ),
								'readonly'    => true,
							),
							'rendered'     => array(
								'description' => __( 'HTML value for the field, transformed for display.', 'buddypress' ),
								'type'        => 'string',
								'context'     => array( 'view', 'edit' ),
								'readonly'    => true,
							),
						),
					),
				),
			);
		}

		/**
		 * Filters the xprofile field schema.
		 *
		 * @param array $schema The endpoint schema.
		 */
		return apply_filters( 'bp_rest_xprofile_field_schema', $this->add_additional_fields_schema( $this->schema ) );
	}


Top ↑

Changelog Changelog

Changelog
Version Description
5.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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