WP_REST_Controller::get_additional_fields() protected WP 4.7.0
Retrieves all of the registered additional fields for a given object-type.
{} It's a method of the class: WP_REST_Controller{}
No Hooks.
Return
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
Changelog
Since 4.7.0 | Introduced. |
Code of WP_REST_Controller::get_additional_fields() WP REST Controller::get additional fields WP 5.6
protected function get_additional_fields( $object_type = null ) {
if ( ! $object_type ) {
$object_type = $this->get_object_type();
}
if ( ! $object_type ) {
return array();
}
global $wp_rest_additional_fields;
if ( ! $wp_rest_additional_fields || ! isset( $wp_rest_additional_fields[ $object_type ] ) ) {
return array();
}
return $wp_rest_additional_fields[ $object_type ];
}