WP_REST_Plugins_Controller::get_item_schema(): array

In this article

Retrieves the plugin’s schema, conforming to JSON Schema.

Return

array Item schema data.

Source

public function get_item_schema() {
	if ( $this->schema ) {
		return $this->add_additional_fields_schema( $this->schema );
	}

	$this->schema = array(
		'$schema'    => 'http://json-schema.org/draft-04/schema#',
		'title'      => 'plugin',
		'type'       => 'object',
		'properties' => array(
			'plugin'       => array(
				'description' => __( 'The plugin file.' ),
				'type'        => 'string',
				'pattern'     => self::PATTERN,
				'readonly'    => true,
				'context'     => array( 'view', 'edit', 'embed' ),
			),
			'status'       => array(
				'description' => __( 'The plugin activation status.' ),
				'type'        => 'string',
				'enum'        => is_multisite() ? array( 'inactive', 'active', 'network-active' ) : array( 'inactive', 'active' ),
				'context'     => array( 'view', 'edit', 'embed' ),
			),
			'name'         => array(
				'description' => __( 'The plugin name.' ),
				'type'        => 'string',
				'readonly'    => true,
				'context'     => array( 'view', 'edit', 'embed' ),
			),
			'plugin_uri'   => array(
				'description' => __( 'The plugin\'s website address.' ),
				'type'        => 'string',
				'format'      => 'uri',
				'readonly'    => true,
				'context'     => array( 'view', 'edit' ),
			),
			'author'       => array(
				'description' => __( 'The plugin author.' ),
				'type'        => 'object',
				'readonly'    => true,
				'context'     => array( 'view', 'edit' ),
			),
			'author_uri'   => array(
				'description' => __( 'Plugin author\'s website address.' ),
				'type'        => 'string',
				'format'      => 'uri',
				'readonly'    => true,
				'context'     => array( 'view', 'edit' ),
			),
			'description'  => array(
				'description' => __( 'The plugin description.' ),
				'type'        => 'object',
				'readonly'    => true,
				'context'     => array( 'view', 'edit' ),
				'properties'  => array(
					'raw'      => array(
						'description' => __( 'The raw plugin description.' ),
						'type'        => 'string',
					),
					'rendered' => array(
						'description' => __( 'The plugin description formatted for display.' ),
						'type'        => 'string',
					),
				),
			),
			'version'      => array(
				'description' => __( 'The plugin version number.' ),
				'type'        => 'string',
				'readonly'    => true,
				'context'     => array( 'view', 'edit' ),
			),
			'network_only' => array(
				'description' => __( 'Whether the plugin can only be activated network-wide.' ),
				'type'        => 'boolean',
				'readonly'    => true,
				'context'     => array( 'view', 'edit', 'embed' ),
			),
			'requires_wp'  => array(
				'description' => __( 'Minimum required version of WordPress.' ),
				'type'        => 'string',
				'readonly'    => true,
				'context'     => array( 'view', 'edit', 'embed' ),
			),
			'requires_php' => array(
				'description' => __( 'Minimum required version of PHP.' ),
				'type'        => 'string',
				'readonly'    => true,
				'context'     => array( 'view', 'edit', 'embed' ),
			),
			'textdomain'   => array(
				'description' => __( 'The plugin\'s text domain.' ),
				'type'        => 'string',
				'readonly'    => true,
				'context'     => array( 'view', 'edit' ),
			),
		),
	);

	return $this->add_additional_fields_schema( $this->schema );
}

Changelog

VersionDescription
5.5.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.