mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
REST API endpoints for your WordPress content. These endpoints provide machine-readable external access to your WordPress site with a clear, standards-driven interface, allowing new and innovative apps for interacting with your site. These endpoints support all of the following: - Posts: Read and write access to all post data, for all types of post-based data, including pages and media. - Comments: Read and write access to all comment data. This includes pingbacks and trackbacks. - Terms: Read and write access to all term data. - Users: Read and write access to all user data. This includes public access to some data for post authors. - Meta: Read and write access to metadata for posts, comments, terms, and users, on an opt-in basis from plugins. - Settings: Read and write access to settings, on an opt-in basis from plugins and core. This enables API management of key site content values that are technically stored in options, such as site title and byline. Love your REST API, WordPress! The infrastructure says, "Let's do lunch!" but the content API endpoints say, "You're paying!" Props rmccue, rachelbaker, danielbachhuber, joehoyle, adamsilverstein, afurculita, ahmadawais, airesvsg, alisspers, antisilent, apokalyptik, artoliukkonen, attitude, boonebgorges, bradyvercher, brianhogg, caseypatrickdriscoll, chopinbach, chredd, christianesperar, chrisvanpatten, claudiolabarbera, claudiosmweb, cmmarslender, codebykat, coderkevin, codfish, codonnell822, daggerhart, danielpunkass, davidbhayes, delphinus, desrosj, dimadin, dotancohen, DrewAPicture, Dudo1985, duncanjbrown, eherman24, eivhyl, eliorivero, elyobo, en-alis, ericandrewlewis, ericpedia, evansobkowicz, fjarrett, frozzare, georgestephanis, greatislander, guavaworks, hideokamoto, hkdobrev, hubdotcom, hurtige, iandunn, ircrash, ironpaperweight, iseulde, Japh, jaredcobb, JDGrimes, jdolan, jdoubleu, jeremyfelt, jimt, jjeaton, jmusal, jnylen0, johanmynhardt, johnbillion, jonathanbardo, jorbin, joshkadis, JPry, jshreve, jtsternberg, JustinSainton, kacperszurek, kadamwhite, kalenjohnson, kellbot, kjbenk, kokarn, krogsgard, kuchenundkakao, kuldipem, kwight, lgedeon, lukepettway, mantismamita, markoheijnen, matrixik, mattheu, mauteri, maxcutler, mayukojpn, michael-arestad, miyauchi, mjbanks, modemlooper, mrbobbybryant, NateWr, nathanrice, netweb, NikV, nullvariable, oskosk, oso96_2000, oxymoron, pcfreak30, pento, peterwilsoncc, Pezzab, phh, pippinsplugins, pjgalbraith, pkevan, pollyplummer, pushred, quasel, QWp6t, schlessera, schrapel, Shelob9, shprink, simonlampen, Soean, solal, tapsboy, tfrommen, tharsheblows, thenbrent, tierra, tlovett1, tnegri, tobych, Toddses, toro_unit, traversal, vanillalounge, vishalkakadiya, wanecek, web2style, webbgaraget, websupporter, westonruter, whyisjake, wonderboymusic, wpsmith, xknown, zyphonic. Fixes #38373. git-svn-id: https://develop.svn.wordpress.org/trunk@38832 602fd350-edb4-49c9-b593-d223f7449a82
79 lines
1.9 KiB
PHP
79 lines
1.9 KiB
PHP
<?php
|
|
/**
|
|
* Unit tests covering WP_REST_Controller functionality
|
|
*
|
|
* @package WordPress
|
|
* @subpackage REST API
|
|
*/
|
|
|
|
/**
|
|
* @group restapi
|
|
*/
|
|
class WP_REST_Test_Controller extends WP_REST_Controller {
|
|
|
|
/**
|
|
* Get the Post type's schema, conforming to JSON Schema
|
|
*
|
|
* @return array
|
|
*/
|
|
public function get_item_schema() {
|
|
$schema = array(
|
|
'$schema' => 'http://json-schema.org/draft-04/schema#',
|
|
'title' => 'type',
|
|
'type' => 'object',
|
|
'properties' => array(
|
|
'somestring' => array(
|
|
'type' => 'string',
|
|
'description' => 'A pretty string.',
|
|
'context' => array( 'view' ),
|
|
),
|
|
'someinteger' => array(
|
|
'type' => 'integer',
|
|
'context' => array( 'view' ),
|
|
),
|
|
'someboolean' => array(
|
|
'type' => 'boolean',
|
|
'context' => array( 'view' ),
|
|
),
|
|
'someurl' => array(
|
|
'type' => 'string',
|
|
'format' => 'uri',
|
|
'context' => array( 'view' ),
|
|
),
|
|
'somedate' => array(
|
|
'type' => 'string',
|
|
'format' => 'date-time',
|
|
'context' => array( 'view' ),
|
|
),
|
|
'someemail' => array(
|
|
'type' => 'string',
|
|
'format' => 'email',
|
|
'context' => array( 'view' ),
|
|
),
|
|
'someenum' => array(
|
|
'type' => 'string',
|
|
'enum' => array( 'a', 'b', 'c' ),
|
|
'context' => array( 'view' ),
|
|
),
|
|
'someargoptions' => array(
|
|
'type' => 'integer',
|
|
'required' => true,
|
|
'arg_options' => array(
|
|
'required' => false,
|
|
'sanitize_callback' => '__return_true',
|
|
),
|
|
),
|
|
'somedefault' => array(
|
|
'type' => 'string',
|
|
'enum' => array( 'a', 'b', 'c' ),
|
|
'context' => array( 'view' ),
|
|
'default' => 'a',
|
|
),
|
|
),
|
|
);
|
|
|
|
return $schema;
|
|
}
|
|
|
|
}
|