WP_REST_Controller::get_additional_fields
Retrieves all of the registered additional fields for a given object-type.
Method of the class: WP_REST_Controller{}
No Hooks.
Returns
Array. Registered additional fields (if any), empty array if none or if the object type could not be inferred.
Usage
// protected - for code of main (parent) or child class $result = $this->get_additional_fields( $object_type );
- $object_type(string)
- The object type.
Default: null
Notes
- Global. Array. $wp_rest_additional_fields Holds registered fields, organized by object type.
Changelog
| Since 4.7.0 | Introduced. |
WP_REST_Controller::get_additional_fields() WP REST Controller::get additional fields code WP 6.8.3
protected function get_additional_fields( $object_type = null ) {
global $wp_rest_additional_fields;
if ( ! $object_type ) {
$object_type = $this->get_object_type();
}
if ( ! $object_type ) {
return array();
}
if ( ! $wp_rest_additional_fields || ! isset( $wp_rest_additional_fields[ $object_type ] ) ) {
return array();
}
return $wp_rest_additional_fields[ $object_type ];
}