LLMS_REST_Controller::register_routes()
Register routes.
Return Return
(void)
Source Source
File: libraries/lifterlms-rest/includes/abstracts/class-llms-rest-controller.php
/** * Retrieves all of the registered additional fields for a given object-type. * * Overrides wp core `get_additional_fields()` to allow excluding fields. * * @since 1.0.0-beta.27 * * @param string $object_type The object type. * @return array Registered additional fields (if any), empty array if none or if the object type could * not be inferred. */ protected function get_additional_fields( $object_type = null ) { // We require the `$this->schema['properties']` to be set in order to exclude additional fields already covered by our schema definition. if ( ! isset( $this->schema['properties'] ) ) { return parent::get_additional_fields( $object_type ); } $additional_fields = parent::get_additional_fields( $object_type ); if ( ! empty( $additional_fields ) ) { /** * Filters the disallowed additional fields. * * The dynamic portion of the hook name, `$object_type`, refers the object type this controller is responsible for managing. * * @since 1.0.0-beta.27 * * @param string[] $disallowed_additional_fields Additional rest field names to skip (added via `register_rest_field()`). */ $disallowed_fields = apply_filters( "llms_rest_{$object_type}_disallowed_additional_fields", $this->disallowed_additional_fields ); /** * Exclude: * - disallowed fields defined in the instance's property `disallowed_additional_fields`. * - additional fields already covered in the schema. * * This is meant to run only once, because otherwise we have no way * to determine whether the property comes from the original schema * definition, or has been added via `register_rest_field()`. */ $additional_fields = array_diff_key( $additional_fields, array_flip( array_keys( $this->schema['properties'] ) ), array_flip( $disallowed_fields ) ); } return $additional_fields; } /** * Exclude disallowed meta fields. *
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
1.0.0-beta.1 | Introduced. |