Code Duplication    Length = 21-22 lines in 2 locations

lib/endpoints/class-wp-rest-users-controller.php 1 location

@@ 849-870 (lines=22) @@
846
			),
847
		);
848
849
		if ( get_option( 'show_avatars' ) ) {
850
			$avatar_properties = array();
851
852
			$avatar_sizes = rest_get_avatar_sizes();
853
			foreach ( $avatar_sizes as $size ) {
854
				$avatar_properties[ $size ] = array(
855
					'description' => sprintf( __( 'Avatar URL with image size of %d pixels.' ), $size ),
856
					'type'        => 'string',
857
					'format'      => 'uri',
858
					'context'     => array( 'embed', 'view', 'edit' ),
859
				);
860
			}
861
862
			$schema['properties']['avatar_urls']  = array(
863
				'description' => __( 'Avatar URLs for the resource.' ),
864
				'type'        => 'object',
865
				'context'     => array( 'embed', 'view', 'edit' ),
866
				'readonly'    => true,
867
				'properties'  => $avatar_properties,
868
			);
869
870
		}
871
872
		return $this->add_additional_fields_schema( $schema );
873
	}

lib/endpoints/class-wp-rest-comments-controller.php 1 location

@@ 931-951 (lines=21) @@
928
			),
929
		);
930
931
		if ( get_option( 'show_avatars' ) ) {
932
			$avatar_properties = array();
933
934
			$avatar_sizes = rest_get_avatar_sizes();
935
			foreach ( $avatar_sizes as $size ) {
936
				$avatar_properties[ $size ] = array(
937
					'description' => sprintf( __( 'Avatar URL with image size of %d pixels.' ), $size ),
938
					'type'        => 'string',
939
					'format'      => 'uri',
940
					'context'     => array( 'embed', 'view', 'edit' ),
941
				);
942
			}
943
944
			$schema['properties']['author_avatar_urls'] = array(
945
				'description'   => __( 'Avatar URLs for the object author.' ),
946
				'type'          => 'object',
947
				'context'       => array( 'view', 'edit', 'embed' ),
948
				'readonly'      => true,
949
				'properties'    => $avatar_properties,
950
			);
951
		}
952
953
		return $this->add_additional_fields_schema( $schema );
954
	}