LLMS_REST_Controller::get_item_schema()

Get the LLMS REST resource schema, conforming to JSON Schema.


Return Return

(array)


Top ↑

Source Source

File: libraries/lifterlms-rest/includes/abstracts/class-llms-rest-controller.php

	public function get_item_schema() {

		if ( isset( $this->schema ) ) {
			// Additional fields are not cached in the schema, @see https://core.trac.wordpress.org/ticket/47871#comment:5.
			return $this->add_additional_fields_schema( $this->schema );
		}

		$schema = $this->get_item_schema_base();

		// Add custom fields registered via `register_meta()`.
		$schema = $this->add_meta_fields_schema( $schema );

		// Allow the schema to be filtered.
		$schema = $this->filter_item_schema( $schema );

		/**
		 * Set `$this->schema` here so that we can exclude additional fields
		 * already covered by the base, filtered, schema.
		 *
		 * Additional fields are added through the call to add_additional_fields_schema() below,
		 * which will call {@see LLMS_REST_Controller::get_additional_fields()}, which requires
		 * `$this->schema` to be set.
		 */
		$this->schema = $schema;

		/**
		 * Adds the schema from additional fields (registered via `register_rest_field()`) to the schema array.
		 * Note: WordPress core doesn't cache the additional fields in the schema, see https://core.trac.wordpress.org/ticket/47871#comment:5
		 */
		return $this->add_additional_fields_schema( $this->schema );
	}


Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0-beta.27 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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