Docs: Document the globals used in some REST API methods.

See #53399.

git-svn-id: https://develop.svn.wordpress.org/trunk@51278 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2021-06-30 12:33:43 +00:00
parent 8a7495701f
commit aa99d7e7a3
5 changed files with 39 additions and 15 deletions
@@ -504,11 +504,14 @@ abstract class WP_REST_Controller {
*
* @since 4.7.0
*
* @global array $wp_rest_additional_fields Holds registered fields, organized by object type.
*
* @param string $object_type Optional. The object type.
* @return array Registered additional fields (if any), empty array if none or if the object type could
* not be inferred.
* @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 ) {
global $wp_rest_additional_fields;
if ( ! $object_type ) {
$object_type = $this->get_object_type();
@@ -518,8 +521,6 @@ abstract class WP_REST_Controller {
return array();
}
global $wp_rest_additional_fields;
if ( ! $wp_rest_additional_fields || ! isset( $wp_rest_additional_fields[ $object_type ] ) ) {
return array();
}