kollapsminoriteten/wp-content/plugins/jetpack/json-endpoints/class.wpcom-json-api-taxono...

52 lines
1.5 KiB
PHP
Raw Normal View History

2022-06-16 14:01:47 +02:00
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
* Taxonomy endpoint.
*/
2019-11-15 23:26:29 +01:00
abstract class WPCOM_JSON_API_Taxonomy_Endpoint extends WPCOM_JSON_API_Endpoint {
2022-06-16 14:01:47 +02:00
/**
* Category object format.
*
* @var array
*/
2019-11-15 23:26:29 +01:00
public $category_object_format = array(
'ID' => '(int) The category ID.',
2022-06-16 14:01:47 +02:00
'name' => '(string) The name of the category.',
'slug' => '(string) The slug of the category.',
2019-11-15 23:26:29 +01:00
'description' => '(string) The description of the category.',
2022-06-16 14:01:47 +02:00
'post_count' => '(int) The number of posts using this category.',
2019-11-15 23:26:29 +01:00
'feed_url' => '(string) The URL of the feed for this category.',
2022-06-16 14:01:47 +02:00
'parent' => '(int) The parent ID for the category.',
2019-11-15 23:26:29 +01:00
'meta' => '(object) Meta data',
);
2022-06-16 14:01:47 +02:00
/**
* Tag object format.
*
* @var array
*/
2019-11-15 23:26:29 +01:00
public $tag_object_format = array(
'ID' => '(int) The tag ID.',
2022-06-16 14:01:47 +02:00
'name' => '(string) The name of the tag.',
'slug' => '(string) The slug of the tag.',
2019-11-15 23:26:29 +01:00
'description' => '(string) The description of the tag.',
2022-06-16 14:01:47 +02:00
'post_count' => '(int) The number of posts using this t.',
2019-11-15 23:26:29 +01:00
'meta' => '(object) Meta data',
);
2022-06-16 14:01:47 +02:00
/**
* Constructor function.
*
* @param string|array|object $args - the arguments.
*/
public function __construct( $args ) {
2019-11-15 23:26:29 +01:00
parent::__construct( $args );
2022-06-16 14:01:47 +02:00
if ( preg_match( '#/tags/#i', $this->path ) ) {
2019-11-15 23:26:29 +01:00
$this->response_format =& $this->tag_object_format;
2022-06-16 14:01:47 +02:00
} else {
2019-11-15 23:26:29 +01:00
$this->response_format =& $this->category_object_format;
2022-06-16 14:01:47 +02:00
}
2019-11-15 23:26:29 +01:00
}
}